Python asyncio.run boilerplate

Concurrency is builtin to Python via asyncio. AsyncIO generators are implemented with yield much like synchronous generators. async for also simplifies expression of asynchronous for loops.

As in Julia, the expression of asynchronous structures in Python does not implement concurrent execution. Concurrent execution in Python is governed by collections of tasks or futures such as asyncio.gather and initiated by a runner such as asyncio.run

asyncio.run() doesn’t handle all use cases. AsyncIO subprocess in particular needs specific asyncio loop configuration. The options needed are not the same for every project, depending on the asynchronous functions used.

asyncio.subprocess

The example date_coro.py uses runner.py. This supports AsyncIO subprocess.

asyncio.open_connection

For networking apps using asyncio.open_connection the ProactorEventLoop emits numerous warnings with trapped RuntimeError. A workaround is to not use the ProactorEventLoop in runner.py.