Did anyone help get Cython to work with Asyncio coroutine? I have a very trivial example that works well in Python and refuses to work in Cython: this is the next separate file that I compile with Cython and execute. The execution starts correctly, but the coroutine does not start. Cython seems to change the type of "sometask" coroutine, which is then not handled by Asyncio and Inspect as usual.
#!/usr/bin/env python import asyncio @asyncio.coroutine def sometask(): counter = 0 while True: print(counter) yield from asyncio.sleep(1) counter += 1 def runloop(): loop = asyncio.get_event_loop() asyncio.async(sometask()) try: print('Start loop') loop.run_forever() except KeyboardInterrupt: print('Aborted by user') loop.close()
UPDATE: I am currently doing this βworkβ by modifying in an ugly way the asyncio / tasks.py file in those places where it checks to see if the object is a generator, but in fact Cython made it an inline function. This Cython object will still do the work of asyncio coroutine, although it has a different type than expected.
Morib source share