mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
asyncio: Add __weakref__ slots to Handle and CoroWrapper. Upstream issue #166.
This commit is contained in:
parent
83c1ddda46
commit
94ba146d11
4 changed files with 16 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ import socket
|
|||
class Handle:
|
||||
"""Object returned by callback registration methods."""
|
||||
|
||||
__slots__ = ['_callback', '_args', '_cancelled', '_loop']
|
||||
__slots__ = ['_callback', '_args', '_cancelled', '_loop', '__weakref__']
|
||||
|
||||
def __init__(self, callback, args, loop):
|
||||
assert not isinstance(callback, Handle), 'A Handle is not a callback'
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ _DEBUG = (not sys.flags.ignore_environment
|
|||
class CoroWrapper:
|
||||
# Wrapper for coroutine in _DEBUG mode.
|
||||
|
||||
__slots__ = ['gen', 'func', '__name__', '__doc__']
|
||||
__slots__ = ['gen', 'func', '__name__', '__doc__', '__weakref__']
|
||||
|
||||
def __init__(self, gen, func):
|
||||
assert inspect.isgenerator(gen), gen
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue