Generated by Cython 3.0.0a9
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: _abstract_linkable.c
+001: # -*- coding: utf-8 -*-
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
002: # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
003: """
004: Internal module, support for the linkable protocol for "event" like objects.
005:
006: """
007: from __future__ import absolute_import
008: from __future__ import division
009: from __future__ import print_function
010:
+011: import sys
__pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+012: from gc import get_objects
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_objects); __Pyx_GIVEREF(__pyx_n_s_get_objects); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_objects); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gc, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_objects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_get_objects); __Pyx_DECREF_SET(__pyx_v_6gevent_27_gevent_c_abstract_linkable_get_objects, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
013:
+014: from greenlet import greenlet
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_greenlet); __Pyx_GIVEREF(__pyx_n_s_greenlet); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_greenlet); __pyx_t_1 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+015: from greenlet import error as greenlet_error
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_error); __Pyx_GIVEREF(__pyx_n_s_error); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_greenlet_error, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
016:
+017: from gevent._compat import thread_mod_name
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_thread_mod_name); __Pyx_GIVEREF(__pyx_n_s_thread_mod_name); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_thread_mod_name); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_thread_mod_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_thread_mod_name, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+018: from gevent._hub_local import get_hub_noargs as get_hub
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_hub_noargs); __Pyx_GIVEREF(__pyx_n_s_get_hub_noargs); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_hub_noargs); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_hub_noargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_noargs, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+019: from gevent._hub_local import get_hub_if_exists
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_get_hub_if_exists); __Pyx_GIVEREF(__pyx_n_s_get_hub_if_exists); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_hub_if_exists); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__hub_local, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_hub_if_exists); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub_if_exists, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
020:
+021: from gevent.exceptions import InvalidSwitchError
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_InvalidSwitchError); __Pyx_GIVEREF(__pyx_n_s_InvalidSwitchError); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_InvalidSwitchError); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_InvalidSwitchError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidSwitchError); __Pyx_DECREF_SET(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidSwitchError, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+022: from gevent.exceptions import InvalidThreadUseError
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_InvalidThreadUseError); __Pyx_GIVEREF(__pyx_n_s_InvalidThreadUseError); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_InvalidThreadUseError); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_exceptions, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_InvalidThreadUseError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidThreadUseError); __Pyx_DECREF_SET(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidThreadUseError, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+023: from gevent.timeout import Timeout
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Timeout); __Pyx_GIVEREF(__pyx_n_s_Timeout); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Timeout); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout); __Pyx_DECREF_SET(__pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
024:
+025: locals()['getcurrent'] = __import__('greenlet').getcurrent
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely((PyDict_SetItem(__pyx_t_2, __pyx_n_s_getcurrent, __pyx_t_1) < 0))) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_greenlet); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5);
+026: locals()['greenlet_init'] = lambda: None
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_lambda = {"lambda", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_lambda, METH_NOARGS, 0}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_lambda(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda (wrapper)", 0); __pyx_r = __pyx_lambda_funcdef_6gevent_27_gevent_c_abstract_linkable_lambda(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_lambda_funcdef_6gevent_27_gevent_c_abstract_linkable_lambda(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda", 0); __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely((PyDict_SetItem(__pyx_t_2, __pyx_n_s_greenlet_init, __pyx_t_1) < 0))) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
027:
+028: __all__ = [
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_AbstractLinkable); __Pyx_GIVEREF(__pyx_n_s_AbstractLinkable); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_AbstractLinkable); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
029: 'AbstractLinkable',
030: ]
031:
032: # Need the real get_ident. We're imported early enough during monkey-patching
033: # that we can be sure nothing is monkey patched yet.
+034: _get_thread_ident = __import__(thread_mod_name).get_ident
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_thread_mod_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin___import__, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_ident); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident); __Pyx_DECREF_SET(__pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+035: _allocate_thread_lock = __import__(thread_mod_name).allocate_lock
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_thread_mod_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin___import__, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_allocate_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_allocate_thread_lock, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
036:
037: class _FakeNotifier(object):
038: __slots__ = (
+039: 'pending',
if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable__FakeNotifier->tp_dict, __pyx_n_s_slots, __pyx_tuple__6) < 0) __PYX_ERR(0, 38, __pyx_L1_error) PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable__FakeNotifier); /* … */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_pending); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6);
040: )
041:
+042: def __init__(self):
/* Python wrapper */ static int __pyx_pw_6gevent_27_gevent_c_abstract_linkable_13_FakeNotifier_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_27_gevent_c_abstract_linkable_13_FakeNotifier_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, __pyx_nargs); return -1;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_VARARGS(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_13_FakeNotifier___init__(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable__FakeNotifier *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_27_gevent_c_abstract_linkable_13_FakeNotifier___init__(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable__FakeNotifier *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+043: self.pending = False
__pyx_v_self->pending = 0;
044:
+045: def get_roots_and_hubs():
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_get_roots_and_hubs(void) { PyObject *__pyx_v_Hub = NULL; PyObject *__pyx_7genexpr__pyx_v_x = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_roots_and_hubs", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.get_roots_and_hubs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_Hub); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_x); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+046: from gevent.hub import Hub # delay import
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Hub); __Pyx_GIVEREF(__pyx_n_s_Hub); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Hub); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_hub, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v_Hub = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+047: return {
__Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2);
+048: x.parent: x
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_7genexpr__pyx_v_x, __pyx_n_s_parent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_t_1, (PyObject*)__pyx_7genexpr__pyx_v_x))) __PYX_ERR(0, 48, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+049: for x in get_objects()
__Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_get_objects); __pyx_t_3 = __pyx_v_6gevent_27_gevent_c_abstract_linkable_get_objects; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_4, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L5_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 49, __pyx_L5_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 49, __pyx_L5_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 49, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_x); __pyx_7genexpr__pyx_v_x = 0; goto __pyx_L11_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_x); __pyx_7genexpr__pyx_v_x = 0; goto __pyx_L1_error; __pyx_L11_exit_scope:; } /* exit inner scope */ __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0;
050: # Make sure to only find hubs that have a loop
051: # and aren't destroyed. If we don't do that, we can
052: # get an old hub that no longer works leading to issues in
053: # combined test cases.
+054: if isinstance(x, Hub) and x.loop is not None
__pyx_t_9 = PyObject_IsInstance(__pyx_7genexpr__pyx_v_x, __pyx_v_Hub); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 54, __pyx_L5_error) __pyx_t_10 = (__pyx_t_9 != 0); if (__pyx_t_10) { } else { __pyx_t_8 = __pyx_t_10; goto __pyx_L9_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_7genexpr__pyx_v_x, __pyx_n_s_loop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = (__pyx_t_10 != 0); __pyx_t_8 = __pyx_t_9; __pyx_L9_bool_binop_done:; if (__pyx_t_8) { /* … */ }
055: }
056:
057:
+058: class AbstractLinkable(object):
struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable { PyObject *(*linkcount)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int __pyx_skip_dispatch); PyObject *(*rawlink)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *, int __pyx_skip_dispatch); int (*ready)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int __pyx_skip_dispatch); PyObject *(*unlink)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *, int __pyx_skip_dispatch); PyObject *(*_check_and_notify)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *); struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *(*_capture_hub)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int); PyObject *(*_AbstractLinkable__wait_to_be_notified)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int); void (*_quiet_unlink_all)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *); int (*_switch_to_hub)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *); PyObject *(*_notify_link_list)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *); PyObject *(*_notify_links)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *, int __pyx_skip_dispatch); PyObject *(*_handle_unswitched_notifications)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *); PyObject *(*_AbstractLinkable__print_unswitched_warning)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *, int); PyObject *(*_drop_lock_for_switch_out)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int __pyx_skip_dispatch); PyObject *(*_acquire_lock_for_switch_in)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int __pyx_skip_dispatch); PyObject *(*_wait_core)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, PyObject *, struct __pyx_opt_args_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait_core *__pyx_optional_args); PyObject *(*_wait_return_value)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, int, int); PyObject *(*_wait)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *, struct __pyx_opt_args_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait *__pyx_optional_args); PyObject *(*_allocate_lock)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *); PyGreenlet *(*_getcurrent)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *); PyObject *(*_get_thread_ident)(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *); }; static struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_vtabptr_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable;
059: # Encapsulates the standard parts of the linking and notifying
060: # protocol common to both repeatable events (Event, Semaphore) and
061: # one-time events (AsyncResult).
062: #
063: # With a few careful exceptions, instances of this object can only
064: # be used from a single thread. The exception is that certain methods
065: # may be used from multiple threads IFF:
066: #
067: # 1. They are documented as safe for that purpose; AND
068: # 2a. This object is compiled with Cython and thus is holding the GIL
069: # for the entire duration of the method; OR
070: # 2b. A subclass ensures that a Python-level native thread lock is held
071: # for the duration of the method; this is necessary in pure-Python mode.
072: # The only known implementation of such
073: # a subclass is for Semaphore. AND
074: # 3. The subclass that calls ``capture_hub`` catches
075: # and handles ``InvalidThreadUseError``
076: #
077: # TODO: As of gevent 1.5, we use the same datastructures and almost
078: # the same algorithm as Greenlet. See about unifying them more.
079:
080: __slots__ = (
+081: 'hub',
if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_slots, __pyx_tuple__7) < 0) __PYX_ERR(0, 80, __pyx_L1_error) PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); /* … */ __pyx_tuple__7 = PyTuple_Pack(5, __pyx_n_s_hub, __pyx_n_s_links, __pyx_n_s_notifier, __pyx_n_s_notify_all, __pyx_n_s_weakref); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7);
082: '_links',
083: '_notifier',
084: '_notify_all',
085: '__weakref__'
086: )
087:
+088: def __init__(self, hub=None):
/* Python wrapper */ static int __pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_hub = 0; CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,0}; #endif PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_None); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub); if (value) { values[0] = value; kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 88, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_hub = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 88, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable___init__(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self), __pyx_v_hub); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable___init__(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_hub) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
089: # Before this implementation, AsyncResult and Semaphore
090: # maintained the order of notifications, but Event did not.
091:
092: # In gevent 1.3, before Semaphore extended this class, that
093: # was changed to not maintain the order. It was done because
094: # Event guaranteed to only call callbacks once (a set) but
095: # AsyncResult had no such guarantees. When Semaphore was
096: # changed to extend this class, it lost its ordering
097: # guarantees. Unfortunately, that made it unfair. There are
098: # rare cases that this can starve a greenlet
099: # (https://github.com/gevent/gevent/issues/1487) and maybe
100: # even lead to deadlock (not tested).
101:
102: # So in gevent 1.5 we go back to maintaining order. But it's
103: # still important not to make duplicate calls, and it's also
104: # important to avoid O(n^2) behaviour that can result from
105: # naive use of a simple list due to the need to handle removed
106: # links in the _notify_links loop. Cython has special support for
107: # built-in sets, lists, and dicts, but not ordereddict. Rather than
108: # use two data structures, or a dict({link: order}), we simply use a
109: # list and remove objects as we go, keeping track of them so as not to
110: # have duplicates called. This makes `unlink` O(n), but we can avoid
111: # calling it in the common case in _wait_core (even so, the number of
112: # waiters should usually be pretty small)
+113: self._links = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->_links); __Pyx_DECREF(__pyx_v_self->_links); __pyx_v_self->_links = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+114: self._notifier = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None;
115: # This is conceptually a class attribute, defined here for ease of access in
116: # cython. If it's true, when notifiers fire, all existing callbacks are called.
117: # If its false, we only call callbacks as long as ready() returns true.
+118: self._notify_all = True
__pyx_v_self->_notify_all = 1;
119: # we don't want to do get_hub() here to allow defining module-level objects
120: # without initializing the hub. However, for multiple-thread safety, as soon
121: # as a waiting method is entered, even if it won't have to wait, we
122: # need to grab the hub and assign ownership. But we don't want to grab one prematurely.
123: # The example is three threads, the main thread and two worker threads; if we create
124: # a Semaphore in the main thread but only use it in the two threads, if we had grabbed
125: # the main thread's hub, the two worker threads would have a dependency on it, meaning that
126: # if the main event loop is blocked, the worker threads might get blocked too.
+127: self.hub = hub
if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 127, __pyx_L1_error) __pyx_t_1 = __pyx_v_hub; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF((PyObject *)__pyx_v_self->hub); __Pyx_DECREF((PyObject *)__pyx_v_self->hub); __pyx_v_self->hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1); __pyx_t_1 = 0;
128:
+129: def linkcount(self):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_linkcount(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("linkcount", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_linkcount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_4, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.linkcount", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_2linkcount, "AbstractLinkable.linkcount(self)"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount = {"linkcount", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount, METH_NOARGS, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_2linkcount}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("linkcount (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_2linkcount(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_2linkcount(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("linkcount", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_linkcount(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.linkcount", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_3linkcount, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_linkcount, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_linkcount, __pyx_t_1) < 0) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_linkcount, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 129, __pyx_L1_error)
130: # For testing: how many objects are linked to this one?
+131: return len(self._links)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 131, __pyx_L1_error) } __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
132:
+133: def ready(self):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static int __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_ready(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ready", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready)) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_4, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_6; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_WriteUnraisable("gevent._gevent_c_abstract_linkable.AbstractLinkable.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_4ready, "AbstractLinkable.ready(self) -> bool"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready = {"ready", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready, METH_NOARGS, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_4ready}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ready (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_4ready(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_4ready(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ready", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.ready", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_5ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_ready, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_ready, __pyx_t_1) < 0) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_ready, 133, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 133, __pyx_L1_error)
134: # Instances must define this
+135: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(0, 135, __pyx_L1_error)
136:
+137: def rawlink(self, callback):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_rawlink(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rawlink", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_callback}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_6rawlink, "AbstractLinkable.rawlink(self, callback)\n\n Register a callback to call when this object is ready.\n\n *callback* will be called in the :class:`Hub\n <gevent.hub.Hub>`, so it must not use blocking gevent API.\n *callback* will be passed one argument: this instance.\n "); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink = {"rawlink", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink, METH_O, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_6rawlink}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rawlink (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_6rawlink(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_6rawlink(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rawlink", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_7rawlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_rawlink, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_rawlink, __pyx_t_1) < 0) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_rawlink, 137, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 137, __pyx_L1_error)
138: """
139: Register a callback to call when this object is ready.
140:
141: *callback* will be called in the :class:`Hub
142: <gevent.hub.Hub>`, so it must not use blocking gevent API.
143: *callback* will be passed one argument: this instance.
144: """
+145: if not callable(callback):
__pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 145, __pyx_L1_error) __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0); if (unlikely(__pyx_t_7)) { /* … */ }
+146: raise TypeError('Expected callable: %r' % (callback, ))
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_callback); __Pyx_GIVEREF(__pyx_v_callback); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 146, __pyx_L1_error)
+147: self._links.append(callback)
if (unlikely(__pyx_v_self->_links == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 147, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 147, __pyx_L1_error)
+148: self._check_and_notify()
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_check_and_notify(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
149:
+150: def unlink(self, callback):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_unlink(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unlink", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_callback}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_8unlink, "AbstractLinkable.unlink(self, callback)\nRemove the callback set by :meth:`rawlink`"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink = {"unlink", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink, METH_O, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_8unlink}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unlink (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_8unlink(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_8unlink(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_callback) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unlink", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_unlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_9unlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable_unlink, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_unlink, __pyx_t_1) < 0) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_unlink, 150, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 150, __pyx_L1_error)
151: """Remove the callback set by :meth:`rawlink`"""
+152: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L8_try_end:; }
+153: self._links.remove(callback)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_links, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_callback}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+154: except ValueError:
__pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_5) { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error; __pyx_L5_except_error:;
155: pass
156:
+157: if not self._links and self._notifier is not None and self._notifier.pending:
__pyx_t_10 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0); __pyx_t_11 = ((!__pyx_t_10) != 0); if (__pyx_t_11) { } else { __pyx_t_9 = __pyx_t_11; goto __pyx_L10_bool_binop_done; } __pyx_t_11 = (__pyx_v_self->_notifier != Py_None); __pyx_t_10 = (__pyx_t_11 != 0); if (__pyx_t_10) { } else { __pyx_t_9 = __pyx_t_10; goto __pyx_L10_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_notifier, __pyx_n_s_pending); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __pyx_t_10; __pyx_L10_bool_binop_done:; if (__pyx_t_9) { /* … */ }
158: # If we currently have one queued, but not running, de-queue it.
159: # This will break a reference cycle.
160: # (self._notifier -> self._notify_links -> self)
161: # If it's actually running, though, (and we're here as a result of callbacks)
162: # we don't want to change it; it needs to finish what its doing
163: # so we don't attempt to start a fresh one or swap it out from underneath the
164: # _notify_links method.
+165: self._notifier.stop()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_notifier, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_3, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
166:
+167: def _allocate_lock(self):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__allocate_lock(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_allocate_lock", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._allocate_lock", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+168: return _allocate_thread_lock()
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_allocate_thread_lock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_3, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
169:
+170: def _getcurrent(self):
static PyGreenlet *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__getcurrent(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyGreenlet *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_getcurrent", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._getcurrent", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+171: return getcurrent() # pylint:disable=undefined-variable
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_27_gevent_c_abstract_linkable_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyGreenlet *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
172:
+173: def _get_thread_ident(self):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__get_thread_ident(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_get_thread_ident", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._get_thread_ident", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+174: return _get_thread_ident()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident); __pyx_t_2 = __pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident; __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_3, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
175:
+176: def _capture_hub(self, create):
static struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__capture_hub(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_v_create) { struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_my_hub = NULL; struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_current_hub = NULL; struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_capture_hub", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._capture_hub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_my_hub); __Pyx_XDECREF((PyObject *)__pyx_v_current_hub); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
177: # Subclasses should call this as the first action from any
178: # public method that could, in theory, block and switch
179: # to the hub. This may release the GIL. It may
180: # raise InvalidThreadUseError if the result would
181:
182: # First, detect a dead hub and drop it.
+183: while 1:
while (1) {
+184: my_hub = self.hub
__pyx_t_1 = ((PyObject *)__pyx_v_self->hub); __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_my_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1)); __pyx_t_1 = 0;
+185: if my_hub is None:
__pyx_t_2 = (((PyObject *)__pyx_v_my_hub) == Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* … */ }
+186: break
goto __pyx_L4_break;
+187: if my_hub.dead: # dead is a property, could release GIL
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_my_hub), __pyx_n_s_dead); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L6; }
188: # back, holding GIL
+189: if self.hub is my_hub:
__pyx_t_3 = (__pyx_v_self->hub == __pyx_v_my_hub); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* … */ }
+190: self.hub = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF((PyObject *)__pyx_v_self->hub); __Pyx_DECREF((PyObject *)__pyx_v_self->hub); __pyx_v_self->hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None);
+191: my_hub = None
__Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_my_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None));
+192: break
goto __pyx_L4_break;
193: else:
+194: break
/*else*/ { goto __pyx_L4_break; } __pyx_L6:; } __pyx_L4_break:;
195:
+196: if self.hub is None:
__pyx_t_2 = (((PyObject *)__pyx_v_self->hub) == Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* … */ }
197: # This next line might release the GIL.
+198: current_hub = get_hub() if create else get_hub_if_exists()
if ((__pyx_v_create != 0)) { __pyx_t_4 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_noargs(0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { __pyx_t_4 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_if_exists(0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_v_current_hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_1); __pyx_t_1 = 0;
199:
200: # We have the GIL again. Did anything change? If so,
201: # we lost the race.
+202: if self.hub is None:
__pyx_t_3 = (((PyObject *)__pyx_v_self->hub) == Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* … */ }
+203: self.hub = current_hub
__Pyx_INCREF((PyObject *)__pyx_v_current_hub); __Pyx_GIVEREF((PyObject *)__pyx_v_current_hub); __Pyx_GOTREF((PyObject *)__pyx_v_self->hub); __Pyx_DECREF((PyObject *)__pyx_v_self->hub); __pyx_v_self->hub = __pyx_v_current_hub;
204:
+205: if self.hub is not None and self.hub.thread_ident != _get_thread_ident():
__pyx_t_3 = (((PyObject *)__pyx_v_self->hub) != Py_None); __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L11_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hub), __pyx_n_s_thread_ident); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident); __pyx_t_6 = __pyx_v_6gevent_27_gevent_c_abstract_linkable__get_thread_ident; __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_7, }; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_5; __pyx_L11_bool_binop_done:; if (unlikely(__pyx_t_2)) { /* … */ }
206: raise InvalidThreadUseError(
207: self.hub,
+208: get_hub_if_exists(),
__pyx_t_4 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_if_exists(0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
+209: getcurrent() # pylint:disable=undefined-variable
__pyx_t_1 = ((PyObject *)__pyx_f_6gevent_27_gevent_c_abstract_linkable_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidThreadUseError); __pyx_t_7 = __pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidThreadUseError; __pyx_t_9 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } { PyObject *__pyx_callargs[4] = {__pyx_t_9, ((PyObject *)__pyx_v_self->hub), __pyx_t_4, __pyx_t_1}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 3+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 206, __pyx_L1_error)
210: )
+211: return self.hub
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_INCREF((PyObject *)__pyx_v_self->hub); __pyx_r = __pyx_v_self->hub; goto __pyx_L0;
212:
+213: def _check_and_notify(self):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__check_and_notify(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_check_and_notify", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._check_and_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_hub); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
214: # If this object is ready to be notified, begin the process.
+215: if self.ready() and self._links and not self._notifier:
__pyx_t_2 = (((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (__pyx_v_self->_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_links) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 215, __pyx_L1_error) __pyx_t_3 = ((!__pyx_t_2) != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+216: hub = None
__Pyx_INCREF(Py_None);
__pyx_v_hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None);
+217: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L12_try_end:; }
+218: hub = self._capture_hub(False) # Must create, we need it.
__pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_capture_hub(__pyx_v_self, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_7)); __pyx_t_7 = 0;
+219: except InvalidThreadUseError:
__pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidThreadUseError); if (__pyx_t_8) { __Pyx_ErrRestore(0,0,0); goto __pyx_L8_exception_handled; } goto __pyx_L9_except_error; __pyx_L9_except_error:;
220: # The current hub doesn't match self.hub. That's OK,
221: # we still want to start the notifier in the thread running
222: # self.hub (because the links probably contains greenlet.switch
223: # calls valid only in that hub)
224: pass
+225: if hub is not None:
__pyx_t_1 = (((PyObject *)__pyx_v_hub) != Py_None); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* … */ goto __pyx_L13; }
+226: self._notifier = hub.loop.run_callback(self._notify_links, [])
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_8 = 1; } } { PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_t_10, __pyx_t_11}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_8, 2+__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = __pyx_t_7; __pyx_t_7 = 0;
227: else:
228: # Hmm, no hub. We must be the only thing running. Then its OK
229: # to just directly call the callbacks.
+230: self._notifier = 1
/*else*/ { __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = __pyx_int_1;
+231: try:
/*try:*/ {
+232: self._notify_links([])
__pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 232, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_notify_links(__pyx_v_self, ((PyObject*)__pyx_t_7), 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 232, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
233: finally:
+234: self._notifier = None
/*finally:*/ { /*normal exit:*/{ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; goto __pyx_L16; } __pyx_L15_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_8 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestore(__pyx_t_6, __pyx_t_5, __pyx_t_4); __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L16:; } } __pyx_L13:;
235:
+236: def _notify_link_list(self, links):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__notify_link_list(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_links) { int __pyx_v_only_while_ready; PyObject *__pyx_v_final_link = NULL; PyObject *__pyx_v_done = NULL; struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = NULL; PyObject *__pyx_v_unswitched = NULL; PyObject *__pyx_v_link = NULL; PyObject *__pyx_v_id_link = NULL; PyObject *__pyx_v_traceback = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_notify_link_list", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_XDECREF(__pyx_t_23); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_link_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_final_link); __Pyx_XDECREF(__pyx_v_done); __Pyx_XDECREF((PyObject *)__pyx_v_hub); __Pyx_XDECREF(__pyx_v_unswitched); __Pyx_XDECREF(__pyx_v_link); __Pyx_XDECREF(__pyx_v_id_link); __Pyx_XDECREF(__pyx_v_traceback); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
237: # The core of the _notify_links method to notify
238: # links in order. Lets the ``links`` list be mutated,
239: # and only notifies up to the last item in the list, in case
240: # objects are added to it.
+241: if not links:
__pyx_t_1 = (__pyx_v_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_links) != 0);
__pyx_t_2 = ((!__pyx_t_1) != 0);
if (__pyx_t_2) {
/* … */
}
242: # HMM. How did we get here? Running two threads at once?
243: # Seen once on Py27/Win/Appveyor
244: # https://ci.appveyor.com/project/jamadden/gevent/builds/36875645/job/9wahj9ft4h4qa170
+245: return []
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
246:
+247: only_while_ready = not self._notify_all
__pyx_v_only_while_ready = (!(__pyx_v_self->_notify_all != 0));
+248: final_link = links[-1]
if (unlikely(__pyx_v_links == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 248, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_links, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_final_link = __pyx_t_3; __pyx_t_3 = 0;
+249: done = set() # of ids
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_done = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+250: hub = self.hub if self.hub is not None else get_hub_if_exists()
__pyx_t_2 = (((PyObject *)__pyx_v_self->hub) != Py_None); if ((__pyx_t_2 != 0)) { __Pyx_INCREF((PyObject *)__pyx_v_self->hub); __pyx_t_3 = ((PyObject *)__pyx_v_self->hub); } else { __pyx_t_4 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_if_exists(0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_v_hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_3); __pyx_t_3 = 0;
+251: unswitched = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_unswitched = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+252: while links: # remember this can be mutated
while (1) {
__pyx_t_2 = (__pyx_v_links != Py_None)&&(PyList_GET_SIZE(__pyx_v_links) != 0);
if (!__pyx_t_2) break;
+253: if only_while_ready and not self.ready():
__pyx_t_1 = (__pyx_v_only_while_ready != 0); if (__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L7_bool_binop_done; } __pyx_t_1 = ((!(((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0)) != 0); __pyx_t_2 = __pyx_t_1; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+254: break
goto __pyx_L5_break;
255:
+256: link = links.pop(0) # Cython optimizes using list internals
if (unlikely(__pyx_v_links == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop"); __PYX_ERR(0, 256, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyList_PopIndex(__pyx_v_links, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_3); __pyx_t_3 = 0;
+257: id_link = id(link)
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, __pyx_v_link); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_id_link, __pyx_t_3); __pyx_t_3 = 0;
+258: if id_link not in done:
__pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_id_link, __pyx_v_done, Py_NE)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 258, __pyx_L1_error) __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* … */ }
259: # XXX: JAM: What was I thinking? This doesn't make much sense,
260: # there's a good chance `link` will be deallocated, and its id() will
261: # be free to be reused. This also makes looping difficult, you have to
262: # create new functions inside a loop rather than just once outside the loop.
+263: done.add(id_link)
__pyx_t_5 = PySet_Add(__pyx_v_done, __pyx_v_id_link); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 263, __pyx_L1_error)
+264: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L17_try_end; __pyx_L10_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L11_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L17_try_end:; }
+265: self._drop_lock_for_switch_out()
__pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_drop_lock_for_switch_out(__pyx_v_self, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+266: try:
/*try:*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L30_try_end; __pyx_L23_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L21_error; __pyx_L24_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_L30_try_end:; } }
+267: link(self)
__Pyx_INCREF(__pyx_v_link); __pyx_t_4 = __pyx_v_link; __pyx_t_12 = NULL; __pyx_t_13 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_13 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_12, ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+268: except greenlet_error:
__Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_12); __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_greenlet_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 268, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_14); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_ErrRestore(__pyx_t_3, __pyx_t_4, __pyx_t_12); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_12 = 0; if (__pyx_t_13) { __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_link_list", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_4, &__pyx_t_3) < 0) __PYX_ERR(0, 268, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_3);
269: # couldn't switch to a greenlet, we must be
270: # running in a different thread. back on the list it goes for next time.
+271: unswitched.append(link)
__pyx_t_5 = __Pyx_PyList_Append(__pyx_v_unswitched, __pyx_v_link); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 271, __pyx_L25_except_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L24_exception_handled; } goto __pyx_L25_except_error; __pyx_L25_except_error:;
272: finally:
+273: self._acquire_lock_for_switch_in()
/*finally:*/ { /*normal exit:*/{ __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_acquire_lock_for_switch_in(__pyx_v_self, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22; } __pyx_L21_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_13 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_acquire_lock_for_switch_in(__pyx_v_self, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_11, __pyx_t_10, __pyx_t_9); __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L10_error; __pyx_L36_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; goto __pyx_L10_error; } __pyx_L22:; }
274:
+275: except: # pylint:disable=bare-except
/*except:*/ { __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_link_list", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_12) < 0) __PYX_ERR(0, 275, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_12);
276: # We're running in the hub, errors must not escape.
+277: if hub is not None:
__pyx_t_1 = (((PyObject *)__pyx_v_hub) != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* … */ goto __pyx_L39; }
+278: hub.handle_error((link, self), *sys.exc_info())
__pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hub), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_INCREF(__pyx_v_link); __Pyx_GIVEREF(__pyx_v_link); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_link); __Pyx_INCREF((PyObject *)__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_20, 1, ((PyObject *)__pyx_v_self)); __pyx_t_21 = PyTuple_New(1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = 0; __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_n_s_sys); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; __pyx_t_22 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_23))) { __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_23); if (likely(__pyx_t_22)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_23); __Pyx_INCREF(__pyx_t_22); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_23, function); __pyx_t_15 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_22, }; __pyx_t_20 = __Pyx_PyObject_FastCall(__pyx_t_23, __pyx_callargs+1-__pyx_t_15, 0+__pyx_t_15); __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; } __pyx_t_23 = __Pyx_PySequence_Tuple(__pyx_t_20); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = PyNumber_Add(__pyx_t_21, __pyx_t_23); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_20, NULL); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 278, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
279: else:
+280: import traceback
/*else*/ { __pyx_t_23 = __Pyx_ImportDottedModule(__pyx_n_s_traceback, NULL); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 280, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_XDECREF_SET(__pyx_v_traceback, __pyx_t_23); __pyx_t_23 = 0;
+281: traceback.print_exc()
__pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v_traceback, __pyx_n_s_print_exc); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 281, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_14 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_15 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_14, }; __pyx_t_23 = __Pyx_PyObject_FastCall(__pyx_t_20, __pyx_callargs+1-__pyx_t_15, 0+__pyx_t_15); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 281, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0; } __pyx_L39:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L11_exception_handled; } __pyx_L12_except_error:;
282:
+283: if link is final_link:
__pyx_t_2 = (__pyx_v_link == __pyx_v_final_link); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* … */ } } __pyx_L5_break:;
+284: break
goto __pyx_L5_break;
+285: return unswitched
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_unswitched); __pyx_r = __pyx_v_unswitched; goto __pyx_L0;
286:
+287: def _notify_links(self, arrived_while_waiting):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links(PyObject *__pyx_v_self, PyObject *__pyx_v_arrived_while_waiting); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__notify_links(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_arrived_while_waiting, int __pyx_skip_dispatch) { PyObject *__pyx_v_notifier = NULL; PyObject *__pyx_v_unswitched = NULL; PyObject *__pyx_v_un2 = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_notify_links", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_arrived_while_waiting}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_notifier); __Pyx_XDECREF(__pyx_v_unswitched); __Pyx_XDECREF(__pyx_v_un2); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links(PyObject *__pyx_v_self, PyObject *__pyx_v_arrived_while_waiting); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_10_notify_links, "AbstractLinkable._notify_links(self, list arrived_while_waiting)"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links = {"_notify_links", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links, METH_O, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_10_notify_links}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links(PyObject *__pyx_v_self, PyObject *__pyx_v_arrived_while_waiting) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arrived_while_waiting), (&PyList_Type), 1, "arrived_while_waiting", 1))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_10_notify_links(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self), ((PyObject*)__pyx_v_arrived_while_waiting)); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_10_notify_links(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_arrived_while_waiting) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_notify_links", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__notify_links(__pyx_v_self, __pyx_v_arrived_while_waiting, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__16 = PyTuple_Pack(2, __pyx_n_s_self_2, __pyx_n_s_arrived_while_waiting); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_11_notify_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable__notify_links, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_notify_links, __pyx_t_1) < 0) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_notify_links, 287, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 287, __pyx_L1_error)
288: # This method must hold the GIL, or be guarded with the lock that guards
289: # this object. Thus, while we are notifying objects, an object from another
290: # thread simply cannot arrive and mutate ``_links`` or ``arrived_while_waiting``
291:
292: # ``arrived_while_waiting`` is a list of greenlet.switch methods
293: # to call. These were objects that called wait() while we were processing,
294: # and which would have run *before* those that had actually waited
295: # and blocked. Instead of returning True immediately, we add them to this
296: # list so they wait their turn.
297:
298: # We release self._notifier here when done invoking links.
299: # The object itself becomes false in a boolean way as soon
300: # as this method returns.
+301: notifier = self._notifier
__pyx_t_1 = __pyx_v_self->_notifier;
__Pyx_INCREF(__pyx_t_1);
__pyx_v_notifier = __pyx_t_1;
__pyx_t_1 = 0;
+302: if notifier is None:
__pyx_t_6 = (__pyx_v_notifier == Py_None); __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { /* … */ }
303: # XXX: How did we get here?
+304: self._check_and_notify()
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_check_and_notify(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+305: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
306: # Early links are allowed to remove later links, and links
307: # are allowed to add more links, thus we must not
308: # make a copy of our the ``_links`` list, we must traverse it and
309: # mutate in place.
310: #
311: # We were ready() at the time this callback was scheduled; we
312: # may not be anymore, and that status may change during
313: # callback processing. Some of our subclasses (Event) will
314: # want to notify everyone who was registered when the status
315: # became true that it was once true, even though it may not be
316: # any more. In that case, we must not keep notifying anyone that's
317: # newly added after that, even if we go ready again.
+318: try:
/*try:*/ {
+319: unswitched = self._notify_link_list(self._links)
__pyx_t_1 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_notify_link_list(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_unswitched = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
320: # Now, those that arrived after we had begun the notification
321: # process. Follow the same rules, stop with those that are
322: # added so far to prevent starvation.
+323: if arrived_while_waiting:
__pyx_t_7 = (__pyx_v_arrived_while_waiting != Py_None)&&(PyList_GET_SIZE(__pyx_v_arrived_while_waiting) != 0);
if (__pyx_t_7) {
/* … */
}
}
+324: un2 = self._notify_link_list(arrived_while_waiting)
__pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_notify_link_list(__pyx_v_self, __pyx_v_arrived_while_waiting); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_un2 = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+325: unswitched.extend(un2)
if (unlikely(__pyx_v_unswitched == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 325, __pyx_L5_error) } __pyx_t_8 = __Pyx_PyList_Extend(__pyx_v_unswitched, __pyx_v_un2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 325, __pyx_L5_error)
326:
327: # Anything left needs to go back on the main list.
+328: self._links.extend(arrived_while_waiting)
if (unlikely(__pyx_v_self->_links == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 328, __pyx_L5_error) } __pyx_t_8 = __Pyx_PyList_Extend(__pyx_v_self->_links, __pyx_v_arrived_while_waiting); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 328, __pyx_L5_error)
329: finally:
330: # We should not have created a new notifier even if callbacks
331: # released us because we loop through *all* of our links on the
332: # same callback while self._notifier is still true.
+333: assert self._notifier is notifier, (self._notifier, notifier)
/*finally:*/ { /*normal exit:*/{ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = (__pyx_v_self->_notifier == __pyx_v_notifier); __pyx_t_6 = (__pyx_t_7 != 0); if (unlikely(!__pyx_t_6)) { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_self->_notifier); __Pyx_GIVEREF(__pyx_v_self->_notifier); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_notifier); __Pyx_INCREF(__pyx_v_notifier); __Pyx_GIVEREF(__pyx_v_notifier); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_notifier); __pyx_t_1 = PyTuple_Pack(1, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_builtin_AssertionError, __pyx_t_1, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 333, __pyx_L1_error) } } #else if ((1)); else __PYX_ERR(0, 333, __pyx_L1_error) #endif /* … */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); __pyx_t_7 = (__pyx_t_6 != 0); if (unlikely(!__pyx_t_7)) { __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_self->_notifier); __Pyx_GIVEREF(__pyx_v_self->_notifier); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_notifier); __Pyx_INCREF(__pyx_v_notifier); __Pyx_GIVEREF(__pyx_v_notifier); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_notifier); __pyx_t_2 = PyTuple_Pack(1, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_builtin_AssertionError, __pyx_t_2, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 333, __pyx_L9_error) } } #else if ((1)); else __PYX_ERR(0, 333, __pyx_L9_error) #endif
+334: self._notifier = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; goto __pyx_L6; } __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __pyx_t_5 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename; { /* … */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); } __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13); __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10; goto __pyx_L1_error; __pyx_L9_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; goto __pyx_L1_error; } __pyx_L6:; }
335: # TODO: Maybe we should intelligently reset self.hub to
336: # free up thread affinity? In case of a pathological situation where
337: # one object was used from one thread once & first, but usually is
338: # used by another thread.
339: #
340: # BoundedSemaphore does this.
341: # Now we may be ready or not ready. If we're ready, which
342: # could have happened during the last link we called, then we
343: # must have more links than we started with. We need to schedule the
344: # wakeup.
+345: self._check_and_notify()
__pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_check_and_notify(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+346: if unswitched:
__pyx_t_7 = (__pyx_v_unswitched != Py_None)&&(PyList_GET_SIZE(__pyx_v_unswitched) != 0);
if (__pyx_t_7) {
/* … */
}
+347: self._handle_unswitched_notifications(unswitched)
__pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_handle_unswitched_notifications(__pyx_v_self, __pyx_v_unswitched); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
348:
349:
+350: def _handle_unswitched_notifications(self, unswitched):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__handle_unswitched_notifications(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_unswitched) { struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub = 0; PyObject *__pyx_v_root_greenlets = NULL; int __pyx_v_printed_tb; int __pyx_v_only_while_ready; PyObject *__pyx_v_link = NULL; PyObject *__pyx_v_glet = NULL; PyObject *__pyx_v_parent = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_handle_unswitched_notifications", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._handle_unswitched_notifications", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_hub); __Pyx_XDECREF(__pyx_v_root_greenlets); __Pyx_XDECREF(__pyx_v_link); __Pyx_XDECREF(__pyx_v_glet); __Pyx_XDECREF(__pyx_v_parent); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
351: # Given a list of callable objects that raised
352: # ``greenlet.error`` when we called them: If we can determine
353: # that it is a parked greenlet (the callablle is a
354: # ``greenlet.switch`` method) and we can determine the hub
355: # that the greenlet belongs to (either its parent, or, in the
356: # case of a main greenlet, find a hub with the same parent as
357: # this greenlet object) then:
358:
359: # Move this to be a callback in that thread.
360: # (This relies on holding the GIL *or* ``Hub.loop.run_callback`` being
361: # thread-safe! Note that the CFFI implementations are definitely
362: # NOT thread-safe. TODO: Make them? Or an alternative?)
363: #
364: # Otherwise, print some error messages.
365:
366: # TODO: Inline this for individual links. That handles the
367: # "only while ready" case automatically. Be careful about locking in that case.
368: #
369: # TODO: Add a 'strict' mode that prevents doing this dance, since it's
370: # inherently not safe.
+371: root_greenlets = None
__Pyx_INCREF(Py_None);
__pyx_v_root_greenlets = ((PyObject*)Py_None);
+372: printed_tb = False
__pyx_v_printed_tb = 0;
+373: only_while_ready = not self._notify_all
__pyx_v_only_while_ready = (!(__pyx_v_self->_notify_all != 0));
374:
+375: while unswitched:
while (1) {
__pyx_t_1 = (__pyx_v_unswitched != Py_None)&&(PyList_GET_SIZE(__pyx_v_unswitched) != 0);
if (!__pyx_t_1) break;
+376: if only_while_ready and not self.ready():
__pyx_t_2 = (__pyx_v_only_while_ready != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } __pyx_t_2 = ((!(((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+377: self.__print_unswitched_warning(unswitched, printed_tb)
__pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_AbstractLinkable__print_unswitched_warning(__pyx_v_self, __pyx_v_unswitched, __pyx_v_printed_tb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+378: break
goto __pyx_L4_break;
379:
+380: link = unswitched.pop(0)
if (unlikely(__pyx_v_unswitched == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop"); __PYX_ERR(0, 380, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyList_PopIndex(__pyx_v_unswitched, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_3); __pyx_t_3 = 0;
381:
+382: hub = None # Also serves as a "handled?" flag
__Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None));
383: # Is it a greenlet.switch method?
+384: if (getattr(link, '__name__', None) == 'switch'
__pyx_t_3 = __Pyx_GetAttr3(__pyx_v_link, __pyx_n_s_name, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_switch, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* … */ if (__pyx_t_1) { /* … */ }
+385: and isinstance(getattr(link, '__self__', None), greenlet)):
__pyx_t_3 = __Pyx_GetAttr3(__pyx_v_link, __pyx_n_s_self, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_TypeCheck(__pyx_t_3, __pyx_ptype_6gevent_27_gevent_c_abstract_linkable_greenlet); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_4; __pyx_L9_bool_binop_done:;
+386: glet = link.__self__
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_link, __pyx_n_s_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_glet, __pyx_t_3); __pyx_t_3 = 0;
+387: parent = glet.parent
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_parent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_parent, __pyx_t_3); __pyx_t_3 = 0;
388:
+389: while parent is not None:
while (1) { __pyx_t_1 = (__pyx_v_parent != Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (!__pyx_t_4) break;
+390: if hasattr(parent, 'loop'): # Assuming the hub.
__pyx_t_4 = __Pyx_HasAttr(__pyx_v_parent, __pyx_n_s_loop); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 390, __pyx_L1_error) __pyx_t_1 = (__pyx_t_4 != 0); if (__pyx_t_1) { /* … */ }
+391: hub = glet.parent
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_parent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_3)); __pyx_t_3 = 0;
+392: break
goto __pyx_L12_break;
+393: parent = glet.parent
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_glet, __pyx_n_s_parent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_parent, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L12_break:;
394:
+395: if hub is None:
__pyx_t_1 = (((PyObject *)__pyx_v_hub) == Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* … */ }
+396: if root_greenlets is None:
__pyx_t_4 = (__pyx_v_root_greenlets == ((PyObject*)Py_None)); __pyx_t_1 = (__pyx_t_4 != 0); if (__pyx_t_1) { /* … */ }
+397: root_greenlets = get_roots_and_hubs()
__pyx_t_3 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_get_roots_and_hubs(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_root_greenlets, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
+398: hub = root_greenlets.get(glet)
if (unlikely(__pyx_v_root_greenlets == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 398, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_root_greenlets, __pyx_v_glet, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_hub, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_3)); __pyx_t_3 = 0;
399:
+400: if hub is not None and hub.loop is not None:
__pyx_t_4 = (((PyObject *)__pyx_v_hub) != Py_None); __pyx_t_2 = (__pyx_t_4 != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L17_bool_binop_done; } __pyx_t_2 = (__pyx_v_hub->loop != Py_None); __pyx_t_4 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_4; __pyx_L17_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+401: hub.loop.run_callback_threadsafe(link, self)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub->loop, __pyx_n_s_run_callback_threadsafe); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_link, ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+402: if hub is None or hub.loop is None:
__pyx_t_4 = (((PyObject *)__pyx_v_hub) == Py_None); __pyx_t_2 = (__pyx_t_4 != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L20_bool_binop_done; } __pyx_t_2 = (__pyx_v_hub->loop == Py_None); __pyx_t_4 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_4; __pyx_L20_bool_binop_done:; if (__pyx_t_1) { /* … */ } } __pyx_L4_break:;
403: # We couldn't handle it
+404: self.__print_unswitched_warning(link, printed_tb)
__pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_AbstractLinkable__print_unswitched_warning(__pyx_v_self, __pyx_v_link, __pyx_v_printed_tb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+405: printed_tb = True
__pyx_v_printed_tb = 1;
406:
407:
+408: def __print_unswitched_warning(self, link, printed_tb):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__AbstractLinkable__print_unswitched_warning(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_link, int __pyx_v_printed_tb) { PyObject *__pyx_v_traceback = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_AbstractLinkable__print_unswitched_warning", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__print_unswitched_warning", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_traceback); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+409: print('gevent: error: Unable to switch to greenlet', link,
__pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_gevent_error_Unable_to_switch_to); __Pyx_GIVEREF(__pyx_kp_s_gevent_error_Unable_to_switch_to); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_gevent_error_Unable_to_switch_to); __Pyx_INCREF(__pyx_v_link); __Pyx_GIVEREF(__pyx_v_link); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_link); __Pyx_INCREF(__pyx_n_s_from); __Pyx_GIVEREF(__pyx_n_s_from); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_from); __Pyx_INCREF((PyObject *)__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_kp_s_crossing_thread_boundaries_is_n); __Pyx_GIVEREF(__pyx_kp_s_crossing_thread_boundaries_is_n); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_s_crossing_thread_boundaries_is_n); /* … */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
410: 'from', self, '; crossing thread boundaries is not allowed.',
+411: file=sys.stderr)
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_stderr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_file, __pyx_t_4) < 0) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
412:
+413: if not printed_tb:
__pyx_t_5 = ((!(__pyx_v_printed_tb != 0)) != 0); if (__pyx_t_5) { /* … */ }
+414: printed_tb = True
__pyx_v_printed_tb = 1;
+415: print(
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__2 = PyTuple_Pack(2, __pyx_kp_s_gevent_error_This_is_a_result_of, __pyx_kp_s_and_is_a_bug_in_the_calling_code); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2);
416: 'gevent: error: '
417: 'This is a result of using gevent objects from multiple threads,',
+418: 'and is a bug in the calling code.', file=sys.stderr)
__pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_stderr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_file, __pyx_t_1) < 0) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
419:
+420: import traceback
__pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_traceback, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_traceback = __pyx_t_1; __pyx_t_1 = 0;
+421: traceback.print_stack()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_traceback, __pyx_n_s_print_stack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_2, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
422:
+423: def _quiet_unlink_all(self, obj):
static void __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__quiet_unlink_all(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_obj) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_quiet_unlink_all", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_WriteUnraisable("gevent._gevent_c_abstract_linkable.AbstractLinkable._quiet_unlink_all", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
+424: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* … */ }
+425: return
goto __pyx_L0;
426:
+427: self.unlink(obj)
__pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_obj, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+428: if self._notifier is not None and self._notifier.args:
__pyx_t_1 = (__pyx_v_self->_notifier != Py_None); __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_notifier, __pyx_n_s_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+429: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_L12_try_end:; }
+430: self._notifier.args[0].remove(obj)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_notifier, __pyx_n_s_args); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 430, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 430, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_remove); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 430, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_10 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+431: except ValueError:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_ErrRestore(0,0,0); goto __pyx_L8_exception_handled; } goto __pyx_L9_except_error; __pyx_L9_except_error:;
432: pass
433:
+434: def __wait_to_be_notified(self, rawlink): # pylint:disable=too-many-branches
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__AbstractLinkable__wait_to_be_notified(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_v_rawlink) { PyObject *__pyx_v_resume_this_greenlet = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_AbstractLinkable__wait_to_be_notified", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_resume_this_greenlet); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+435: resume_this_greenlet = getcurrent().switch # pylint:disable=undefined-variable
__pyx_t_1 = ((PyObject *)__pyx_f_6gevent_27_gevent_c_abstract_linkable_getcurrent()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_resume_this_greenlet = __pyx_t_2; __pyx_t_2 = 0;
+436: if rawlink:
__pyx_t_3 = (__pyx_v_rawlink != 0); if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+437: self.rawlink(resume_this_greenlet)
__pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_resume_this_greenlet, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
438: else:
+439: self._notifier.args[0].append(resume_this_greenlet)
/*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_notifier, __pyx_n_s_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_resume_this_greenlet); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:;
440:
+441: try:
/*try:*/ {
+442: self._switch_to_hub(self.hub)
__pyx_t_1 = ((PyObject *)__pyx_v_self->hub); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_switch_to_hub(__pyx_v_self, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 442, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
443: # If we got here, we were automatically unlinked already.
+444: resume_this_greenlet = None
__Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_resume_this_greenlet, Py_None); }
445: finally:
+446: self._quiet_unlink_all(resume_this_greenlet)
/*finally:*/ { /*normal exit:*/{ ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_quiet_unlink_all(__pyx_v_self, __pyx_v_resume_this_greenlet); goto __pyx_L6; } __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename; { ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_quiet_unlink_all(__pyx_v_self, __pyx_v_resume_this_greenlet); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7; goto __pyx_L1_error; } __pyx_L6:; }
447:
+448: def _switch_to_hub(self, the_hub):
static int __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__switch_to_hub(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_the_hub) { PyObject *__pyx_v_result = NULL; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_switch_to_hub", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._switch_to_hub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+449: self._drop_lock_for_switch_out()
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_drop_lock_for_switch_out(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+450: try:
/*try:*/ {
+451: result = the_hub.switch()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_the_hub, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_3, }; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_result = __pyx_t_1; __pyx_t_1 = 0; }
452: finally:
+453: self._acquire_lock_for_switch_in()
/*finally:*/ { /*normal exit:*/{ __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_acquire_lock_for_switch_in(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_acquire_lock_for_switch_in(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; __pyx_L7_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; goto __pyx_L1_error; } __pyx_L5:; }
+454: if result is not self: # pragma: no cover
__pyx_t_13 = (__pyx_v_result != ((PyObject *)__pyx_v_self)); __pyx_t_14 = (__pyx_t_13 != 0); if (unlikely(__pyx_t_14)) { /* … */ }
455: raise InvalidSwitchError(
+456: 'Invalid switch into %s.wait(): %r' % (
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_s_wait_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidSwitchError); __pyx_t_2 = __pyx_v_6gevent_27_gevent_c_abstract_linkable_InvalidSwitchError; __pyx_t_15 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 455, __pyx_L1_error)
+457: self.__class__.__name__,
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_INCREF(__pyx_v_result); __Pyx_GIVEREF(__pyx_v_result); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_result); __pyx_t_3 = 0;
458: result,
459: )
460: )
461:
+462: def _acquire_lock_for_switch_in(self):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__acquire_lock_for_switch_in(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_acquire_lock_for_switch_in", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_acquire_lock_for_switch_in); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_4, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._acquire_lock_for_switch_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_12_acquire_lock_for_switch_in, "AbstractLinkable._acquire_lock_for_switch_in(self)"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in = {"_acquire_lock_for_switch_in", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in, METH_NOARGS, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_12_acquire_lock_for_switch_in}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_acquire_lock_for_switch_in (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_12_acquire_lock_for_switch_in(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_12_acquire_lock_for_switch_in(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_acquire_lock_for_switch_in", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__acquire_lock_for_switch_in(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._acquire_lock_for_switch_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_13_acquire_lock_for_switch_in, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable__acquire_lock_f, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_acquire_lock_for_switch_in, __pyx_t_1) < 0) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_acquire_lock_for_switch_in, 462, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 462, __pyx_L1_error)
+463: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
464:
+465: def _drop_lock_for_switch_out(self):
static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__drop_lock_for_switch_out(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_drop_lock_for_switch_out", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_drop_lock_for_switch_out); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #ifdef __Pyx_CyFunction_USED if (!__Pyx_IsCyOrPyCFunction(__pyx_t_1) #else if (!PyCFunction_Check(__pyx_t_1) #endif || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_4, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._drop_lock_for_switch_out", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_14_drop_lock_for_switch_out, "AbstractLinkable._drop_lock_for_switch_out(self)"); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out = {"_drop_lock_for_switch_out", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out, METH_NOARGS, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_14_drop_lock_for_switch_out}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_drop_lock_for_switch_out (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_14_drop_lock_for_switch_out(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_14_drop_lock_for_switch_out(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_drop_lock_for_switch_out", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__drop_lock_for_switch_out(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._drop_lock_for_switch_out", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_15_drop_lock_for_switch_out, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable__drop_lock_for, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_drop_lock_for_switch_out, __pyx_t_1) < 0) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__abstract_linkable_py, __pyx_n_s_drop_lock_for_switch_out, 465, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 465, __pyx_L1_error)
+466: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
467:
+468: def _wait_core(self, timeout, catch=Timeout):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait_core(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, PyObject *__pyx_v_timeout, struct __pyx_opt_args_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait_core *__pyx_optional_args) { PyObject *__pyx_v_catch = __pyx_k__3; PyObject *__pyx_v_timer = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_wait_core", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_catch = __pyx_optional_args->catch; } } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_timer); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __Pyx_INCREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout); __pyx_k__3 = __pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout; __Pyx_GIVEREF(__pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout);
469: """
470: The core of the wait implementation, handling switching and
471: linking.
472:
473: This method is NOT safe to call from multiple threads.
474:
475: ``self.hub`` must be initialized before entering this method.
476: The hub that is set is considered the owner and cannot be changed
477: while this method is running. It must only be called from the thread
478: where ``self.hub`` is the current hub.
479:
480: If *catch* is set to ``()``, a timeout that elapses will be
481: allowed to be raised.
482:
483: :return: A true value if the wait succeeded without timing out.
484: That is, a true return value means we were notified and control
485: resumed in this greenlet.
486: """
+487: with Timeout._start_new_or_dummy(timeout) as timer: # Might release
/*with:*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_27_gevent_c_abstract_linkable_Timeout, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_timeout}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_6, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_timer = __pyx_t_3; __pyx_t_3 = 0; /* … */ } __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 487, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 487, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 487, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_14 < 0) __PYX_ERR(0, 487, __pyx_L9_except_error) __pyx_t_13 = ((!(__pyx_t_14 != 0)) != 0); if (unlikely(__pyx_t_13)) { __Pyx_GIVEREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; __PYX_ERR(0, 487, __pyx_L9_except_error) } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L11_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L4_return; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__4, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } goto __pyx_L6; } __pyx_L4_return: { __pyx_t_9 = __pyx_r; __pyx_r = 0; if (__pyx_t_5) { __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__4, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0; } __pyx_L6:; } goto __pyx_L34; __pyx_L3_error:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L1_error; __pyx_L34:; } /* … */ __pyx_tuple__4 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4);
488: # We already checked above (_wait()) if we're ready()
+489: try:
{ /*try:*/ { /* … */ } __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L7_error; __pyx_L17_try_return:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L11_try_return; __pyx_L16_except_return:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L11_try_return; }
+490: self.__wait_to_be_notified(
__pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_AbstractLinkable__wait_to_be_notified(__pyx_v_self, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 490, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
491: True,# Use rawlink()
492: )
+493: return True
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L17_try_return;
+494: except catch as ex:
__pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_v_catch); if (__pyx_t_4) { __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 494, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_v_ex = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L24_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_4 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L15_except_error; } __pyx_L23_return: { __pyx_t_22 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; __pyx_r = __pyx_t_22; __pyx_t_22 = 0; goto __pyx_L16_except_return; } } } goto __pyx_L15_except_error; __pyx_L15_except_error:;
+495: if ex is not timer:
__pyx_t_13 = (__pyx_v_ex != __pyx_v_timer); __pyx_t_14 = (__pyx_t_13 != 0); if (unlikely(__pyx_t_14)) { /* … */ }
+496: raise
__Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_1, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 496, __pyx_L24_error)
497: # test_set_and_clear and test_timeout in test_threading
498: # rely on the exact return values, not just truthish-ness
+499: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L23_return; }
500:
+501: def _wait_return_value(self, waited, wait_success):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait_return_value(CYTHON_UNUSED struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, CYTHON_UNUSED int __pyx_v_waited, CYTHON_UNUSED int __pyx_v_wait_success) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_wait_return_value", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
502: # pylint:disable=unused-argument
503: # Subclasses should override this to return a value from _wait.
504: # By default we return None.
+505: return None # pragma: no cover all extent subclasses override
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
506:
+507: def _wait(self, timeout=None):
static PyObject *__pyx_f_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self, struct __pyx_opt_args_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable__wait *__pyx_optional_args) { PyObject *__pyx_v_timeout = ((PyObject *)Py_None); PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_gotit = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_wait", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_timeout = __pyx_optional_args->timeout; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_abstract_linkable.AbstractLinkable._wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_gotit); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
508: # Watch where we could potentially release the GIL.
+509: self._capture_hub(True) # Must create, we must have an owner. Might release
__pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_capture_hub(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
510:
+511: if self.ready(): # *might* release, if overridden in Python.
__pyx_t_2 = (((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->ready(__pyx_v_self, 0) != 0); if (__pyx_t_2) { /* … */ }
+512: result = self._wait_return_value(False, False) # pylint:disable=assignment-from-none
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_return_value(__pyx_v_self, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = __pyx_t_1; __pyx_t_1 = 0;
+513: if self._notifier:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 513, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
514: # We're already notifying waiters; one of them must have run
515: # and switched to this greenlet, which arrived here. Alternately,
516: # we could be in a separate thread (but we're holding the GIL/object lock)
+517: self.__wait_to_be_notified(False) # Use self._notifier.args[0] instead of self.rawlink
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_AbstractLinkable__wait_to_be_notified(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
518:
+519: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
520:
+521: gotit = self._wait_core(timeout)
__pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_core(__pyx_v_self, __pyx_v_timeout, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_gotit = __pyx_t_1; __pyx_t_1 = 0;
+522: return self._wait_return_value(True, gotit)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_gotit); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 522, __pyx_L1_error) __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self->__pyx_vtab)->_wait_return_value(__pyx_v_self, 1, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
523:
+524: def _at_fork_reinit(self):
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_17_at_fork_reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_16_at_fork_reinit, "AbstractLinkable._at_fork_reinit(self)\n\n This method was added in Python 3.9 and is called by logging.py\n ``_after_at_fork_child_reinit_locks`` on Lock objects.\n\n It is also called from threading.py, ``_after_fork`` in\n ``_reset_internal_locks``, and that can hit ``Event`` objects.\n\n Subclasses should reset themselves to an initial state. This\n includes unlocking/releasing, if possible. This method detaches from the\n previous hub and drops any existing notifier.\n "); static PyMethodDef __pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_17_at_fork_reinit = {"_at_fork_reinit", (PyCFunction)__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_17_at_fork_reinit, METH_NOARGS, __pyx_doc_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_16_at_fork_reinit}; static PyObject *__pyx_pw_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_17_at_fork_reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_at_fork_reinit (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_16_at_fork_reinit(((struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_16_at_fork_reinit(struct __pyx_obj_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_at_fork_reinit", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_self_2); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* … */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_27_gevent_c_abstract_linkable_16AbstractLinkable_17_at_fork_reinit, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_AbstractLinkable__at_fork_reinit, NULL, __pyx_n_s_gevent__gevent_c_abstract_linkab, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable->tp_dict, __pyx_n_s_at_fork_reinit, __pyx_t_1) < 0) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_6gevent_27_gevent_c_abstract_linkable_AbstractLinkable);
525: """
526: This method was added in Python 3.9 and is called by logging.py
527: ``_after_at_fork_child_reinit_locks`` on Lock objects.
528:
529: It is also called from threading.py, ``_after_fork`` in
530: ``_reset_internal_locks``, and that can hit ``Event`` objects.
531:
532: Subclasses should reset themselves to an initial state. This
533: includes unlocking/releasing, if possible. This method detaches from the
534: previous hub and drops any existing notifier.
535: """
+536: self.hub = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF((PyObject *)__pyx_v_self->hub); __Pyx_DECREF((PyObject *)__pyx_v_self->hub); __pyx_v_self->hub = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None);
+537: self._notifier = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_notifier); __Pyx_DECREF(__pyx_v_self->_notifier); __pyx_v_self->_notifier = Py_None;
538:
+539: def _init():
static void __pyx_f_6gevent_27_gevent_c_abstract_linkable__init(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_init", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
+540: greenlet_init() # pylint:disable=undefined-variable
__pyx_f_6gevent_27_gevent_c_abstract_linkable_greenlet_init();
541:
+542: _init()
__pyx_f_6gevent_27_gevent_c_abstract_linkable__init();
543:
544:
+545: from gevent._util import import_c_accel
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_import_c_accel); __Pyx_GIVEREF(__pyx_n_s_import_c_accel); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_import_c_accel); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_1) < 0) __PYX_ERR(0, 545, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+546: import_c_accel(globals(), 'gevent.__abstract_linkable')
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_kp_s_gevent___abstract_linkable); __Pyx_GIVEREF(__pyx_kp_s_gevent___abstract_linkable); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_gevent___abstract_linkable); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;