Closed GoogleCodeExporter closed 9 years ago
this example (which uses the same patch technique as monkey.patch_thread())
shows the
underlying problem on my python 2.6.4 install:
---
import thread
import _threading_local
thread._local = _threading_local.local
import threading
print "threading.local is", threading.local, "instead of",
_threading_local.local
---
I get:
---
threading.local is <type 'thread._local'> instead of <class
'_threading_local.local'>
---
I added a "print thread._local" line to the top of my install's threading.py,
and it
prints out <type 'thread._local'>, despite the line directly above 'import
threading'
that sets thread._local to _threading_local.local. Somehow, threading.py in the
python install is magically finding the original <type 'thread._local'>.
I copied my python's threading.py to mythreading.py and put it in the same
directory
as my python test script. If I import mythreading instead of threading, the
problem
goes away. I don't know enough about python's import system to debug any
further.
Hopefully this problem is only affecting my install. I'm working around it by
adding
"threading.local = _threading_local.local" after I import threading.
Original comment by tsuz...@gmail.com
on 30 Apr 2010 at 7:49
Verified that this problem can be simply fixed by adding the following lines to
the beginning of your program.
---
import gevent.monkey
gevent.monkey.patch_all()
import threading
import thread
threading.local = thread._local
---
Original comment by thewrong...@gmail.com
on 4 May 2010 at 3:53
[deleted comment]
Please note that _threading_local is broken in many Python versions. You may
want to
apply the patch in the following issue first.
http://bugs.python.org/issue1522237
Original comment by thewrong...@gmail.com
on 4 May 2010 at 10:03
Fixed in the trunk.
gevent now has gevent.local module:
http://bitbucket.org/denis/gevent/src/tip/gevent/local.py
gevent.monkey uses it when patching thread and it also patches threading now.
Original comment by Denis.Bi...@gmail.com
on 20 May 2010 at 9:35
Migrated to http://github.com/SiteSupport/gevent/issues/24
Original comment by Denis.Bi...@gmail.com
on 14 Sep 2012 at 10:51
Original issue reported on code.google.com by
tsuz...@gmail.com
on 30 Apr 2010 at 6:20Attachments: