Discussion forum for David Beazley

KqueueSelector doesn't sleep when no files are passed


Hi, I’m working on a test system which will either be based on curio or at least inspired by it.

Under OSX I’ve noticed that when KqueueSelector isn’t given any files it returns immediately. The result is that code such as this:

from curio import run, sleep

async def just_sleep():
    await sleep(20)


uses 100% CPU whilst it’s running. Passing selector=SelectSelector() to run() ‘fixes’ this.

I think I’d argue that this is a bug, possibly in selectors, but I’m not sure. I’d be very interested to hear opinions on this.


Interesting. I agree that this sounds like a bug in selectors.
SelectSelector on Windows has a similar problem. See:

My suspicion is that what’s going on here is that ‘selectors’ was written
for asyncio and hasn’t really been tested otherwise, and it turns out that
asyncio always has at least one file descriptor that it selects on, so no
one ever noticed all these bugs in the zero-file-descriptor cases :frowning:


Interesting. I will need to check into this.