I'm using djangoflup+fastgic+ngix. It works good.
Now I planned to upgrade from python 2.6.6 to 2.7.2 and met a problem to import flup in python 2.7.
Python 2.7.2 (Red Hat 4.1.2-50)
>>> import sys
>>> sys.path
['', '......',
'/usr/local/lib/python2.7.2/lib/python2.7/site-packages/flup-1.0.2-py2.7.egg', '......']
>>> import flup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named flup
It works perfectly on the SAME host under python 2.6.
Python 2.6.6 (Red Hat 4.1.2-50)
>>> import sys
>>> sys.path
['', '......', '/usr/local/lib/python2.6/site-packages/flup-1.0.1-py2.6.egg', '......']
>>> import flup
>>>
Any idea about the reason?
Newer versions of flup dropped support for python2.7 (accidentally?)
You can install an older one that works with:
pip install flup==1.0.3.dev-20110405
The problem is with a change in importing threading capability. The latest (as of this writing) version of flup is 1.0.3 and can be fixed with the following patch:
diff -puNr flup-1.0.3/lib/python2.7/site-packages/flup/server/fcgi_base.py flup-1.0.3.fixed/lib/python2.7/site-packages/flup/server/fcgi_base.py
--- flup-1.0.3/lib/python2.7/site-packages/flup/server/fcgi_base.py 2019-02-03 23:13:24.305329000 +0000
+++ flup-1.0.3.fixed/lib/python2.7/site-packages/flup/server/fcgi_base.py 2019-02-03 23:12:12.319327934 +0000
@@ -38,11 +38,14 @@ import errno
import traceback
try:
- import _thread
+ try:
+ import _thread
+ except ImportError:
+ import thread as _thread
import threading
thread_available = True
except ImportError:
- import _dummy_thread as thread
+ import _dummy_thread as _thread
import dummy_threading as threading
thread_available = False
Above, I preserved the original behaviour (importing _thread first), then it will fallback to import thread as _thread. I also fixed the fallback option since whoever introduced the change forgot to fix the fallback.
Given that RHEL/CentOS 7 are still running Python 2.7 this fix would be needed for some time. Unfortunately, I failed to locate the current home for flup to be able to push this fix upstream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With