Commit 5af72d4d authored by Jason Madden's avatar Jason Madden

Account for the stopped callbacks in the leakcheck.

parent 44ce117c
......@@ -189,6 +189,11 @@ class Greenlet(greenlet):
# 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):
......
......@@ -28,6 +28,7 @@ import time
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
......@@ -106,6 +107,12 @@ def wrap_refcount(method):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment