Re: what thread-synch mech to use for clean exit from a thread

2013-07-15 Thread MRAB
On 15/07/2013 04:04, Steven D'Aprano wrote: On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: A currency exchange thread updates exchange rate once a minute. If the thread faield to update currency rate for 5 hours, it should inform main() for a clean exit. This has to be done gracefully

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
Oh, I forgot another comment... On Mon, 15 Jul 2013 03:04:14 +, Steven D'Aprano wrote: > On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: >>while time.time() - self.rate_timestamp < 5*3600: >> ... # update exchange rate >> if success: >> self.

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: > A currency exchange thread updates exchange rate once a minute. If the > thread faield to update currency rate for 5 hours, it should inform > main() for a clean exit. This has to be done gracefully, because main() > could be doing somethi

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread zhangweiwu
On Monday, July 15, 2013 10:27:45 AM UTC+8, Gildor Oronar wrote: > What is the professional way in this case? Hi. I am not a professional neither but I think a professional does this: class CurrencyExchange(): def __init__(in_case_callback): this.callback = in_case_callback def __r