3 ms·
You need to run the executor somewhere ( loop.run_forever() or loop.run_until_complete() ), that can be in the current thread or a separate thread, keep in mind
by m3047 4y ago
You need to run the executor somewhere ( loop.run_forever() or loop.run_until_complete() ), that can be in the current thread or a separate thread, keep in mind Python is still conceptually a single core.
Things I've found particularly useful:
* Optional / debug logging of coroutine start/exit.
* Stats logging, including count, runtime, request queue (multiple instances of the same function) depth.
* Printing tracebacks within the coroutine context.
Haven't expended any effort on decorators, good for you.
- xwowsersx 4y agoThose do sound useful, thanks for this. Will keep in mind as I continue exploring.
- m3047 4y agoI think I hit a foul ball there, as run_in_executor() is for a threadpool. So yeah you are running inside of run_forever() or run_until_complete(), we just don't see it here, and that's where your sending things to run in a different thread. ;-)
- xwowsersx 4y agoAh got it, thanks for the correction and info.