wxPython and threading issue
steve at holdenweb.com
Fri Sep 29 08:00:10 CEST 2006
Patrick Smith wrote:
> Thanks for your reply.
> <sjdevnull at yahoo.com> wrote in message
> news:1159499923.311082.63610 at h48g2000cwc.googlegroups.com...
>>Patrick Smith wrote:
>>>I'm hoping someone here will be able to help as I've been struggling
>>>this problem for a few days now.
>>>I'm working on an application that is creating a ProgressDialog, and
>>>creating a thread that runs a function from another module in the
>>>The problem is, when the cancel button on the ProgressDialog is pressed,
>>>thread that was created continues to run. How can I make it so that
>>>the cancel button on the dialog is clicked, the spawned thread dies?
>>Have the main thread set a flag telling the worker thread to exit, and
>>have the worker thread check that periodically when it knows it's in a
>>safe state to exit.
> This would work, unfortunately, the thread that it spawns calls a function
> in a loop, that function has an incredibly long run-time, on the order of
> minutes (possibly hours depending on the input), and that function, its self
> is multithreaded.
> This means that the worker thread could only check the flag after each
> completion of this long-running function.
> Given that this is the situation, is it possible to do what I mentioned
> above? Or does the long running function prevent any nice way of doing
If the function is a black box then you are stymied, I suspect.
Had you considered using a sub-process instead of a thread to perform
the lengthy computation?
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list