aiomcachedoesn’t have the “quit” command, and I’m not sure I can duct-tape one in there, I decided to spawn a PHP process (as we’re primarily a PHP shop) to connect-and-quit, exiting 0 on success.
This immediately crashed with an error:
RuntimeError: Cannot add child handler, the child watcher does not have a loop attached
The reason was, the loop didn’t have a child watcher. Only the subprocess API really cares; everything else just doesn’t run subprocesses, and therefore doesn’t interact with the child watcher, broken or otherwise.
Anyway, the correct way to do things is:
def create_loop(): asyncio.set_event_loop(None) loop = asyncio.new_event_loop() asyncio.get_child_watcher().attach_loop(loop) return loop
asynciorequires exactly one active/global child watcher, so we don’t jump through any hoops to create a new one. It wouldn’t meaningfully isolate our tests from the rest of the system.
(Incidentally, the PHP memcached client doesn’t connect to any servers until it must, so the PHP script is really setup +
getVersion()to ask for server data, the connection was never made.)