By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Pausing Threads?

P: 8
I have created a program with a gui that uses threads to accomplish it's task, what I was wondering was is how the 'pause' effect can be accomplished in python?

so here's what I want to accomplish:
They push the pause button, and all threads stop what they're doing. The threads also should be able to resume upon the user's request.
May 23 '07 #1
Share this Question
Share on Google+
6 Replies


bartonc
Expert 5K+
P: 6,596
I have created a program with a gui that uses threads to accomplish it's task, what I was wondering was is how the 'pause' effect can be accomplished in python?

so here's what I want to accomplish:
They push the pause button, and all threads stop what they're doing. The threads also should be able to resume upon the user's request.
The simplest (and one of the few thread-safe ways) way is to use an threading.Event object shared by the main thread and the worker thread. By using (say) pauseEvent.set() in the main thread and eventPassedInThreadArgsEvent.isSet() in the worker, you can control the thread's behavior.

Ps: sorry for the late reply. Yesterday was quite hectic and today I finally got my new SOHO network up to speed.

Thanks for joining (and the comment in the Articles Section).
May 24 '07 #2

bartonc
Expert 5K+
P: 6,596
Is "Sardonic" like sarcastic, only different?
May 25 '07 #3

P: 8
Thank you for your help ^_^

"Derived from the Greek Sardonios which means bitter or scornful laughter: the primary reference is to the effects of eating a Sardinian plant which was said to produce facial convulsions resembling horrible laughter, usually followed by death."
~_~
Jun 2 '07 #4

bartonc
Expert 5K+
P: 6,596
Thank you for your help ^_^

"Derived from the Greek Sardonios which means bitter or scornful laughter: the primary reference is to the effects of eating a Sardinian plant which was said to produce facial convulsions resembling horrible laughter, usually followed by death."
~_~
VERY interesting. Thanks for sharing.
Have you got any working code that you'd like to share with our members who may come up against the same type of problem?
Jun 2 '07 #5

P: 8
VERY interesting. Thanks for sharing.
Have you got any working code that you'd like to share with our members who may come up against the same type of problem?
not quite yet, i'm still trying to figure it out myself. I'll post the program I'm currently working on (it's my first real program in any language, so you can imagine how gruesome it'll be ^_^).
Jun 4 '07 #6

bartonc
Expert 5K+
P: 6,596
not quite yet, i'm still trying to figure it out myself. I'll post the program I'm currently working on (it's my first real program in any language, so you can imagine how gruesome it'll be ^_^).
By all means, we're here to help with any stage of development!
A multi-threaded program is a huge chunk to bite into for a beginner. Luckily, Python is quite a forgiving language in that regard.
Have fun and keep posting,
Barton
Jun 4 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.