Skip to content

Commit

Permalink
Account for the stopped callbacks in the leakcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jul 8, 2015
1 parent 44ce117 commit 5af72d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gevent/greenlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ def __cancel_start(self):
# prevent self from ever being started in the future
self._start_event = _cancelled_start_event
# cancel any pending start event
# NOTE: If this was a real pending start event, this will leave a
# "dangling" callback/timer object in the hub.loop.callbacks list;
# depending on where we are in the event loop, it may even be in a local
# variable copy of that list (in _run_callbacks). This isn't a problem,
# except for the leak-tests.
self._start_event.stop()

def __handle_death_before_start(self, *args):
Expand Down
7 changes: 7 additions & 0 deletions greentest/greentest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import os
from os.path import basename, splitext
import gevent
import gevent.core
from patched_tests_setup import get_switch_expected
from gevent.hub import _get_hub
from functools import wraps
Expand Down Expand Up @@ -106,6 +107,12 @@ def type_hist():
k = type(x)
if k in IGNORED_TYPES:
continue
if k == gevent.core.callback and x.callback is None and x.args is None:
# these represent callbacks that have been stopped, but
# the event loop hasn't cycled around to run them. The only
# known cause of this is killing greenlets before they get a chance
# to run for the first time.
continue
d[k] += 1
return d

Expand Down

0 comments on commit 5af72d4

Please sign in to comment.