Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
gevent.select.poll handles negative timeouts wrong, especially on libuv #1127
if timeout is not None and timeout > -1: timeout /= 1000.0 result.event.wait(timeout=timeout)
When called with -1, that has the effect of passing -1 and so forth on down through Event -> Timeout -> loop.timer().
On libuv, timeout values < 0 cause a check watcher to be used, which wakes up on the next iteration of the loop.
On libev it's not (immediately) clear what a negative value does. At the very least, it's going to allocate an extra C-level watcher object.
The stdlib documentation for select.poll.poll since at least 3.5 says:
So we're definitely wrong on libuv. We're possibly also wrong on libev, depending on its implementation. At the very least, we're creating C objects we don't need.
A negative timeout should be handled the same as None.
(Discovered while tracing through #1126 )