Skip to content

Instantly share code, notes, and snippets.

@1st1
Last active April 25, 2019 03:47
Show Gist options
  • Save 1st1/a1936d2f283c1e2f1848c4ed42634ebf to your computer and use it in GitHub Desktop.
Save 1st1/a1936d2f283c1e2f1848c4ed42634ebf to your computer and use it in GitHub Desktop.
# in asyncio:
class asyncio.AbstractFileIOImplementation:
async def open(self):
raise NotImplementedError
async def open(...):
return await get_current_loop(). get_file_io_implementation().open(...)
# in uvloop or twisted or ...:
class uvloop.FileIO(asyncio.AbstractFileIOImplementation):
# ... implementation of "open()"
class uvloop.Loop(uvloop.FileIO):
def get_file_io_implementation(self):
return self
# later in user code:
async def main():
file = await asyncio.open(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment