"""Tests for futures.py."""
import concurrent.futures
+import gc
import re
import sys
import threading
def _fakefunc(f):
return f
+
def first_cb():
pass
+
def last_cb():
pass
Exception("elephant"), Exception("elephant"))
self.assertRaises(TypeError, fi.throw, list)
+ def test_future_del_collect(self):
+ class Evil:
+ def __del__(self):
+ gc.collect()
+
+ for i in range(100):
+ fut = self._new_future(loop=self.loop)
+ fut.set_result(Evil())
+
@unittest.skipUnless(hasattr(futures, '_CFuture'),
'requires the C _asyncio module')
import collections
import contextlib
import functools
+import gc
import io
import os
import re
self.loop.set_task_factory(self.new_task)
self.loop.create_future = lambda: self.new_future(self.loop)
+ def test_task_del_collect(self):
+ class Evil:
+ def __del__(self):
+ gc.collect()
+
+ @asyncio.coroutine
+ def run():
+ return Evil()
+
+ self.loop.run_until_complete(
+ asyncio.gather(*[
+ self.new_task(self.loop, run()) for _ in range(100)
+ ], loop=self.loop))
+
def test_other_loop_future(self):
other_loop = asyncio.new_event_loop()
fut = self.new_future(other_loop)
--- /dev/null
+Fixed a crash when using asyncio and threads.
}
}
+ PyObject_GC_UnTrack(self);
+
if (fut->fut_weakreflist != NULL) {
PyObject_ClearWeakRefs(self);
}
}
}
+ PyObject_GC_UnTrack(self);
+
if (task->task_weakreflist != NULL) {
PyObject_ClearWeakRefs(self);
}