mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +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
|
@ -4,6 +4,7 @@ import gc
|
|||
import os.path
|
||||
import types
|
||||
import unittest
|
||||
import weakref
|
||||
from test.script_helper import assert_python_ok
|
||||
|
||||
import asyncio
|
||||
|
@ -1475,6 +1476,13 @@ class TaskTests(unittest.TestCase):
|
|||
self.assertEqual(call((1, 2)), (1, 2))
|
||||
self.assertEqual(call('spam'), 'spam')
|
||||
|
||||
def test_corowrapper_weakref(self):
|
||||
wd = weakref.WeakValueDictionary()
|
||||
def foo(): yield from []
|
||||
cw = asyncio.tasks.CoroWrapper(foo(), foo)
|
||||
wd['cw'] = cw # Would fail without __weakref__ slot.
|
||||
cw.gen = None # Suppress warning from __del__.
|
||||
|
||||
|
||||
class GatherTestsBase:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue