On 2019-05-25 13:46:40 +0200, Cecil Westerhof wrote: > Just changing the while loop to a for loop did not make sense to me, > but this does. I now have: > max_tries = 5 > for current_try in range(1, max_tries): > try: > posted = twitter.update_status(status = message, > in_reply_to_status_id = message_id, > trim_user = True) > return posted['id'] > except TwythonError as e: > if not 'Temporary failure in name resolution' in e.msg: > raise > timed_message('Failed on try: {0} of {1}'.format(current_try, > max_tries)) > if current_try == max_tries: ^^^^^^^^^^^^^^^^^^^^^^^^ This will never be true because the loop will exit before current_try reaches max_tries. > print('Could not get a connection to the internet: exiting') > deinit(2) Also you don't seem to stop here (unless deinit raises an exception)
> time.sleep(60) > raise RuntimeError('Should not get here') ^^^^^^^^^^^^^^^^^^^^^ So if you can't get a status update you will reach this point. hp -- _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | h...@hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list