From d537b59e452daafe4a3d82a3307c03b9ba4a9f39 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 23 Sep 2015 17:44:41 -0700 Subject: [PATCH] Remove green worker reference to its executor There really is no need to give a green worker a reference to its creator and it hinders/makes it harder for python to garbage collect the executor and its workers. It is also not used, so let's make the python garbage collectors life easier by not even passing it in. Change-Id: I0f9d27663c3ca5ca908ef6f90f3d1d0f6b5f9104 --- futurist/_futures.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/futurist/_futures.py b/futurist/_futures.py index 5e16fb8..4d54dd1 100644 --- a/futurist/_futures.py +++ b/futurist/_futures.py @@ -348,8 +348,7 @@ class SynchronousExecutor(_futures.Executor): class _GreenWorker(object): - def __init__(self, executor, work, work_queue): - self.executor = executor + def __init__(self, work, work_queue): self.work = work self.work_queue = work_queue @@ -473,7 +472,7 @@ class GreenThreadPoolExecutor(_futures.Executor): """ alive = self._pool.running() + self._pool.waiting() if alive < self._max_workers: - self._pool.spawn_n(_GreenWorker(self, work, self._delayed_work)) + self._pool.spawn_n(_GreenWorker(work, self._delayed_work)) return True return False