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: _tracer.c
001: # Copyright (c) 2018 gevent. See LICENSE for details.
002: # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
003: from __future__ import print_function, absolute_import, division
004:
+005: import sys
__pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_sys); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_sys, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+006: import traceback
__pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_traceback, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_traceback); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_traceback, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
007:
+008: from greenlet import settrace
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_settrace); __Pyx_GIVEREF(__pyx_n_s_settrace); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_settrace); __pyx_t_2 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __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_settrace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_settrace); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_settrace, __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;
+009: from greenlet import getcurrent
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_getcurrent); __Pyx_GIVEREF(__pyx_n_s_getcurrent); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_getcurrent); __pyx_t_1 = __Pyx_Import(__pyx_n_s_greenlet, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __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_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_getcurrent); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_getcurrent, __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;
010:
+011: from gevent.util import format_run_info
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_format_run_info); __Pyx_GIVEREF(__pyx_n_s_format_run_info); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_format_run_info); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __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_format_run_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_format_run_info); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_format_run_info, __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;
012:
+013: from gevent._compat import perf_counter
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_perf_counter); __Pyx_GIVEREF(__pyx_n_s_perf_counter); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_perf_counter); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__compat, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __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_perf_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter, __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;
+014: from gevent._util import gmctime
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_gmctime); __Pyx_GIVEREF(__pyx_n_s_gmctime); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gmctime); __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __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_gmctime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_6gevent_16_gevent_c_tracer_gmctime); __Pyx_DECREF_SET(__pyx_v_6gevent_16_gevent_c_tracer_gmctime, __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;
015:
016:
+017: __all__ = [
__pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_GreenletTracer); __Pyx_GIVEREF(__pyx_n_s_GreenletTracer); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_GreenletTracer); __Pyx_INCREF(__pyx_n_s_HubSwitchTracer); __Pyx_GIVEREF(__pyx_n_s_HubSwitchTracer); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_HubSwitchTracer); __Pyx_INCREF(__pyx_n_s_MaxSwitchTracer); __Pyx_GIVEREF(__pyx_n_s_MaxSwitchTracer); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_MaxSwitchTracer); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
018: 'GreenletTracer',
019: 'HubSwitchTracer',
020: 'MaxSwitchTracer',
021: ]
022:
023: # Recall these classes are cython compiled, so
024: # class variable declarations are bad.
025:
026:
+027: class GreenletTracer(object):
struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_GreenletTracer { PyObject *(*_trace)(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *, PyObject *, PyObject *, int __pyx_skip_dispatch); PyObject *(*did_block_hub)(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *, PyObject *, int __pyx_skip_dispatch); PyObject *(*kill)(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_vtabptr_6gevent_16_gevent_c_tracer_GreenletTracer;
+028: def __init__(self):
/* Python wrapper */ static int __pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_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_16_gevent_c_tracer_14GreenletTracer___init__(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer___init__(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self) { PyObject *__pyx_v_prev_trace = NULL; 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_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_prev_trace); __Pyx_RefNannyFinishContext(); return __pyx_r; }
029: # A counter, incremented by the greenlet trace function
030: # we install on every greenlet switch. This is reset when the
031: # periodic monitoring thread runs.
032:
+033: self.greenlet_switch_counter = 0
__pyx_v_self->greenlet_switch_counter = 0;
034:
035: # The greenlet last switched to.
+036: self.active_greenlet = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->active_greenlet); __Pyx_DECREF(__pyx_v_self->active_greenlet); __pyx_v_self->active_greenlet = Py_None;
037:
038: # The trace function that was previously installed,
039: # if any.
040: # NOTE: Calling a class instance is cheaper than
041: # calling a bound method (at least when compiled with cython)
042: # even when it redirects to another function.
+043: prev_trace = settrace(self)
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_settrace); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_settrace; __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[2] = {__pyx_t_3, ((PyObject *)__pyx_v_self)}; __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, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_prev_trace = __pyx_t_1; __pyx_t_1 = 0;
044:
+045: self.previous_trace_function = prev_trace
__Pyx_INCREF(__pyx_v_prev_trace); __Pyx_GIVEREF(__pyx_v_prev_trace); __Pyx_GOTREF(__pyx_v_self->previous_trace_function); __Pyx_DECREF(__pyx_v_self->previous_trace_function); __pyx_v_self->previous_trace_function = __pyx_v_prev_trace;
046:
+047: self._killed = False
__pyx_v_self->_killed = 0;
048:
+049: def kill(self):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer_kill(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("kill", 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_kill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __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_16_gevent_c_tracer_14GreenletTracer_3kill)) { __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, 49, __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_tracer.GreenletTracer.kill", __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_16_gevent_c_tracer_14GreenletTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_2kill, "GreenletTracer.kill(self)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_3kill = {"kill", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_3kill, METH_NOARGS, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_2kill}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_3kill(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("kill (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_2kill(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_2kill(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("kill", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer_kill(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __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_tracer.GreenletTracer.kill", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_3kill, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_kill, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_kill, __pyx_t_2) < 0) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_kill, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 49, __pyx_L1_error)
050: # Must be called in the monitored thread.
+051: if not self._killed:
__pyx_t_6 = ((!(__pyx_v_self->_killed != 0)) != 0); if (__pyx_t_6) { /* … */ }
+052: self._killed = True
__pyx_v_self->_killed = 1;
+053: settrace(self.previous_trace_function)
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_settrace); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_settrace; __pyx_t_3 = NULL; __pyx_t_5 = 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_5 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_self->previous_trace_function}; __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, 53, __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;
+054: self.previous_trace_function = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->previous_trace_function); __Pyx_DECREF(__pyx_v_self->previous_trace_function); __pyx_v_self->previous_trace_function = Py_None;
055:
+056: def _trace(self, event, args):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer__trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 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_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __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_16_gevent_c_tracer_14GreenletTracer_5_trace)) { __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[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __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_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer._trace", __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_16_gevent_c_tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_4_trace, "GreenletTracer._trace(self, str event, tuple args)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_5_trace = {"_trace", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_5_trace, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_4_trace}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_5_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_event = 0; PyObject *__pyx_v_args = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_event)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 56, __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, "_trace") < 0)) __PYX_ERR(0, 56, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_event = ((PyObject*)values[0]); __pyx_v_args = ((PyObject*)values[1]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 56, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 56, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 56, __pyx_L1_error) __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_4_trace(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args); 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_16_gevent_c_tracer_14GreenletTracer_4_trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __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_tracer.GreenletTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_5_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer__trace, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_trace, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 56, __pyx_L1_error)
057: # This function runs in the thread we are monitoring.
+058: self.greenlet_switch_counter += 1
__pyx_v_self->greenlet_switch_counter = (__pyx_v_self->greenlet_switch_counter + 1);
+059: if event in ('switch', 'throw'):
__Pyx_INCREF(__pyx_v_event); __pyx_t_6 = __pyx_v_event; __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_t_6, __pyx_n_s_switch, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 59, __pyx_L1_error) __pyx_t_9 = (__pyx_t_8 != 0); if (!__pyx_t_9) { } else { __pyx_t_7 = __pyx_t_9; goto __pyx_L4_bool_binop_done; } __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_6, __pyx_n_s_throw, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 59, __pyx_L1_error) __pyx_t_8 = (__pyx_t_9 != 0); __pyx_t_7 = __pyx_t_8; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* … */ goto __pyx_L3; }
060: # args is (origin, target). This is the only defined
061: # case
+062: self.active_greenlet = args[1]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 62, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->active_greenlet); __Pyx_DECREF(__pyx_v_self->active_greenlet); __pyx_v_self->active_greenlet = __pyx_t_1; __pyx_t_1 = 0;
063: else:
+064: self.active_greenlet = None
/*else*/ { __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->active_greenlet); __Pyx_DECREF(__pyx_v_self->active_greenlet); __pyx_v_self->active_greenlet = Py_None; } __pyx_L3:;
+065: if self.previous_trace_function is not None:
__pyx_t_8 = (__pyx_v_self->previous_trace_function != Py_None); __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* … */ }
+066: self.previous_trace_function(event, args)
__Pyx_INCREF(__pyx_v_self->previous_trace_function); __pyx_t_2 = __pyx_v_self->previous_trace_function; __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[3] = {__pyx_t_3, __pyx_v_event, __pyx_v_args}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __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;
067:
+068: def __call__(self, event, args):
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_event = 0; PyObject *__pyx_v_args = 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); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__call__ (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; 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 (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_event)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); __PYX_ERR(0, 68, __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, "__call__") < 0)) __PYX_ERR(0, 68, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); } __pyx_v_event = values[0]; __pyx_v_args = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 68, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_6__call__(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_6__call__(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__call__", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+069: return self._trace(event, args)
__Pyx_XDECREF(__pyx_r); if (!(likely(PyString_CheckExact(__pyx_v_event))||((__pyx_v_event) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_event))) __PYX_ERR(0, 69, __pyx_L1_error) if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_v_args))) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self->__pyx_vtab)->_trace(__pyx_v_self, ((PyObject*)__pyx_v_event), ((PyObject*)__pyx_v_args), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
070:
+071: def did_block_hub(self, hub):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer_did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, int __pyx_skip_dispatch) { int __pyx_v_did_switch; PyObject *__pyx_v_active_greenlet = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 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_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __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_16_gevent_c_tracer_14GreenletTracer_9did_block_hub)) { __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_hub}; __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, 71, __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_tracer.GreenletTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_active_greenlet); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_8did_block_hub, "GreenletTracer.did_block_hub(self, hub)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub, METH_O, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_8did_block_hub}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_8did_block_hub(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_8did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __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_tracer.GreenletTracer.did_block_hub", __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(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_9did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_did_block_hub, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 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__tracer_py, __pyx_n_s_did_block_hub, 71, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 71, __pyx_L1_error)
072: # Check to see if we have blocked since the last call to this
073: # method. Returns a true value if we blocked (not in the hub),
074: # a false value if everything is fine.
075:
076: # This may be called in the same thread being traced or a
077: # different thread; if a different thread, there is a race
078: # condition with this being incremented in the thread we're
079: # monitoring, but probably not often enough to lead to
080: # annoying false positives.
081:
+082: active_greenlet = self.active_greenlet
__pyx_t_1 = __pyx_v_self->active_greenlet;
__Pyx_INCREF(__pyx_t_1);
__pyx_v_active_greenlet = __pyx_t_1;
__pyx_t_1 = 0;
+083: did_switch = self.greenlet_switch_counter != 0
__pyx_v_did_switch = (__pyx_v_self->greenlet_switch_counter != 0);
+084: self.greenlet_switch_counter = 0
__pyx_v_self->greenlet_switch_counter = 0;
085:
+086: if did_switch or active_greenlet is None or active_greenlet is hub:
__pyx_t_7 = (__pyx_v_did_switch != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = (__pyx_v_active_greenlet == Py_None); __pyx_t_8 = (__pyx_t_7 != 0); if (!__pyx_t_8) { } else { __pyx_t_6 = __pyx_t_8; goto __pyx_L4_bool_binop_done; } __pyx_t_8 = (__pyx_v_active_greenlet == __pyx_v_hub); __pyx_t_7 = (__pyx_t_8 != 0); __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_6) { /* … */ }
087: # Either we switched, or nothing is running (we got a
088: # trace event we don't know about or were requested to
089: # ignore), or we spent the whole time in the hub, blocked
090: # for IO. Nothing to report.
+091: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
+092: return True, active_greenlet
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(Py_True); __Pyx_GIVEREF(Py_True); PyTuple_SET_ITEM(__pyx_t_1, 0, Py_True); __Pyx_INCREF(__pyx_v_active_greenlet); __Pyx_GIVEREF(__pyx_v_active_greenlet); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_active_greenlet); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
093:
+094: def ignore_current_greenlet_blocking(self):
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_11ignore_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_10ignore_current_greenlet_blocking, "GreenletTracer.ignore_current_greenlet_blocking(self)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_11ignore_current_greenlet_blocking = {"ignore_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_11ignore_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_10ignore_current_greenlet_blocking}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_11ignore_current_greenlet_blocking(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("ignore_current_greenlet_blocking (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_10ignore_current_greenlet_blocking(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_10ignore_current_greenlet_blocking(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ignore_current_greenlet_blocking", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_11ignore_current_greenlet_blocking, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_ignore_current_gr, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_ignore_current_greenlet_blocking, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __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__tracer_py, __pyx_n_s_ignore_current_greenlet_blocking, 94, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 94, __pyx_L1_error)
095: # Don't pay attention to the current greenlet.
+096: self.active_greenlet = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->active_greenlet); __Pyx_DECREF(__pyx_v_self->active_greenlet); __pyx_v_self->active_greenlet = Py_None;
097:
+098: def monitor_current_greenlet_blocking(self):
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_13monitor_current_greenlet_blocking(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_12monitor_current_greenlet_blocking, "GreenletTracer.monitor_current_greenlet_blocking(self)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_13monitor_current_greenlet_blocking = {"monitor_current_greenlet_blocking", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_13monitor_current_greenlet_blocking, METH_NOARGS, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_12monitor_current_greenlet_blocking}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_13monitor_current_greenlet_blocking(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("monitor_current_greenlet_blocking (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_12monitor_current_greenlet_blocking(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_12monitor_current_greenlet_blocking(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("monitor_current_greenlet_blocking", 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_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.monitor_current_greenlet_blocking", __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(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_13monitor_current_greenlet_blocking, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_monitor_current_g, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_monitor_current_greenlet_blockin, __pyx_t_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 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__tracer_py, __pyx_n_s_monitor_current_greenlet_blockin, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 98, __pyx_L1_error)
+099: self.active_greenlet = getcurrent()
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_getcurrent); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_getcurrent; __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, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->active_greenlet); __Pyx_DECREF(__pyx_v_self->active_greenlet); __pyx_v_self->active_greenlet = __pyx_t_1; __pyx_t_1 = 0;
100:
+101: def did_block_hub_report(self, hub, active_greenlet, format_kwargs):
/* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_15did_block_hub_report(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_14did_block_hub_report, "GreenletTracer.did_block_hub_report(self, hub, active_greenlet, format_kwargs)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_15did_block_hub_report = {"did_block_hub_report", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_15did_block_hub_report, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_16_gevent_c_tracer_14GreenletTracer_14did_block_hub_report}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_14GreenletTracer_15did_block_hub_report(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_hub = 0; PyObject *__pyx_v_active_greenlet = 0; PyObject *__pyx_v_format_kwargs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub_report (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_active_greenlet,&__pyx_n_s_format_kwargs,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_active_greenlet,&__pyx_n_s_format_kwargs,0}; #endif PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_active_greenlet)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, 1); __PYX_ERR(0, 101, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_format_kwargs)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, 2); __PYX_ERR(0, 101, __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, "did_block_hub_report") < 0)) __PYX_ERR(0, 101, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_hub = values[0]; __pyx_v_active_greenlet = values[1]; __pyx_v_format_kwargs = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("did_block_hub_report", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 101, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_14did_block_hub_report(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_active_greenlet, __pyx_v_format_kwargs); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_14GreenletTracer_14did_block_hub_report(struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_active_greenlet, PyObject *__pyx_v_format_kwargs) { PyObject *__pyx_v_report = NULL; PyObject *__pyx_v_frame = NULL; PyObject *__pyx_v_stack = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub_report", 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_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_report); __Pyx_XDECREF(__pyx_v_frame); __Pyx_XDECREF(__pyx_v_stack); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__14 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_hub, __pyx_n_s_active_greenlet, __pyx_n_s_format_kwargs, __pyx_n_s_report, __pyx_n_s_frame, __pyx_n_s_stack); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_14GreenletTracer_15did_block_hub_report, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_GreenletTracer_did_block_hub_rep, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer->tp_dict, __pyx_n_s_did_block_hub_report, __pyx_t_2) < 0) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer); __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 7, 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__tracer_py, __pyx_n_s_did_block_hub_report, 101, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 101, __pyx_L1_error)
102: # XXX: On Python 2 with greenlet 1.0a1, '%s' formatting a greenlet
103: # results in a unicode object. This is a bug in greenlet, I think.
104: # https://github.com/python-greenlet/greenlet/issues/218
+105: report = ['=' * 80,
__pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_s_); __Pyx_GIVEREF(__pyx_kp_s_); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_); __Pyx_GIVEREF(__pyx_t_2); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_report = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+106: '\n%s : Greenlet %s appears to be blocked' %
__pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_Greenlet_s_appears_to_be_bloc, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+107: (gmctime(), str(active_greenlet))]
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_gmctime); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_gmctime; __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, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_active_greenlet); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0;
+108: report.append(" Reported by %s" % (self,))
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF((PyObject *)__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Reported_by_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+109: try:
{ /*try:*/ { /* … */ } /* … */ __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:; }
+110: frame = sys._current_frames()[hub.thread_ident]
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16_gevent_c_tracer_sys, __pyx_n_s_current_frames); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[1] = {__pyx_t_1, }; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub, __pyx_n_s_thread_ident); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L3_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_v_frame = __pyx_t_1; __pyx_t_1 = 0;
+111: except KeyError:
__pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_4) { __Pyx_AddTraceback("gevent._gevent_c_tracer.GreenletTracer.did_block_hub_report", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 111, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_2);
112: # The thread holding the hub has died. Perhaps we shouldn't
113: # even report this?
+114: stack = ["Unknown: No thread found for hub %r\n" % (hub,)]
__pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_hub); __Pyx_GIVEREF(__pyx_v_hub); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_hub); __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_No_thread_found_for_hub, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 114, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = 0; __pyx_v_stack = __pyx_t_9; __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error; __pyx_L5_except_error:;
115: else:
+116: stack = traceback.format_stack(frame)
/*else:*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_16_gevent_c_tracer_traceback, __pyx_n_s_format_stack); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_frame}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_stack = __pyx_t_1; __pyx_t_1 = 0; } __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;
+117: report.append('Blocked Stack (for thread id %s):' % (hex(hub.thread_ident),))
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_hub, __pyx_n_s_thread_ident); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Blocked_Stack_for_thread_id_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_3); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+118: report.append(''.join(stack))
__pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_v_stack); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_report, __pyx_t_3); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+119: report.append("Info:")
__pyx_t_5 = __Pyx_PyList_Append(__pyx_v_report, __pyx_kp_s_Info); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 119, __pyx_L1_error)
+120: report.extend(format_run_info(**format_kwargs))
if (unlikely(__pyx_v_format_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 120, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_format_kwargs))) { __pyx_t_3 = PyDict_Copy(__pyx_v_format_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_3 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_format_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_6gevent_16_gevent_c_tracer_format_run_info, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyList_Extend(__pyx_v_report, __pyx_t_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
121:
+122: return report
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_report); __pyx_r = __pyx_v_report; goto __pyx_L0;
123:
124:
+125: class _HubTracer(GreenletTracer):
struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer__HubTracer { struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_GreenletTracer __pyx_base; }; static struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer__HubTracer *__pyx_vtabptr_6gevent_16_gevent_c_tracer__HubTracer;
+126: def __init__(self, hub, max_blocking_time):
/* Python wrapper */ static int __pyx_pw_6gevent_16_gevent_c_tracer_10_HubTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_16_gevent_c_tracer_10_HubTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_hub = 0; PyObject *__pyx_v_max_blocking_time = 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,&__pyx_n_s_max_blocking_time,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; 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 (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_blocking_time)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 126, __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, 126, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); } __pyx_v_hub = values[0]; __pyx_v_max_blocking_time = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 126, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer._HubTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_10_HubTracer___init__(((struct __pyx_obj_6gevent_16_gevent_c_tracer__HubTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_16_gevent_c_tracer_10_HubTracer___init__(struct __pyx_obj_6gevent_16_gevent_c_tracer__HubTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) { 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_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_tracer._HubTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+127: GreenletTracer.__init__(self)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_GreenletTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __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, ((PyObject *)__pyx_v_self)}; __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, 127, __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;
+128: self.max_blocking_time = max_blocking_time
__pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_max_blocking_time); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_v_self->max_blocking_time = __pyx_t_5;
+129: self.hub = hub
__Pyx_INCREF(__pyx_v_hub); __Pyx_GIVEREF(__pyx_v_hub); __Pyx_GOTREF(__pyx_v_self->hub); __Pyx_DECREF(__pyx_v_self->hub); __pyx_v_self->hub = __pyx_v_hub;
130:
+131: def kill(self):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_10_HubTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_10_HubTracer_kill(struct __pyx_obj_6gevent_16_gevent_c_tracer__HubTracer *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("kill", 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_kill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __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_16_gevent_c_tracer_10_HubTracer_3kill)) { __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, 131, __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_tracer._HubTracer.kill", __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_16_gevent_c_tracer_10_HubTracer_3kill(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_10_HubTracer_2kill, "_HubTracer.kill(self)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_10_HubTracer_3kill = {"kill", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_10_HubTracer_3kill, METH_NOARGS, __pyx_doc_6gevent_16_gevent_c_tracer_10_HubTracer_2kill}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_10_HubTracer_3kill(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("kill (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_10_HubTracer_2kill(((struct __pyx_obj_6gevent_16_gevent_c_tracer__HubTracer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_10_HubTracer_2kill(struct __pyx_obj_6gevent_16_gevent_c_tracer__HubTracer *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("kill", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_10_HubTracer_kill(__pyx_v_self, 1); 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; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gevent._gevent_c_tracer._HubTracer.kill", __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(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_10_HubTracer_3kill, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubTracer_kill, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer__HubTracer->tp_dict, __pyx_n_s_kill, __pyx_t_2) < 0) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer__HubTracer); __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 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__tracer_py, __pyx_n_s_kill, 131, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 131, __pyx_L1_error)
+132: self.hub = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->hub); __Pyx_DECREF(__pyx_v_self->hub); __pyx_v_self->hub = Py_None;
+133: GreenletTracer.kill(self)
__pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer_kill(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
134:
135:
+136: class HubSwitchTracer(_HubTracer):
struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_HubSwitchTracer { struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer__HubTracer __pyx_base; }; static struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_vtabptr_6gevent_16_gevent_c_tracer_HubSwitchTracer;
137: # A greenlet tracer that records the last time we switched *into* the hub.
138:
+139: def __init__(self, hub, max_blocking_time):
/* Python wrapper */ static int __pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_hub = 0; PyObject *__pyx_v_max_blocking_time = 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,&__pyx_n_s_max_blocking_time,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; 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 (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_blocking_time)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 139, __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, 139, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); } __pyx_v_hub = values[0]; __pyx_v_max_blocking_time = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 139, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.HubSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15HubSwitchTracer___init__(((struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_16_gevent_c_tracer_15HubSwitchTracer___init__(struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) { 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_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_tracer.HubSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+140: _HubTracer.__init__(self, hub, max_blocking_time)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer__HubTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __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[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __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;
+141: self.last_entered_hub = 0
__pyx_v_self->last_entered_hub = 0.0;
142:
+143: def _trace(self, event, args):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_15HubSwitchTracer__trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 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_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __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_16_gevent_c_tracer_15HubSwitchTracer_3_trace)) { __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[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __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_tracer.HubSwitchTracer._trace", __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_16_gevent_c_tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_15HubSwitchTracer_2_trace, "HubSwitchTracer._trace(self, str event, tuple args)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_15HubSwitchTracer_3_trace = {"_trace", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_3_trace, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_16_gevent_c_tracer_15HubSwitchTracer_2_trace}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_event = 0; PyObject *__pyx_v_args = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_event)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 143, __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, "_trace") < 0)) __PYX_ERR(0, 143, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_event = ((PyObject*)values[0]); __pyx_v_args = ((PyObject*)values[1]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 143, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.HubSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 143, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 143, __pyx_L1_error) __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15HubSwitchTracer_2_trace(((struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args); 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_16_gevent_c_tracer_15HubSwitchTracer_2_trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_15HubSwitchTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __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_tracer.HubSwitchTracer._trace", __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(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_15HubSwitchTracer_3_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubSwitchTracer__trace, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_HubSwitchTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_HubSwitchTracer); __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 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__tracer_py, __pyx_n_s_trace, 143, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 143, __pyx_L1_error)
+144: GreenletTracer._trace(self, event, args)
__pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer__trace(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+145: if self.active_greenlet is self.hub:
__pyx_t_6 = (__pyx_v_self->__pyx_base.__pyx_base.active_greenlet == __pyx_v_self->__pyx_base.hub); __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { /* … */ }
+146: self.last_entered_hub = perf_counter()
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_perf_counter; __pyx_t_3 = NULL; __pyx_t_5 = 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_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, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->last_entered_hub = __pyx_t_8;
147:
+148: def did_block_hub(self, hub):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_15HubSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 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_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __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_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub)) { __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_hub}; __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, 148, __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_tracer.HubSwitchTracer.did_block_hub", __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_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_15HubSwitchTracer_4did_block_hub, "HubSwitchTracer.did_block_hub(self, hub)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub, METH_O, __pyx_doc_6gevent_16_gevent_c_tracer_15HubSwitchTracer_4did_block_hub}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15HubSwitchTracer_4did_block_hub(((struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_15HubSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_HubSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_15HubSwitchTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __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_tracer.HubSwitchTracer.did_block_hub", __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(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_15HubSwitchTracer_5did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_HubSwitchTracer_did_block_hub, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_HubSwitchTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_HubSwitchTracer); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 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__tracer_py, __pyx_n_s_did_block_hub, 148, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 148, __pyx_L1_error)
+149: if perf_counter() - self.last_entered_hub > self.max_blocking_time:
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_perf_counter; __pyx_t_3 = NULL; __pyx_t_5 = 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_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, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->last_entered_hub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.max_blocking_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+150: return True, self.active_greenlet
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(Py_True); __Pyx_GIVEREF(Py_True); PyTuple_SET_ITEM(__pyx_t_1, 0, Py_True); __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet); __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->__pyx_base.__pyx_base.active_greenlet); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
151:
152:
+153: class MaxSwitchTracer(_HubTracer):
struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_MaxSwitchTracer { struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer__HubTracer __pyx_base; }; static struct __pyx_vtabstruct_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_vtabptr_6gevent_16_gevent_c_tracer_MaxSwitchTracer;
154: # A greenlet tracer that records the maximum time between switches,
155: # not including time spent in the hub.
156:
+157: def __init__(self, hub, max_blocking_time):
/* Python wrapper */ static int __pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_hub = 0; PyObject *__pyx_v_max_blocking_time = 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,&__pyx_n_s_max_blocking_time,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hub,&__pyx_n_s_max_blocking_time,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; 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 (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 157, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_blocking_time)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 157, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 157, __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, 157, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); } __pyx_v_hub = values[0]; __pyx_v_max_blocking_time = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 157, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.MaxSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15MaxSwitchTracer___init__(((struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_6gevent_16_gevent_c_tracer_15MaxSwitchTracer___init__(struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub, PyObject *__pyx_v_max_blocking_time) { 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_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gevent._gevent_c_tracer.MaxSwitchTracer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+158: _HubTracer.__init__(self, hub, max_blocking_time)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer__HubTracer), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __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[4] = {__pyx_t_3, ((PyObject *)__pyx_v_self), __pyx_v_hub, __pyx_v_max_blocking_time}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __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;
+159: self.last_switch = perf_counter()
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_perf_counter; __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, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->last_switch = __pyx_t_5;
+160: self.max_blocking = 0
__pyx_v_self->max_blocking = 0.0;
161:
+162: def _trace(self, event, args):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_15MaxSwitchTracer__trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args, int __pyx_skip_dispatch) { double __pyx_v_switched_at; PyObject *__pyx_v_old_active = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 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_trace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __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_16_gevent_c_tracer_15MaxSwitchTracer_3_trace)) { __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[3] = {__pyx_t_4, __pyx_v_event, __pyx_v_args}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __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_tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_old_active); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_2_trace, "MaxSwitchTracer._trace(self, str event, tuple args)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace = {"_trace", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_2_trace}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_event = 0; PyObject *__pyx_v_args = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace (wrapper)", 0); { #if CYTHON_USE_MODULE_STATE PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #else static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_event,&__pyx_n_s_args,0}; #endif PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_event)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args)) != 0)) kw_args--; else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, 1); __PYX_ERR(0, 162, __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, "_trace") < 0)) __PYX_ERR(0, 162, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_event = ((PyObject*)values[0]); __pyx_v_args = ((PyObject*)values[1]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_trace", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 162, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("gevent._gevent_c_tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_event), (&PyString_Type), 1, "event", 1))) __PYX_ERR(0, 162, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 1, "args", 1))) __PYX_ERR(0, 162, __pyx_L1_error) __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_2_trace(((struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args); 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_16_gevent_c_tracer_15MaxSwitchTracer_2_trace(struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_event, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_trace", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_15MaxSwitchTracer__trace(__pyx_v_self, __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __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_tracer.MaxSwitchTracer._trace", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_event, __pyx_n_s_args); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_3_trace, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MaxSwitchTracer__trace, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_MaxSwitchTracer->tp_dict, __pyx_n_s_trace, __pyx_t_2) < 0) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_MaxSwitchTracer); __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__tracer_py, __pyx_n_s_trace, 162, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 162, __pyx_L1_error)
+163: old_active = self.active_greenlet
__pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.active_greenlet;
__Pyx_INCREF(__pyx_t_1);
__pyx_v_old_active = __pyx_t_1;
__pyx_t_1 = 0;
+164: GreenletTracer._trace(self, event, args)
__pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_14GreenletTracer__trace(((struct __pyx_obj_6gevent_16_gevent_c_tracer_GreenletTracer *)__pyx_v_self), __pyx_v_event, __pyx_v_args, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+165: if old_active is not self.hub and old_active is not None:
__pyx_t_7 = (__pyx_v_old_active != __pyx_v_self->__pyx_base.hub); __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { } else { __pyx_t_6 = __pyx_t_8; goto __pyx_L4_bool_binop_done; } __pyx_t_8 = (__pyx_v_old_active != Py_None); __pyx_t_7 = (__pyx_t_8 != 0); __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_6) { /* … */ }
166: # If we're switching out of the hub, the blocking
167: # time doesn't count.
+168: switched_at = perf_counter()
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_perf_counter; __pyx_t_3 = NULL; __pyx_t_5 = 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_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, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_switched_at = __pyx_t_9;
+169: self.max_blocking = max(self.max_blocking,
__pyx_t_10 = __pyx_v_self->max_blocking; /* … */ __pyx_v_self->max_blocking = __pyx_t_11;
+170: switched_at - self.last_switch)
__pyx_t_9 = (__pyx_v_switched_at - __pyx_v_self->last_switch); /* … */ if (((__pyx_t_9 > __pyx_t_10) != 0)) { __pyx_t_11 = __pyx_t_9; } else { __pyx_t_11 = __pyx_t_10; }
171:
+172: def did_block_hub(self, hub):
static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ static PyObject *__pyx_f_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hub, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 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_did_block_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __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_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub)) { __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_hub}; __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, 172, __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_tracer.MaxSwitchTracer.did_block_hub", __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_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_4did_block_hub, "MaxSwitchTracer.did_block_hub(self, hub)"); static PyMethodDef __pyx_mdef_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub = {"did_block_hub", (PyCFunction)__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub, METH_O, __pyx_doc_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_4did_block_hub}; static PyObject *__pyx_pw_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub(PyObject *__pyx_v_self, PyObject *__pyx_v_hub) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_4did_block_hub(((struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *)__pyx_v_self), ((PyObject *)__pyx_v_hub)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_4did_block_hub(struct __pyx_obj_6gevent_16_gevent_c_tracer_MaxSwitchTracer *__pyx_v_self, PyObject *__pyx_v_hub) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("did_block_hub", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_did_block_hub(__pyx_v_self, __pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __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_tracer.MaxSwitchTracer.did_block_hub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__24 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_hub); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_16_gevent_c_tracer_15MaxSwitchTracer_5did_block_hub, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_MaxSwitchTracer_did_block_hub, NULL, __pyx_n_s_gevent__gevent_c_tracer, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_16_gevent_c_tracer_MaxSwitchTracer->tp_dict, __pyx_n_s_did_block_hub, __pyx_t_2) < 0) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_ptype_6gevent_16_gevent_c_tracer_MaxSwitchTracer);
+173: if self.max_blocking == 0:
__pyx_t_6 = ((__pyx_v_self->max_blocking == 0.0) != 0); if (__pyx_t_6) { /* … */ }
174: # We never switched. Check the time now
+175: self.max_blocking = perf_counter() - self.last_switch
__Pyx_INCREF(__pyx_v_6gevent_16_gevent_c_tracer_perf_counter); __pyx_t_2 = __pyx_v_6gevent_16_gevent_c_tracer_perf_counter; __pyx_t_3 = NULL; __pyx_t_5 = 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_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, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->last_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->max_blocking = __pyx_t_7;
176:
+177: if self.max_blocking > self.max_blocking_time:
__pyx_t_6 = ((__pyx_v_self->max_blocking > __pyx_v_self->__pyx_base.max_blocking_time) != 0); if (__pyx_t_6) { /* … */ }
+178: return True, self.active_greenlet
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(Py_True); __Pyx_GIVEREF(Py_True); PyTuple_SET_ITEM(__pyx_t_3, 0, Py_True); __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet); __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.active_greenlet); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->__pyx_base.__pyx_base.active_greenlet); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
179:
180:
+181: from gevent._util import import_c_accel
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_import_c_accel); __Pyx_GIVEREF(__pyx_n_s_import_c_accel); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel); __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __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_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+182: import_c_accel(globals(), 'gevent.__tracer')
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_INCREF(__pyx_kp_s_gevent___tracer); __Pyx_GIVEREF(__pyx_kp_s_gevent___tracer); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_gevent___tracer); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;