shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

_context threadlocal incompatible with eventlet green threads #118

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
luke@node041 ~ $ python
Python 2.7.3 (default, Sep 25 2013, 09:17:55) 
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
>>> eventlet.monkey_patch()
>>> import numexpr

What is the expected output? What do you see instead?
Expected to import cleanly. Instead, it raises:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/zymeworks/devtools/4.3/lib/python2.7/site-packages/numexpr-2.0.1-py2.7-linux-x86_64.egg/numexpr/__init__.py", line 38, in <module>
    from numexpr.expressions import E
  File "/opt/zymeworks/devtools/4.3/lib/python2.7/site-packages/numexpr-2.0.1-py2.7-linux-x86_64.egg/numexpr/expressions.py", line 60, in <module>
    _context = Context({})
  File "/opt/zymeworks/devtools/4.3/lib/python2.7/site-packages/numexpr-2.0.1-py2.7-linux-x86_64.egg/numexpr/expressions.py", line 49, in __init__
    raise SystemError('__init__ called too many times')
SystemError: __init__ called too many times

What version of the product are you using? On what operating system?
Python 2.7.3
eventlet==0.13.0
numexpr==2.0.1

Please provide any additional information below.
I believe there is a problem with the implementation of 
numexpr.expressions:Context. It overrides the __init__ method and does not call 
super(). Since __dict__ is available by default, you can simply remove the 
__init__ method like so:

46,51d60
<     initialized = False
<     def __init__(self, dict_):
<         if self.initialized:
<             raise SystemError('__init__ called too many times')
<         self.initialized = True
<         self.__dict__.update(dict_)
60c69
< _context = Context({})

---
> _context = Context()

Indeed, that fixes the problem for me, but I'm unsure what other implications 
it may have.

Original issue reported on code.google.com by lukec...@gmail.com on 29 Oct 2013 at 5:45