summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2018-02-13 10:28:33 (GMT)
committerINADA Naoki <methane@users.noreply.github.com>2018-02-13 10:28:33 (GMT)
commitd019bc8319ea35e93bf4baa38098ff1b57cd3ee5 (patch)
treed9b927eba02059f8be8465d35b6969254b172b8e /Lib/test/test_asyncio/test_tasks.py
parentaec7532ed3ccbd29d3429a3f375e25f956c44003 (diff)
downloadcpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.zip
cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.gz
cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.bz2
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 19cf1e6..e5334c6 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2373,6 +2373,20 @@ class CTask_CFuture_Tests(BaseTaskTests, SetMethodsTest,
Task = getattr(tasks, '_CTask', None)
Future = getattr(futures, '_CFuture', None)
+ @support.refcount_test
+ def test_refleaks_in_task___init__(self):
+ gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
+ @asyncio.coroutine
+ def coro():
+ pass
+ task = self.new_task(self.loop, coro())
+ self.loop.run_until_complete(task)
+ refs_before = gettotalrefcount()
+ for i in range(100):
+ task.__init__(coro(), loop=self.loop)
+ self.loop.run_until_complete(task)
+ self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
+
@unittest.skipUnless(hasattr(futures, '_CFuture') and
hasattr(tasks, '_CTask'),