Cython: _hub_local.py

Generated by Cython 3.1.0a1

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: _hub_local.c

    +001: # -*- coding: utf-8 -*-

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     002: # copyright 2018 gevent. See LICENSE

     003: """

     004: Maintains the thread local hub.

     005:

     006: """

     007: from __future__ import absolute_import

     008: from __future__ import division

     009: from __future__ import print_function

     010:

     011:

    +012: import _thread

      __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_mstate_global->__pyx_n_u_thread, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_thread, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     013:

    +014: __all__ = [

      __pyx_t_2 = __Pyx_PyList_Pack(3, __pyx_mstate_global->__pyx_n_u_get_hub, __pyx_mstate_global->__pyx_n_u_get_hub_noargs, __pyx_mstate_global->__pyx_n_u_get_hub_if_exists); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_all, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     015:     'get_hub',

     016:     'get_hub_noargs',

     017:     'get_hub_if_exists',

     018: ]

     019:

     020: # These must be the "real" native thread versions,

     021: # not monkey-patched.

     022: # We are imported early enough (by gevent/__init__) that

     023: # we can rely on not being monkey-patched in any way yet.

    +024: assert 'gevent' not in str(_thread._local)

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(__pyx_assertions_enabled())) {
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_thread); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_local); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_n_u_gevent, __pyx_t_2, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 24, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_4)) {
          __Pyx_Raise(__pyx_builtin_AssertionError, 0, 0, 0);
          __PYX_ERR(0, 24, __pyx_L1_error)
        }
      }
      #else
      if ((1)); else __PYX_ERR(0, 24, __pyx_L1_error)
      #endif

    +025: class _Threadlocal(_thread._local):

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_thread); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_local); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_Pack(1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_Py3MetaclassPrepare(__pyx_t_5, __pyx_t_3, __pyx_mstate_global->__pyx_n_u_Threadlocal, __pyx_mstate_global->__pyx_n_u_Threadlocal, (PyObject *) NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, (PyObject *) NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3 != __pyx_t_2) {
        if (unlikely((PyDict_SetItemString(__pyx_t_6, "__orig_bases__", __pyx_t_2) < 0))) __PYX_ERR(0, 25, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /* … */
      __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Threadlocal, __pyx_t_3, __pyx_t_6, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Threadlocal, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     026:

    +027:     def __init__(self):

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_12_Threadlocal_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_12_Threadlocal_1__init__ = {"__init__", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_12_Threadlocal_1__init__, METH_O, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_12_Threadlocal_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_12_Threadlocal___init__(__pyx_self, ((PyObject *)__pyx_v_self));

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_12_Threadlocal___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local._Threadlocal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_12_Threadlocal_1__init__, 0, __pyx_mstate_global->__pyx_n_u_Threadlocal___init, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_SetNameInClass(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_init, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     028:         # Use a class with an initializer so that we can test

     029:         # for 'is None' instead of catching AttributeError, making

     030:         # the code cleaner and possibly solving some corner cases

     031:         # (like #687).

     032:         #

     033:         # However, under some weird circumstances, it _seems_ like the

     034:         # __init__ method doesn't get called properly ("seems" is the

     035:         # keyword). We've seen at least one instance

     036:         # (https://github.com/gevent/gevent/issues/1961) of

     037:         # ``AttributeError: '_Threadlocal' object has no attribute # 'hub'``

     038:         # which should be impossible unless:

     039:         #

     040:         # - Someone manually deletes the attribute

     041:         # - The _threadlocal object itself is in the process of being

     042:         #   deleted. The C ``tp_clear`` slot for it deletes the ``__dict__``

     043:         #   of each instance in each thread (and/or the ``tp_clear`` of ``dict`` itself

     044:         #   clears the instance). Now, how we could be getting

     045:         #   cleared while still being used is unclear, but clearing is part of

     046:         #   circular garbage collection, and in the bug report it looks like we're inside a

     047:         #   weakref finalizer or ``__del__`` method, which could suggest that

     048:         #   garbage collection is happening.

     049:         #

     050:         # See https://github.com/gevent/gevent/issues/1961

     051:         # and ``get_hub_if_exists()``

    +052:         super(_Threadlocal, self).__init__()

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_Threadlocal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 52, __pyx_L1_error);
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self) != (0)) __PYX_ERR(0, 52, __pyx_L1_error);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __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;

    +053:         self.Hub = None

      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_Hub, Py_None) < 0) __PYX_ERR(0, 53, __pyx_L1_error)

    +054:         self.loop = None

      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_loop, Py_None) < 0) __PYX_ERR(0, 54, __pyx_L1_error)

    +055:         self.hub = None

      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_hub, Py_None) < 0) __PYX_ERR(0, 55, __pyx_L1_error)

     056:

    +057: _threadlocal = _Threadlocal()

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_Threadlocal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XGOTREF(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal);
      __Pyx_DECREF_SET(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;

     058:

    +059: Hub = None # Set when gevent.hub is imported

      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Hub, Py_None) < 0) __PYX_ERR(0, 59, __pyx_L1_error)

     060:

    +061: def get_hub_class():

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyObject *__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_class(CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_v_hubtype = NULL;
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_hubtype);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_19_gevent_c_hub_local_get_hub_class, "Return the type of hub to use for the current thread.\n\n    If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used.\n    ");
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_1get_hub_class = {"get_hub_class", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_1get_hub_class, METH_NOARGS, __pyx_doc_6gevent_19_gevent_c_hub_local_get_hub_class};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_1get_hub_class(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_hub_class (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_get_hub_class(__pyx_self);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_get_hub_class(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_19_gevent_c_hub_local_get_hub_class(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __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_hub_local.get_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_1get_hub_class, 0, __pyx_mstate_global->__pyx_n_u_get_hub_class, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_hub_class, __pyx_t_5) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     062:     """Return the type of hub to use for the current thread.

     063:

     064:     If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used.

     065:     """

    +066:     hubtype = _threadlocal.Hub

      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_Hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_hubtype = __pyx_t_1;
      __pyx_t_1 = 0;

    +067:     if hubtype is None:

      __pyx_t_2 = (__pyx_v_hubtype == Py_None);
      if (__pyx_t_2) {
    /* … */
      }

    +068:         hubtype = _threadlocal.Hub = Hub

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_Hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_hubtype, __pyx_t_1);
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_Hub, __pyx_t_1) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +069:     return hubtype

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_hubtype);
      __pyx_r = __pyx_v_hubtype;
      goto __pyx_L0;

     070:

    +071: def set_default_hub_class(hubtype):

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_3set_default_hub_class(PyObject *__pyx_self, PyObject *__pyx_v_hubtype); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_3set_default_hub_class = {"set_default_hub_class", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_3set_default_hub_class, METH_O, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_3set_default_hub_class(PyObject *__pyx_self, PyObject *__pyx_v_hubtype) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("set_default_hub_class (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_2set_default_hub_class(__pyx_self, ((PyObject *)__pyx_v_hubtype));

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_2set_default_hub_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_hubtype) {
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.set_default_hub_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_3set_default_hub_class, 0, __pyx_mstate_global->__pyx_n_u_set_default_hub_class, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_set_default_hub_class, __pyx_t_5) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     072:     global Hub

    +073:     Hub = hubtype

      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Hub, __pyx_v_hubtype) < 0) __PYX_ERR(0, 73, __pyx_L1_error)

     074:

    +075: def get_hub():

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_5get_hub(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_19_gevent_c_hub_local_get_hub(CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_v_hub = NULL;
      PyObject *__pyx_v_hubtype = NULL;
      struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_hub);
      __Pyx_XDECREF(__pyx_v_hubtype);
      __Pyx_XGIVEREF((PyObject *)__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_5get_hub(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_19_gevent_c_hub_local_4get_hub, "\n    Return the hub for the current thread.\n\n    If a hub does not exist in the current thread, a new one is\n    created of the type returned by :func:`get_hub_class`.\n\n    .. deprecated:: 1.3b1\n       The ``*args`` and ``**kwargs`` arguments are deprecated. They were\n       only used when the hub was created, and so were non-deterministic---to be\n       sure they were used, *all* callers had to pass them, or they were order-dependent.\n       Use ``set_hub`` instead.\n\n    .. versionchanged:: 1.5a3\n       The *args* and *kwargs* arguments are now completely ignored.\n\n    .. versionchanged:: 23.7.0\n       The long-deprecated ``args`` and ``kwargs`` parameters are no\n       longer accepted.\n    ");
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_5get_hub = {"get_hub", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_5get_hub, METH_NOARGS, __pyx_doc_6gevent_19_gevent_c_hub_local_4get_hub};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_5get_hub(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_hub (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_4get_hub(__pyx_self);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_4get_hub(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub(1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __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_hub_local.get_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_5get_hub, 0, __pyx_mstate_global->__pyx_n_u_get_hub, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_hub, __pyx_t_5) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     076:     """

     077:     Return the hub for the current thread.

     078:

     079:     If a hub does not exist in the current thread, a new one is

     080:     created of the type returned by :func:`get_hub_class`.

     081:

     082:     .. deprecated:: 1.3b1

     083:        The ``*args`` and ``**kwargs`` arguments are deprecated. They were

     084:        only used when the hub was created, and so were non-deterministic---to be

     085:        sure they were used, *all* callers had to pass them, or they were order-dependent.

     086:        Use ``set_hub`` instead.

     087:

     088:     .. versionchanged:: 1.5a3

     089:        The *args* and *kwargs* arguments are now completely ignored.

     090:

     091:     .. versionchanged:: 23.7.0

     092:        The long-deprecated ``args`` and ``kwargs`` parameters are no

     093:        longer accepted.

     094:     """

     095:     # See get_hub_if_exists

    +096:     try:

      {
        /*try:*/ {
    /* … */
        }
        __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;
        goto __pyx_L8_try_end;
        __pyx_L3_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    /* … */
        __pyx_L5_except_error:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L1_error;
        __pyx_L4_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        __pyx_L8_try_end:;
      }

    +097:         hub = _threadlocal.hub

          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_v_hub = __pyx_t_4;
          __pyx_t_4 = 0;

    +098:     except AttributeError:

        __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
        if (__pyx_t_5) {
          __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 98, __pyx_L5_except_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_7);

    +099:         hub = None

          __Pyx_INCREF(Py_None);
          __Pyx_XDECREF_SET(__pyx_v_hub, Py_None);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L4_exception_handled;
        }
        goto __pyx_L5_except_error;

    +100:     if hub is None:

      __pyx_t_8 = (__pyx_v_hub == Py_None);
      if (__pyx_t_8) {
    /* … */
      }

    +101:         hubtype = get_hub_class()

        __pyx_t_7 = __pyx_f_6gevent_19_gevent_c_hub_local_get_hub_class(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_v_hubtype = __pyx_t_7;
        __pyx_t_7 = 0;

    +102:         hub = _threadlocal.hub = hubtype()

        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_v_hubtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 102, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_DECREF_SET(__pyx_v_hub, __pyx_t_7);
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub, __pyx_t_7) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    +103:     return hub

      __Pyx_XDECREF((PyObject *)__pyx_r);
      if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_mstate_global->__pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 103, __pyx_L1_error)
      __Pyx_INCREF(__pyx_v_hub);
      __pyx_r = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_hub);
      goto __pyx_L0;

     104:

     105: # For Cython purposes, we need to duplicate get_hub into this function so it

     106: # can be directly called.

    +107: def get_hub_noargs():

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_noargs(CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_v_hub = NULL;
      PyObject *__pyx_v_hubtype = NULL;
      struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub_noargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_hub);
      __Pyx_XDECREF(__pyx_v_hubtype);
      __Pyx_XGIVEREF((PyObject *)__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_7get_hub_noargs = {"get_hub_noargs", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_7get_hub_noargs, METH_NOARGS, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_7get_hub_noargs(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_hub_noargs (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_6get_hub_noargs(__pyx_self);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_6get_hub_noargs(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_noargs(1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __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_hub_local.get_hub_noargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_7get_hub_noargs, 0, __pyx_mstate_global->__pyx_n_u_get_hub_noargs, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_hub_noargs, __pyx_t_5) < 0) __PYX_ERR(0, 107, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     108:     # See get_hub_if_exists

    +109:     try:

      {
        /*try:*/ {
    /* … */
        }
        __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;
        goto __pyx_L8_try_end;
        __pyx_L3_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    /* … */
        __pyx_L5_except_error:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L1_error;
        __pyx_L4_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        __pyx_L8_try_end:;
      }

    +110:         hub = _threadlocal.hub

          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_v_hub = __pyx_t_4;
          __pyx_t_4 = 0;

    +111:     except AttributeError:

        __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
        if (__pyx_t_5) {
          __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub_noargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 111, __pyx_L5_except_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_7);

    +112:         hub = None

          __Pyx_INCREF(Py_None);
          __Pyx_XDECREF_SET(__pyx_v_hub, Py_None);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L4_exception_handled;
        }
        goto __pyx_L5_except_error;

    +113:     if hub is None:

      __pyx_t_8 = (__pyx_v_hub == Py_None);
      if (__pyx_t_8) {
    /* … */
      }

    +114:         hubtype = get_hub_class()

        __pyx_t_7 = __pyx_f_6gevent_19_gevent_c_hub_local_get_hub_class(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_v_hubtype = __pyx_t_7;
        __pyx_t_7 = 0;

    +115:         hub = _threadlocal.hub = hubtype()

        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_v_hubtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_DECREF_SET(__pyx_v_hub, __pyx_t_7);
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub, __pyx_t_7) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    +116:     return hub

      __Pyx_XDECREF((PyObject *)__pyx_r);
      if (!(likely(((__pyx_v_hub) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hub, __pyx_mstate_global->__pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 116, __pyx_L1_error)
      __Pyx_INCREF(__pyx_v_hub);
      __pyx_r = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_hub);
      goto __pyx_L0;

     117:

    +118: def get_hub_if_exists():

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_if_exists(CYTHON_UNUSED int __pyx_skip_dispatch) {
      struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub_if_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF((PyObject *)__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_19_gevent_c_hub_local_8get_hub_if_exists, "\n    Return the hub for the current thread.\n\n    Return ``None`` if no hub has been created yet.\n    ");
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_9get_hub_if_exists = {"get_hub_if_exists", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_9get_hub_if_exists, METH_NOARGS, __pyx_doc_6gevent_19_gevent_c_hub_local_8get_hub_if_exists};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_9get_hub_if_exists(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_hub_if_exists (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_8get_hub_if_exists(__pyx_self);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_8get_hub_if_exists(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((PyObject *)__pyx_f_6gevent_19_gevent_c_hub_local_get_hub_if_exists(1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __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_hub_local.get_hub_if_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_9get_hub_if_exists, 0, __pyx_mstate_global->__pyx_n_u_get_hub_if_exists, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_hub_if_exists, __pyx_t_5) < 0) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

     119:     """

     120:     Return the hub for the current thread.

     121:

     122:     Return ``None`` if no hub has been created yet.

     123:     """

     124:     # Attempt a band-aid for the poorly-understood behaviour

     125:     # seen in https://github.com/gevent/gevent/issues/1961

     126:     # where the ``hub`` attribute has gone missing.

    +127:     try:

      {
        /*try:*/ {
    /* … */
        }
        __pyx_L3_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    /* … */
        __pyx_L5_except_error:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L1_error;
        __pyx_L7_try_return:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L0;
        __pyx_L6_except_return:;
        __Pyx_XGIVEREF(__pyx_t_1);
        __Pyx_XGIVEREF(__pyx_t_2);
        __Pyx_XGIVEREF(__pyx_t_3);
        __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        goto __pyx_L0;
      }

    +128:         return _threadlocal.hub

          __Pyx_XDECREF((PyObject *)__pyx_r);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop))))) __PYX_ERR(0, 128, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_t_4);
          __pyx_t_4 = 0;
          goto __pyx_L7_try_return;

    +129:     except AttributeError:

        __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
        if (__pyx_t_5) {
          __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_hub_if_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 129, __pyx_L5_except_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_7);

     130:         # XXX: I'd really like to report this, but I'm not sure how

     131:         # that can be done safely (because I don't know how we get

     132:         # here in the first place). We may be in a place where imports

     133:         # are unsafe, or the interpreter is shutting down, or the

     134:         # thread is exiting, or...

    +135:         return None

          __Pyx_XDECREF((PyObject *)__pyx_r);
          __pyx_r = ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)Py_None); __Pyx_INCREF(Py_None);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L6_except_return;
        }
        goto __pyx_L5_except_error;

     136:

     137:

     138:

     139:

    +140: def set_hub(hub):

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub); /*proto*/
    static PyObject *__pyx_f_6gevent_19_gevent_c_hub_local_set_hub(struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub, CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.set_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_19_gevent_c_hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_11set_hub = {"set_hub", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_11set_hub, METH_O, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_11set_hub(PyObject *__pyx_self, PyObject *__pyx_v_hub) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("set_hub (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hub), __pyx_mstate_global->__pyx_ptype_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop, 1, "hub", 0))) __PYX_ERR(0, 140, __pyx_L1_error)
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_10set_hub(__pyx_self, ((struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *)__pyx_v_hub));
      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_19_gevent_c_hub_local_10set_hub(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_6gevent_29_gevent_c_greenlet_primitives_SwitchOutGreenletWithLoop *__pyx_v_hub) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_19_gevent_c_hub_local_set_hub(__pyx_v_hub, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __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_hub_local.set_hub", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_11set_hub, 0, __pyx_mstate_global->__pyx_n_u_set_hub, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_set_hub, __pyx_t_5) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    +141:     _threadlocal.hub = hub

      if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_hub, ((PyObject *)__pyx_v_hub)) < 0) __PYX_ERR(0, 141, __pyx_L1_error)

     142:

    +143: def get_loop():

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyObject *__pyx_f_6gevent_19_gevent_c_hub_local_get_loop(CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.get_loop", __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_19_gevent_c_hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_13get_loop = {"get_loop", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_13get_loop, METH_NOARGS, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_13get_loop(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_loop (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_12get_loop(__pyx_self);

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_12get_loop(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_19_gevent_c_hub_local_get_loop(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_hub_local.get_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_13get_loop, 0, __pyx_mstate_global->__pyx_n_u_get_loop, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_loop, __pyx_t_5) < 0) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    +144:     return _threadlocal.loop

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_loop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     145:

    +146: def set_loop(loop):

    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop); /*proto*/
    static PyObject *__pyx_f_6gevent_19_gevent_c_hub_local_set_loop(PyObject *__pyx_v_loop, CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("gevent._gevent_c_hub_local.set_loop", __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_19_gevent_c_hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop); /*proto*/
    static PyMethodDef __pyx_mdef_6gevent_19_gevent_c_hub_local_15set_loop = {"set_loop", (PyCFunction)__pyx_pw_6gevent_19_gevent_c_hub_local_15set_loop, METH_O, 0};
    static PyObject *__pyx_pw_6gevent_19_gevent_c_hub_local_15set_loop(PyObject *__pyx_self, PyObject *__pyx_v_loop) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("set_loop (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __pyx_r = __pyx_pf_6gevent_19_gevent_c_hub_local_14set_loop(__pyx_self, ((PyObject *)__pyx_v_loop));

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_6gevent_19_gevent_c_hub_local_14set_loop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_loop) {
      PyObject *__pyx_r = NULL;
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_19_gevent_c_hub_local_set_loop(__pyx_v_loop, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
    /* … */
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_19_gevent_c_hub_local_15set_loop, 0, __pyx_mstate_global->__pyx_n_u_set_loop, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_hub_local, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_set_loop, __pyx_t_5) < 0) __PYX_ERR(0, 146, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    +147:     _threadlocal.loop = loop

      if (__Pyx_PyObject_SetAttrStr(__pyx_v_6gevent_19_gevent_c_hub_local__threadlocal, __pyx_mstate_global->__pyx_n_u_loop, __pyx_v_loop) < 0) __PYX_ERR(0, 147, __pyx_L1_error)

     148:

    +149: from gevent._util import import_c_accel

      __pyx_t_5 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_gevent__util, __pyx_t_5, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_import_c_accel, __pyx_t_5) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +150: import_c_accel(globals(), 'gevent.__hub_local')

      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_Globals(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = NULL;
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_6, __pyx_mstate_global->__pyx_kp_u_gevent___hub_local};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;