Simple threading example freezes IDLE?

Sergio Correia sergio.correia at
Wed Sep 26 23:50:42 CEST 2007

I think the -print- command, as used in IDLE, is not thread-safe. I
was bitten by an issue like that today, and the problem ended up being
the -print- command I used.

On the cmd line, it works per-fect-ly.. but IDLE seems to be the culprit.
A possible answer seems to be to write a wrapper for print that makes
it thread safe (with the help of a lock.

On 9/19/07, writser at <writser at> wrote:
> hey all,
> For my study I'm writing a simple threaded webcrawler and I am trying
> to do this in python. But somehow, using threads causes IDLE to crash
> on Windows XP (with the latest python distribution 2.5.1). Even a
> simple example such as this:
> import thread, time
> def doSomething():
>   print "something"
> for i in range(2):
>   thread.start_new(doSomething, ())
> causes IDLE to freeze when I type it in the interpreter. Using the
> python command line everything works just fine. Using IDLE on Debian
> linux also does not cause anything to crash. What am I overlooking?
> regards, Writser Cleveringa
> --

More information about the Python-list mailing list