我尝试在Raspberry Pi上的Python3.7上使用gevent运行我的Flask项目,并在第一行使用gevent.monkey.patch_all()。但它最终出现了这个错误:
Traceback (most recent call last):
File "src/gevent/_hub_local.py", line 71, in gevent._gevent_c_hub_local.get_hub
File "src/gevent/_hub_local.py", line 80, in gevent._gevent_c_hub_local.get_hub_noargs
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/hub.py", line 445, in __init__
self.loop = self.loop_class(flags=loop, default=default) # pylint:disable=not-callable
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/hub.py", line 459, in loop_class
return GEVENT_CONFIG.loop
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/_config.py", line 50, in getter
return self.settings[setting_name].get()
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/_config.py", line 146, in get
self.value = self.validate(self._default())
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/_config.py", line 248, in validate
return self._import_one_of([self.shortname_map.get(x, x) for x in value])
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/_config.py", line 219, in _import_one_of
return self._import_one(item)
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/_config.py", line 237, in _import_one
module = importlib.import_module(module)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 980, in _find_and_load
File "<frozen importlib._bootstrap>", line 149, in __enter__
File "<frozen importlib._bootstrap>", line 88, in acquire
File "src/gevent/_semaphore.py", line 273, in gevent._gevent_c_semaphore.Semaphore.__enter__
File "src/gevent/_semaphore.py", line 274, in gevent._gevent_c_semaphore.Semaphore.__enter__
File "src/gevent/_semaphore.py", line 175, in gevent._gevent_c_semaphore.Semaphore.acquire
File "/home/pi/server/venv/lib/python3.7/site-packages/gevent/thread.py", line 121, in acquire
acquired = BoundedSemaphore.acquire(self, blocking, timeout)
File "src/gevent/_semaphore.py", line 175, in gevent._gevent_c_semaphore.Semaphore.acquire
File "src/gevent/_semaphore.py", line 200, in gevent._gevent_c_semaphore.Semaphore.acquire
OverflowError: Python int too large to convert to C long在我的PC (Python3.8)上,哪里一切都正常,我收到了这样的警告:
init.py:1: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (/usr/local/lib/python3.8/dist-packages/urllib3/util/__init__.py)', 'urllib3.util.ssl_ (/usr/local/lib/python3.8/dist-packages/urllib3/util/ssl_.py)'].我需要有补丁猴子,因为当我移除它时,其他一切都工作得很好,但从外部线程发出的套接字正在堆叠和缓冲,并在很长一段时间后到达JavaScript处理程序。
我的模块版本:
Flask==1.1.2
Flask-SocketIO==5.0.1
python-engineio==4.0.0
python-socketio==5.04
gevent==20.12.1
gevent-websocket==0.10.1谁都知道,我该如何解决这个问题?
谢谢。
发布于 2021-01-30 21:34:22
问题是我在RPi上运行的是32位而不是64位的Python3。
https://stackoverflow.com/questions/65469353
复制相似问题