Let's say i'm not interested to relay on 3rd party modules.
Is it possible to wrap a standard python module into a coroutine in order to use with asyncio
?
For example:
- wrapping
open()
into a coroutine to read/write files - Wrapping
urllib
into coroutines to make non blocking requests
something like this:
@asyncio.coroutine
def async_open(filename: str, mode: str) -> str:
with open(filename, mode) as fopen:
for block in fopen:
yield block