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

Threading program with issues when executing from IDLE

P: n/a
People, executing the following code from command line, it works as expected
(you see "th1 - 2" *always* after "th2 - 2").

But when I execute from IDLE one of two things happens:

- Everything freezes up after "th1 - 1".
- The program finishes but after I get an strange internal IDLE error.

There's a way to avoid that?

The code:

-----------------
import threading

def thfunc1():
print "th1 - 1"
event.wait()
print "th1 - 2"

def thfunc2():
print "th2 - 1"
print "th2 - 2"
event.set()

event = threading.Event()

th1 = threading.Thread(target=thfunc1)
th2 = threading.Thread(target=thfunc2)

th2.start()
th1.start()
-----------------

Thank you all!

.. Facundo

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.