gevent monkey.patch_all(thread=False) raises a TypeError
when using flask on python 3.10,
from gevent import monkey
monkey.patch_all(thread=False) # use native C-sockets, pycurl is not patchable
I see the following:
2025-07-01T16:13:51Z <io at 0x7f0c3883e6c0 native=0x7f0c3883e700 fd=13 events=READ active callback=<bound method PollResult.add_event of <gevent.select.PollResult object at 0x7f0c38711d50>> args=(gevent.core.EVENTS, 13)> failed with TypeError
Traceback (most recent call last):
File "/usr/local/venv/lib/python3.10/site-packages/gevent/select.py", line 217, in add_event
if events < 0:
TypeError: '<' not supported between instances of 'tuple' and 'int'
which looks like a problem here https://github.com/gevent/gevent/blob/73025a8837b3bff19c106e877fa2374889c59dd3/src/gevent/select.py#L216-L217 given that events seems to be a tuple, but not sure why. It looks like the callback here isn't correct: https://github.com/gevent/gevent/blob/master/benchmarks/bench_hub.py#L42-L45 and should be maybe cb(*obj)?
There's not enough information here to suggest what the problem is or what a fix would be. Can you supply a short, self-contained example that reproduces the issue?
Unless you were specifically running it, the benchmark code in bench_hub is completely unrelated.
The only expected caller of add_event is gevent_callback in callbacks.c. It will be called with the arguments specified (args=(gevent.core.EVENTS, 13)), where gevent.core.EVENTS is actually a stand-in for the real integer event number we get from the loop, so the actual call will be add_event(*args), e.g., add_event(*(1, 13)).