[CentralOH] Fwd: Re: Stackless Python
brian.costlow at gmail.com
Wed Nov 4 20:50:22 CET 2009
Didn't see any public responses to your post of your code, wondered if you
got any private help?
I took a quick look at the code, and I am certain that the GIL issues are
what are slowing down your threaded version.
There's nothing you can do to code around that, the GIL keeps python from
running threaded code sanely in a multicore environment.
It's an implementation limitation of CPython.
You do need to add your lock around your 'done' print statement. The GIL is
removed for I/O and without the lock, these intermix with the worker
threads' print statements.
Thread number 7 1 7.07142857143
Thread number 27 6.93
Thread number 3 is done
for pingle in pinglist:
print "Thread number ",pingle.number,"is done"
I noticed from your comments in the code that this was originally doing
pings. That's I/O bound and could be a case where threads would help in a
single-core setup. But after looking at David Beazley's talk, probably would
still behave badly on multiple cores.
However, for I/O bound code, as opposed to processor-bound, Stackless might
Other possibilities would be Eventlet, Twisted, or rolling your own
asynchronous code using asyncore.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the CentralOH