Skip to content

Instantly share code, notes, and snippets.

@upgradeQ
Created December 11, 2017 07:24
Show Gist options
  • Save upgradeQ/784e3ebee6f0a1e0648b38c7f60f9ff1 to your computer and use it in GitHub Desktop.
Save upgradeQ/784e3ebee6f0a1e0648b38c7f60f9ff1 to your computer and use it in GitHub Desktop.
import aiofiles
import asyncio
async def red():
print('where did lost ')
async with aiofiles.open('data.txt', mode='r') as f:
contents = await f.read()
return contents
events = asyncio.get_event_loop()
try:
coro = events.run_until_complete(red())
print('files content is: "{}"'.format(coro))
finally:
print('end')
events.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment