Skip to content

Commit 03ed5c1

Browse files
committed
Make _asyncio_awaited_by a frozenset in the Python version as well per Kumar's wishes
1 parent 7799391 commit 03ed5c1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Lib/asyncio/futures.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Future:
6868
_asyncio_future_blocking = False
6969

7070
# Used by the capture_call_stack() API.
71-
_asyncio_awaited_by = None
71+
__asyncio_awaited_by = None
7272

7373
__log_traceback = False
7474

@@ -119,6 +119,12 @@ def _log_traceback(self, val):
119119
raise ValueError('_log_traceback can only be set to False')
120120
self.__log_traceback = False
121121

122+
@property
123+
def _asyncio_awaited_by(self):
124+
if self.__asyncio_awaited_by is None:
125+
return None
126+
return frozenset(self.__asyncio_awaited_by)
127+
122128
def get_loop(self):
123129
"""Return the event loop the Future is bound to."""
124130
loop = self._loop
@@ -442,9 +448,9 @@ def future_add_to_awaited_by(fut, waiter, /):
442448
# Note that there's an accelerated version of this function
443449
# shadowing this implementation later in this file.
444450
if isinstance(fut, _PyFuture) and isinstance(waiter, _PyFuture):
445-
if fut._asyncio_awaited_by is None:
446-
fut._asyncio_awaited_by = set()
447-
fut._asyncio_awaited_by.add(waiter)
451+
if fut._Future__asyncio_awaited_by is None:
452+
fut._Future__asyncio_awaited_by = set()
453+
fut._Future__asyncio_awaited_by.add(waiter)
448454

449455

450456
def future_discard_from_awaited_by(fut, waiter, /):
@@ -455,8 +461,8 @@ def future_discard_from_awaited_by(fut, waiter, /):
455461
# Note that there's an accelerated version of this function
456462
# shadowing this implementation later in this file.
457463
if isinstance(fut, _PyFuture) and isinstance(waiter, _PyFuture):
458-
if fut._asyncio_awaited_by is not None:
459-
fut._asyncio_awaited_by.discard(waiter)
464+
if fut._Future__asyncio_awaited_by is not None:
465+
fut._Future__asyncio_awaited_by.discard(waiter)
460466

461467

462468
try:

0 commit comments

Comments
 (0)