Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gevent 20.12.0 give error: OverflowError: Python int too large to convert to C long #1733

Closed
theyosh opened this issue Dec 27, 2020 · 6 comments

Comments

@theyosh
Copy link

theyosh commented Dec 27, 2020

  • gevent version: pypi version 20.12.0
  • Python version: Python 3.7.3 installed via deb packages.
  • Operating System: Raspberry Pi OS (latest version) Linux 5.4.79-v7l+ Build and test with PyPy 7.1 #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux
  • Device: Raspberry PI version 4

Description:

Upgrading from gevent 20.9.0 to 20.12.0 with pip install -U command will break my python software. It will give the following error when we monkey patch python. This is on a Raspberry PI 4:

OverflowError: Python int too large to convert to C long

Traceback (most recent call last):
  File "terrariumPI.py", line 5, in <module>
    monkey.patch_all()
  File "/home/pi/TerrariumPI/venv/lib/python3.7/site-packages/gevent/monkey.py", line 1222, in patch_all
    patch_thread(Event=Event, _warnings=_warnings)
  File "/home/pi/TerrariumPI/venv/lib/python3.7/site-packages/gevent/monkey.py", line 195, in ignores
    return func(*args, **kwargs)
  File "/home/pi/TerrariumPI/venv/lib/python3.7/site-packages/gevent/monkey.py", line 756, in patch_thread
    _notify_did_subscribers=False)
  File "/home/pi/TerrariumPI/venv/lib/python3.7/site-packages/gevent/monkey.py", line 443, in _patch_module
    gevent_module, target_module, target_module_name = _check_availability(name)
  File "/home/pi/TerrariumPI/venv/lib/python3.7/site-packages/gevent/monkey.py", line 429, in _check_availability
    gevent_module = getattr(__import__('gevent.' + name), name)
  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/TerrariumPI/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

On a Raspberry Pi 3 there is no overflow error, but the camera is not working. When I try to grab an frame(image) from the Raspberry PI camera, it times out with a general message that the camera was not able to. Sorry no error message from it.

What I've run:

In just a python console:

from gevent import monkey
monkey.patch_all()

I would just expect that an upgrade will not break my code. Also, when just running monkey.patch_all() it will break already. Should not be happening.

@theyosh
Copy link
Author

theyosh commented Dec 27, 2020

Is this related to 32bit vs 64bit OS?

@jamadden
Copy link
Member

jamadden commented Dec 27, 2020

This is due to thread.get_ident() returning a long in Python 2, and an unsigned long in Python 3. The gevent code currently uses a long; I haven't encountered a Python 3 system that actually returned a thread identifier greater than 2**63 (or 2**31, depending). But apparently your system does. I'll have to figure out how to conditionally change the type in gevent's Cython code.

@theyosh
Copy link
Author

theyosh commented Dec 27, 2020

Is there something I can do/test to get more info?

@jamadden
Copy link
Member

Thank you, no. The problem is clear.

jamadden added a commit that referenced this issue Dec 27, 2020
@jamadden
Copy link
Member

Fix released in 20.12.1.

@theyosh
Copy link
Author

theyosh commented Dec 27, 2020

Nice, that was fast. It is working. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants