@remaster that might work! I may try to write something quick using fibers, first, but that library may come in handy.
It's just odd that there's no "check for input, return even if there isn't any" function.
@woozle Full disclosure: I have never used it! Only seen it mentioned and came to think of it when I saw your toot. Hope it helps. Seems like an interesting tool.
@woozle Something like this? https://reactphp.org/