This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import functools | |
| handles = set() | |
| def call_later(delay, cb, *args, loop=None): | |
| if loop is None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| There was an error in the Elpy backend. | |
| The following lines were received from Python, and might help identifying | |
| the problem. | |
| Traceback (most recent call last): | |
| File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main | |
| "__main__", mod_spec) | |
| File "/usr/lib/python3.4/runpy.py", line 85, in _run_code | |
| exec(code, run_globals) | |
| File "/home/andrew/.local/lib/python3.4/site-packages/elpy/__main__.py", line 15, in <module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [1]: import dis | |
| In [2]: for i in range(10): | |
| ...: print(i) | |
| ...: | |
| 0 | |
| 1 | |
| 2 | |
| 3 | |
| 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from inspect import getattr_static | |
| class dep: | |
| name = None | |
| def __init__(self, type): | |
| self.type = type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| class CM: | |
| async def __aenter__(self): | |
| print(1) | |
| await asyncio.sleep(0.01) | |
| print(2) | |
| return self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| END = b'Bye-bye!\n' | |
| async def echo_client(): | |
| reader, writer = await asyncio.open_connection('localhost', 8000) | |
| writer.write(b'Hello, world\n') | |
| writer.write(b'What a fine day it is.\n') | |
| writer.write(END) | |
| while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(): | |
| future = asyncio.Future() | |
| future.set_result(5) | |
| return future # yield from f() returns 5. | |
| def g(): | |
| future = asyncio.Future() | |
| asyncio.get_event_loop.call_later(1, future.set_result, 5) | |
| return future # yield from g() also returns 5 but 1 second later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import aiohttp | |
| import asyncio | |
| class MyClass: | |
| def __init__(self): | |
| self.data = {'username': 'me', 'password': 'pw'} | |
| self.login_url = 'http://example.com/login' | |
| self.client = aiohttp.ClientSession() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import warnings | |
| class Timeout: | |
| def __init__(self, timeout, *, raise_error=False, loop=None): | |
| self._timeout = timeout | |
| if loop is None: | |
| loop = asyncio.get_event_loop() | |
| self._loop = loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| from aiohttp import CIMultiDict | |
| import tracemalloc | |
| def leaking(headers): | |
| headers = ''.join(itertools.chain( | |
| ('status line',), | |
| *((k, ': ', v, '\r\n') for k, v in headers.items()))) |