asyncio: Add __weakref__ slots to Handle and CoroWrapper. Upstream issue #166.

This commit is contained in:
Guido van Rossum 2014-04-27 10:44:22 -07:00
parent 83c1ddda46
commit 94ba146d11
4 changed files with 16 additions and 2 deletions

View file

@ -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: