Re: Retrying to send message

2015-06-03 Thread Cecil Westerhof
Op Thursday 4 Jun 2015 01:15 CEST schreef Ethan Furman: > On 06/03/2015 01:37 PM, Mark Lawrence wrote: >> On 03/06/2015 19:28, Ethan Furman wrote: >>> On 06/03/2015 09:15 AM, Cecil Westerhof wrote: >>> I kept the except. I like to see the message that went wrong. ;-) >>> >>> That's fine, but

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 01:37 PM, Mark Lawrence wrote: On 03/06/2015 19:28, Ethan Furman wrote: On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that

Re: Retrying to send message

2015-06-03 Thread Chris Angelico
On Thu, Jun 4, 2015 at 2:15 AM, Cecil Westerhof wrote: >> And I'd also skip the bare except clause. If you get any sort of >> exception, whether it's a bug, a failure from libturpial, a network >> error, or anything else, your code will just terminate with a bland >> and useless message. Much bett

Re: Retrying to send message

2015-06-03 Thread Mark Lawrence
On 03/06/2015 19:28, Ethan Furman wrote: On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that message failed. -- ~Ethan~ Why bother in th

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that message failed. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Retrying to send message

2015-06-03 Thread MRAB
On 2015-06-03 17:15, Cecil Westerhof wrote: Op Wednesday 3 Jun 2015 15:29 CEST schreef Chris Angelico: On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: def send_message(account_id, message, max_tries, terminate_program): error_msg = 'Something went wrong with: ' + message not_send = Tr

Re: Retrying to send message

2015-06-03 Thread Cecil Westerhof
Op Wednesday 3 Jun 2015 15:29 CEST schreef Chris Angelico: > On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: >> def send_message(account_id, message, max_tries, >> terminate_program): error_msg = 'Something went wrong with: ' + >> message not_send = True tries = 0 while not_send: try: >>

Re: Retrying to send message

2015-06-03 Thread Chris Angelico
On Wed, Jun 3, 2015 at 10:27 PM, Cecil Westerhof wrote: > def send_message(account_id, message, max_tries, terminate_program): > error_msg = 'Something went wrong with: ' + message > not_send= True > tries = 0 > while not_send: > try: >

Retrying to send message

2015-06-03 Thread Cecil Westerhof
I am using libturpial to post messages on Twitter. Sometimes I get a libturpial.exceptions.ServiceOverCapacity. It is a good idea to try it again then. For this I wrote the following function: def send_message(account_id, message, max_tries, terminate_program): error_msg = 'Something