Gevent 猴子修补 - OverflowError
Gevent monkey patching - OverflowError
我尝试 运行 我的 Flask 项目在 Python3.7 上 Raspberry Pi 上使用 gevent,在第一行上使用 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
谁知道,我该如何解决这个问题?
谢谢。
问题是我在 RPi 上 运行 32 位而不是 64 位 Python3。
我尝试 运行 我的 Flask 项目在 Python3.7 上 Raspberry Pi 上使用 gevent,在第一行上使用 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
谁知道,我该如何解决这个问题?
谢谢。
问题是我在 RPi 上 运行 32 位而不是 64 位 Python3。