Cython: _semaphore.py

Generated by Cython 3.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: _semaphore.c

    +001: # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False

        __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
        #else
        if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     002: from __future__ import print_function, absolute_import, division

     003:

    +004: __all__ = [

        __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_n_s_Semaphore);
        __Pyx_GIVEREF(__pyx_n_s_Semaphore);
        PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Semaphore);
        __Pyx_INCREF(__pyx_n_s_BoundedSemaphore);
        __Pyx_GIVEREF(__pyx_n_s_BoundedSemaphore);
        PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_BoundedSemaphore);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_1);
        if (PyModule_AddObject(__pyx_m, __pyx_k_all, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
        #else
        if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     005:     'Semaphore',

     006:     'BoundedSemaphore',

     007: ]

     008:

    +009: def _get_linkable():

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_1_get_linkable(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore__get_linkable, "_get_linkable()");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_1_get_linkable = {"_get_linkable", (PyCFunction)__pyx_pw_6gevent_11__semaphore_1_get_linkable, METH_NOARGS, __pyx_doc_6gevent_11__semaphore__get_linkable};
    static PyObject *__pyx_pw_6gevent_11__semaphore_1_get_linkable(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_get_linkable (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore__get_linkable(__pyx_self);

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

    static PyObject *__pyx_pf_6gevent_11__semaphore__get_linkable(CYTHON_UNUSED PyObject *__pyx_self) {
      PyObject *__pyx_v_x = NULL;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_get_linkable", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("gevent.__semaphore._get_linkable", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_x);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_x); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 9, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_1_get_linkable, 0, __pyx_n_s_get_linkable, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_2, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        #else
        __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_1_get_linkable, 0, __pyx_n_s_get_linkable, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_1);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_1);
        if (PyModule_AddObject(__pyx_m, __pyx_k_get_linkable, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
        #else
        if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_linkable, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_get_linkable, 9, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 9, __pyx_L1_error)

    +010:     x = __import__('gevent._abstract_linkable')

      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_x = __pyx_t_1;
      __pyx_t_1 = 0;
    /* … */
      __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_gevent__abstract_linkable); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 10, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple_);
      __Pyx_GIVEREF(__pyx_tuple_);

    +011:     return x._abstract_linkable.AbstractLinkable

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_abstract_linkable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_AbstractLinkable); 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_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

    +012: locals()['AbstractLinkable'] = _get_linkable()

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_linkable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(PyDict_SetItem(__pyx_t_1, __pyx_n_s_AbstractLinkable, __pyx_t_2) < 0)) __PYX_ERR(0, 12, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    +013: del _get_linkable

        if (__Pyx_PyObject_DelAttrStr(__pyx_m, __pyx_n_s_get_linkable) < 0) __PYX_ERR(0, 13, __pyx_L1_error)

     014:

     015:

    +016: class Semaphore(AbstractLinkable): # pylint:disable=undefined-variable

    struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore {
      struct __pyx_vtabstruct_6gevent_19__abstract_linkable_AbstractLinkable __pyx_base;
      int (*locked)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
      int (*release)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
      PyObject *(*_start_notify)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
      int (*wait)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args);
      int (*acquire)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args);
      PyObject *(*__pyx___enter__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, int __pyx_skip_dispatch);
      PyObject *(*__pyx___exit__)(struct __pyx_obj_6gevent_11__semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
    };
    static struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *__pyx_vtabptr_6gevent_11__semaphore_Semaphore;

     017:     """

     018:     Semaphore(value=1) -> Semaphore

     019:

     020:     .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents

     021:        some classes of bugs. If unsure, most users should opt for `BoundedSemaphore`.

     022:

     023:     A semaphore manages a counter representing the number of `release`

     024:     calls minus the number of `acquire` calls, plus an initial value.

     025:     The `acquire` method blocks if necessary until it can return

     026:     without making the counter negative. A semaphore does not track ownership

     027:     by greenlets; any greenlet can call `release`, whether or not it has previously

     028:     called `acquire`.

     029:

     030:     If not given, ``value`` defaults to 1.

     031:

     032:     The semaphore is a context manager and can be used in ``with`` statements.

     033:

     034:     This Semaphore's ``__exit__`` method does not call the trace function

     035:     on CPython, but does under PyPy.

     036:

     037:

     038:     .. versionchanged:: 1.4.0

     039:         Document that the order in which waiters are awakened is not specified. It was not

     040:         specified previously, but due to CPython implementation quirks usually went in FIFO order.

     041:     .. versionchanged:: 1.5a3

     042:        Waiting greenlets are now awakened in the order in which they waited.

     043:     .. versionchanged:: 1.5a3

     044:        The low-level ``rawlink`` method (most users won't use this) now automatically

     045:        unlinks waiters before calling them.

     046:     """

     047:

    +048:     def __init__(self, value=1, hub=None):

    /* Python wrapper */
    static int __pyx_pw_6gevent_11__semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static int __pyx_pw_6gevent_11__semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_value = 0;
      PyObject *__pyx_v_hub = 0;
      CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
      {
        #if CYTHON_COMPILING_IN_LIMITED_API
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_hub,0};
        #else
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_hub,0};
        #endif
        PyObject* values[2] = {0,0};
        values[0] = ((PyObject *)__pyx_int_1);
        values[1] = ((PyObject *)Py_None);
        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 (kw_args > 0) {
              PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value);
              if (value) { values[0] = value; kw_args--; }
              else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  1:
            if (kw_args > 0) {
              PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hub);
              if (value) { values[1] = value; kw_args--; }
              else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 48, __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, 48, __pyx_L3_error)
          }
        } else {
          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;
          }
        }
        __pyx_v_value = values[0];
        __pyx_v_hub = values[1];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 48, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return -1;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore___init__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_value, __pyx_v_hub);

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

    static int __pyx_pf_6gevent_11__semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_hub) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__init__", 0);
    /* … */
      /* function exit code */
      __pyx_r = 0;
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +049:         if value < 0:

      __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(__pyx_t_2)) {
    /* … */
      }

    +050:             raise ValueError("semaphore initial value must be >= 0")

        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 50, __pyx_L1_error)
    /* … */
      __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_semaphore_initial_value_must_be); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__2);
      __Pyx_GIVEREF(__pyx_tuple__2);

    +051:         super(Semaphore, self).__init__(hub)

      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __Pyx_GIVEREF((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore);
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore));
      __Pyx_INCREF((PyObject *)__pyx_v_self);
      __Pyx_GIVEREF((PyObject *)__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_1 = __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_1)) __PYX_ERR(0, 51, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +052:         self.counter = value

      __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 52, __pyx_L1_error)
      __pyx_v_self->counter = __pyx_t_6;

    +053:         self._notify_all = False

      __pyx_v_self->__pyx_base._notify_all = 0;

     054:

    +055:     def __str__(self):

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self); /*proto*/
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_2__str__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_v_params = NULL;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__str__", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_params);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +056:         params = (self.__class__.__name__, self.counter, self.linkcount())

      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_linkcount); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      {
        PyObject *__pyx_callargs[1] = {__pyx_t_5, };
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_v_params = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

    +057:         return '<%s counter=%s _links[%s]>' % params

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_counter_s__links_s, __pyx_v_params); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

     058:

    +059:     def locked(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static int __pyx_f_6gevent_11__semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("locked", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_locked); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked)) {
            __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, 59, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_6;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L0;
          }
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
          __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
          if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
            __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
          }
          #endif
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
        }
        #endif
      }
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_WriteUnraisable("gevent.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_9Semaphore_4locked, "Semaphore.locked(self) -> bool\n\n        Return a boolean indicating whether the semaphore can be\n        acquired (`False` if the semaphore *can* be acquired). Most\n        useful with binary semaphores (those with an initial value of 1).\n\n        :rtype: bool\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_5locked = {"locked", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_4locked};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(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("locked (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_4locked(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("locked", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_11__semaphore_9Semaphore_locked(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __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.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 59, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__5);
      __Pyx_GIVEREF(__pyx_tuple__5);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_5locked, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_locked, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_5locked, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_locked, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_locked, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_locked, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_locked, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 59, __pyx_L1_error)

     060:         """

     061:         Return a boolean indicating whether the semaphore can be

     062:         acquired (`False` if the semaphore *can* be acquired). Most

     063:         useful with binary semaphores (those with an initial value of 1).

     064:

     065:         :rtype: bool

     066:         """

    +067:         return self.counter <= 0

      __pyx_r = (__pyx_v_self->counter <= 0);
      goto __pyx_L0;

     068:

    +069:     def release(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static int __pyx_f_6gevent_11__semaphore_9Semaphore_release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("release", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_7release)) {
            __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, 69, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 69, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_6;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L0;
          }
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
          __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
          if (unlikely(__pyx_type_dict_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.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1000;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_9Semaphore_6release, "Semaphore.release(self) -> int\n\n        Release the semaphore, notifying any waiters if needed. There\n        is no return value.\n\n        .. note::\n\n            This can be used to over-release the semaphore.\n            (Release more times than it has been acquired or was initially\n            created with.)\n\n            This is usually a sign of a bug, but under some circumstances it can be\n            used deliberately, for example, to model the arrival of additional\n            resources.\n\n        :rtype: None\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_7release = {"release", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_7release, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_6release};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(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("release (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_6release(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("release", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 69, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__7);
      __Pyx_GIVEREF(__pyx_tuple__7);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_release, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_release, 69, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 69, __pyx_L1_error)

     070:         """

     071:         Release the semaphore, notifying any waiters if needed. There

     072:         is no return value.

     073:

     074:         .. note::

     075:

     076:             This can be used to over-release the semaphore.

     077:             (Release more times than it has been acquired or was initially

     078:             created with.)

     079:

     080:             This is usually a sign of a bug, but under some circumstances it can be

     081:             used deliberately, for example, to model the arrival of additional

     082:             resources.

     083:

     084:         :rtype: None

     085:         """

    +086:         self.counter += 1

      __pyx_v_self->counter = (__pyx_v_self->counter + 1);

    +087:         self._check_and_notify()

      __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._check_and_notify(((struct __pyx_obj_6gevent_19__abstract_linkable_AbstractLinkable *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +088:         return self.counter

      __pyx_r = __pyx_v_self->counter;
      goto __pyx_L0;

     089:

    +090:     def ready(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static int __pyx_f_6gevent_11__semaphore_9Semaphore_ready(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("ready", 0);
      /* Check if called by wrapper */
      if (unlikely(__pyx_skip_dispatch)) ;
      /* Check if overridden in Python */
      else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_ready); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready)) {
            __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, 90, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_6;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L0;
          }
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
          __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
          if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
            __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
          }
          #endif
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
        }
        #endif
      }
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_WriteUnraisable("gevent.__semaphore.Semaphore.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_9Semaphore_8ready, "Semaphore.ready(self) -> bool\n\n        Return a boolean indicating whether the semaphore can be\n        acquired (`True` if the semaphore can be acquired).\n\n        :rtype: bool\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_9ready = {"ready", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_8ready};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("ready (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_8ready(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_8ready(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("ready", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_11__semaphore_9Semaphore_ready(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __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.__semaphore.Semaphore.ready", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__9);
      __Pyx_GIVEREF(__pyx_tuple__9);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_9ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_ready, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_9ready, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_ready, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_ready, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_ready, 90, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 90, __pyx_L1_error)

     091:         """

     092:         Return a boolean indicating whether the semaphore can be

     093:         acquired (`True` if the semaphore can be acquired).

     094:

     095:         :rtype: bool

     096:         """

    +097:         return self.counter > 0

      __pyx_r = (__pyx_v_self->counter > 0);
      goto __pyx_L0;

     098:

    +099:     def _start_notify(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_11_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_start_notify", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_start_notify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_11_start_notify)) {
            __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, 99, __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_type_dict_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.__semaphore.Semaphore._start_notify", __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_11__semaphore_9Semaphore_11_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_9Semaphore_10_start_notify, "Semaphore._start_notify(self)");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_11_start_notify = {"_start_notify", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_11_start_notify, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_10_start_notify};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_11_start_notify(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("_start_notify (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_10_start_notify(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_10_start_notify(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_start_notify", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __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.__semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 99, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__11);
      __Pyx_GIVEREF(__pyx_tuple__11);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_11_start_notify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__start_notify, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_11_start_notify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__start_notify, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_start_notify, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_start_notify, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_start_notify, 99, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 99, __pyx_L1_error)

    +100:         self._check_and_notify()

      __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._check_and_notify(((struct __pyx_obj_6gevent_19__abstract_linkable_AbstractLinkable *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     101:

    +102:     def _wait_return_value(self, waited, wait_success):

    static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore__wait_return_value(CYTHON_UNUSED struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_waited, PyObject *__pyx_v_wait_success) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_wait_return_value", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore._wait_return_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +103:         if waited:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_waited); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 103, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
      }

    +104:             return wait_success

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

     105:         # We didn't even wait, we must be good to go.

     106:         # XXX: This is probably dead code, we're careful not to go into the wait

     107:         # state if we don't expect to need to

    +108:         return True

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

     109:

    +110:     def wait(self, timeout=None):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(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 int __pyx_f_6gevent_11__semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_wait *__pyx_optional_args) {
      PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("wait", 0);
      if (__pyx_optional_args) {
        if (__pyx_optional_args->__pyx_n > 0) {
          __pyx_v_timeout = __pyx_optional_args->timeout;
        }
      }
      /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait)) {
            __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_timeout};
              __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, 110, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_6;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L0;
          }
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
          __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
          if (unlikely(__pyx_type_dict_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.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1000;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(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_11__semaphore_9Semaphore_12wait, "Semaphore.wait(self, timeout=None) -> int\n\n        Wait until it is possible to acquire this semaphore, or until the optional\n        *timeout* elapses.\n\n        .. note:: If this semaphore was initialized with a *value* of 0,\n           this method will block forever if no timeout is given.\n\n        :keyword float timeout: If given, specifies the maximum amount of seconds\n           this method will block.\n        :return: A number indicating how many times the semaphore can be acquired\n            before blocking. *This could be 0,* if other waiters acquired\n            the semaphore.\n        :rtype: int\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_13wait = {"wait", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_12wait};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(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_timeout = 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("wait (wrapper)", 0);
      {
        #if CYTHON_COMPILING_IN_LIMITED_API
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
        #else
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
        #endif
        PyObject* values[1] = {0};
        values[0] = ((PyObject *)Py_None);
        if (__pyx_kwds) {
          Py_ssize_t kw_args;
          switch (__pyx_nargs) {
            case  1: values[0] = __Pyx_Arg_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 (kw_args > 0) {
              PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_timeout);
              if (value) { values[0] = value; kw_args--; }
              else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 110, __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, "wait") < 0)) __PYX_ERR(0, 110, __pyx_L3_error)
          }
        } else {
          switch (__pyx_nargs) {
            case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
        }
        __pyx_v_timeout = values[0];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 110, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_12wait(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_timeout);

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_12wait(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("wait", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2.__pyx_n = 1;
      __pyx_t_2.timeout = __pyx_v_timeout;
      __pyx_t_1 = __pyx_vtabptr_6gevent_11__semaphore_Semaphore->wait(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 110, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__13);
      __Pyx_GIVEREF(__pyx_tuple__13);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_13wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_wait, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_13wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_wait, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_wait, __pyx_t_2) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_wait, 110, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 110, __pyx_L1_error)

     111:         """

     112:         Wait until it is possible to acquire this semaphore, or until the optional

     113:         *timeout* elapses.

     114:

     115:         .. note:: If this semaphore was initialized with a *value* of 0,

     116:            this method will block forever if no timeout is given.

     117:

     118:         :keyword float timeout: If given, specifies the maximum amount of seconds

     119:            this method will block.

     120:         :return: A number indicating how many times the semaphore can be acquired

     121:             before blocking. *This could be 0,* if other waiters acquired

     122:             the semaphore.

     123:         :rtype: int

     124:         """

    +125:         if self.counter > 0:

      __pyx_t_7 = ((__pyx_v_self->counter > 0) != 0);
      if (__pyx_t_7) {
    /* … */
      }

    +126:             return self.counter

        __pyx_r = __pyx_v_self->counter;
        goto __pyx_L0;

     127:

    +128:         self._wait(timeout) # return value irrelevant, whether we got it or got a timeout

      __pyx_t_8.__pyx_n = 1;
      __pyx_t_8.timeout = __pyx_v_timeout;
      __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._wait(((struct __pyx_obj_6gevent_19__abstract_linkable_AbstractLinkable *)__pyx_v_self), &__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +129:         return self.counter

      __pyx_r = __pyx_v_self->counter;
      goto __pyx_L0;

     130:

    +131:     def acquire(self, blocking=True, timeout=None):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(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 int __pyx_f_6gevent_11__semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_11__semaphore_9Semaphore_acquire *__pyx_optional_args) {
      int __pyx_v_blocking = ((int)1);
      PyObject *__pyx_v_timeout = ((PyObject *)Py_None);
      PyObject *__pyx_v_success = NULL;
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("acquire", 0);
      if (__pyx_optional_args) {
        if (__pyx_optional_args->__pyx_n > 0) {
          __pyx_v_blocking = __pyx_optional_args->blocking;
          if (__pyx_optional_args->__pyx_n > 1) {
            __pyx_v_timeout = __pyx_optional_args->timeout;
          }
        }
      }
      /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire)) {
            __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_blocking); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
            __pyx_t_6 = 0;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
              if (likely(__pyx_t_5)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_4, function);
                __pyx_t_6 = 1;
              }
            }
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout};
              __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6);
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_7;
            __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_type_dict_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_XDECREF(__pyx_t_5);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1000;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_success);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(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_11__semaphore_9Semaphore_14acquire, "Semaphore.acquire(self, bool blocking=True, timeout=None) -> bool\n\n        acquire(blocking=True, timeout=None) -> bool\n\n        Acquire the semaphore.\n\n        .. note:: If this semaphore was initialized with a *value* of 0,\n           this method will block forever (unless a timeout is given or blocking is\n           set to false).\n\n        :keyword bool blocking: If True (the default), this function will block\n           until the semaphore is acquired.\n        :keyword float timeout: If given, and *blocking* is true,\n           specifies the maximum amount of seconds\n           this method will block.\n        :return: A `bool` indicating whether the semaphore was acquired.\n           If ``blocking`` is True and ``timeout`` is None (the default), then\n           (so long as this semaphore was initialized with a size greater than 0)\n           this will always return True. If a timeout was given, and it expired before\n           the semaphore was acquired, False will be returned. (Note that this can still\n           raise a ``Timeout`` exception, if some other caller had already started a timer.)\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_15acquire = {"acquire", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_14acquire};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(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
    ) {
      int __pyx_v_blocking;
      PyObject *__pyx_v_timeout = 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("acquire (wrapper)", 0);
      {
        #if CYTHON_COMPILING_IN_LIMITED_API
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,&__pyx_n_s_timeout,0};
        #else
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,&__pyx_n_s_timeout,0};
        #endif
        PyObject* values[2] = {0,0};
        values[1] = ((PyObject *)Py_None);
        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 (kw_args > 0) {
              PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_blocking);
              if (value) { values[0] = value; kw_args--; }
              else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  1:
            if (kw_args > 0) {
              PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_timeout);
              if (value) { values[1] = value; kw_args--; }
              else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 131, __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, "acquire") < 0)) __PYX_ERR(0, 131, __pyx_L3_error)
          }
        } else {
          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;
          }
        }
        if (values[0]) {
          __pyx_v_blocking = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L3_error)
        } else {
          __pyx_v_blocking = ((int)1);
        }
        __pyx_v_timeout = values[1];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 131, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_14acquire(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_blocking, __pyx_v_timeout);

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_14acquire(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("acquire", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2.__pyx_n = 2;
      __pyx_t_2.blocking = __pyx_v_blocking;
      __pyx_t_2.timeout = __pyx_v_timeout;
      __pyx_t_1 = __pyx_vtabptr_6gevent_11__semaphore_Semaphore->acquire(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 131, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__15 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_blocking, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__15);
      __Pyx_GIVEREF(__pyx_tuple__15);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_15acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_acquire, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_15acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_acquire, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_acquire, 131, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 131, __pyx_L1_error)

     132:         """

     133:         acquire(blocking=True, timeout=None) -> bool

     134:

     135:         Acquire the semaphore.

     136:

     137:         .. note:: If this semaphore was initialized with a *value* of 0,

     138:            this method will block forever (unless a timeout is given or blocking is

     139:            set to false).

     140:

     141:         :keyword bool blocking: If True (the default), this function will block

     142:            until the semaphore is acquired.

     143:         :keyword float timeout: If given, and *blocking* is true,

     144:            specifies the maximum amount of seconds

     145:            this method will block.

     146:         :return: A `bool` indicating whether the semaphore was acquired.

     147:            If ``blocking`` is True and ``timeout`` is None (the default), then

     148:            (so long as this semaphore was initialized with a size greater than 0)

     149:            this will always return True. If a timeout was given, and it expired before

     150:            the semaphore was acquired, False will be returned. (Note that this can still

     151:            raise a ``Timeout`` exception, if some other caller had already started a timer.)

     152:         """

    +153:         if self.counter > 0:

      __pyx_t_7 = ((__pyx_v_self->counter > 0) != 0);
      if (__pyx_t_7) {
    /* … */
      }

    +154:             self.counter -= 1

        __pyx_v_self->counter = (__pyx_v_self->counter - 1);

    +155:             return True

        __pyx_r = 1;
        goto __pyx_L0;

     156:

    +157:         if not blocking:

      __pyx_t_7 = ((!(__pyx_v_blocking != 0)) != 0);
      if (__pyx_t_7) {
    /* … */
      }

    +158:             return False

        __pyx_r = 0;
        goto __pyx_L0;

     159:

    +160:         success = self._wait(timeout)

      __pyx_t_8.__pyx_n = 1;
      __pyx_t_8.timeout = __pyx_v_timeout;
      __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._wait(((struct __pyx_obj_6gevent_19__abstract_linkable_AbstractLinkable *)__pyx_v_self), &__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_success = __pyx_t_1;
      __pyx_t_1 = 0;

    +161:         if not success:

      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_success); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 161, __pyx_L1_error)
      __pyx_t_9 = ((!__pyx_t_7) != 0);
      if (__pyx_t_9) {
    /* … */
      }

     162:             # Our timer expired.

    +163:             return False

        __pyx_r = 0;
        goto __pyx_L0;

     164:

     165:         # Neither our timer no another one expired, so we blocked until

     166:         # awoke. Therefore, the counter is ours

    +167:         self.counter -= 1

      __pyx_v_self->counter = (__pyx_v_self->counter - 1);

    +168:         assert self.counter >= 0

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_self->counter >= 0) != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 168, __pyx_L1_error)
        }
      }
      #endif

    +169:         return True

      __pyx_r = 1;
      goto __pyx_L0;

     170:

    +171:     _py3k_acquire = acquire # PyPy needs this; it must be static for Cython

        __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore, __pyx_n_s_acquire); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_py3k_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_py3k_acquire, __pyx_t_2) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);

     172:

    +173:     def __enter__(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static PyObject *__pyx_f_6gevent_11__semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__enter__", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_17__enter__)) {
            __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, 173, __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_type_dict_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.__semaphore.Semaphore.__enter__", __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_11__semaphore_9Semaphore_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_9Semaphore_16__enter__, "Semaphore.__enter__(self)");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_17__enter__ = {"__enter__", (PyCFunction)__pyx_pw_6gevent_11__semaphore_9Semaphore_17__enter__, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_9Semaphore_16__enter__};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17__enter__(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("__enter__ (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_16__enter__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_16__enter__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__enter__", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore___enter__(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __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.__semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__17 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__17);
      __Pyx_GIVEREF(__pyx_tuple__17);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_17__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___enter, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_17__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___enter, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_enter, __pyx_t_2) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_enter, __pyx_t_2) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_enter, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 173, __pyx_L1_error)

    +174:         self.acquire()

      __pyx_t_6 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->acquire(__pyx_v_self, 0, NULL); if (unlikely(__pyx_t_6 == ((int)-1000))) __PYX_ERR(0, 174, __pyx_L1_error)

     175:

    +176:     def __exit__(self, t, v, tb):

    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__(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_11__semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__exit__", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__)) {
            __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[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb};
              __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 3+__pyx_t_5);
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __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_type_dict_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.__semaphore.Semaphore.__exit__", __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_11__semaphore_9Semaphore_19__exit__(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_11__semaphore_9Semaphore_18__exit__, "Semaphore.__exit__(self, t, v, tb)");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_19__exit__ = {"__exit__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_18__exit__};
    static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__(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_t = 0;
      PyObject *__pyx_v_v = 0;
      PyObject *__pyx_v_tb = 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("__exit__ (wrapper)", 0);
      {
        #if CYTHON_COMPILING_IN_LIMITED_API
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0};
        #else
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,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_t)) != 0)) kw_args--;
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 176, __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_v)) != 0)) kw_args--;
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 176, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_tb)) != 0)) kw_args--;
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 176, __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, "__exit__") < 0)) __PYX_ERR(0, 176, __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_t = values[0];
        __pyx_v_v = values[1];
        __pyx_v_tb = values[2];
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 176, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_6gevent_11__semaphore_9Semaphore_18__exit__(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb);

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_9Semaphore_18__exit__(struct __pyx_obj_6gevent_11__semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__exit__", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore___exit__(__pyx_v_self, __pyx_v_t, __pyx_v_v, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __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.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__19 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__19);
      __Pyx_GIVEREF(__pyx_tuple__19);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_19__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___exit, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_9Semaphore_19__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___exit, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_exit, __pyx_t_2) < 0) __PYX_ERR(0, 176, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_exit, __pyx_t_2) < 0) __PYX_ERR(0, 176, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_Semaphore);
      __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__semaphore_py, __pyx_n_s_exit, 176, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 176, __pyx_L1_error)

    +177:         self.release()

      __pyx_t_6 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->release(__pyx_v_self, 0); if (unlikely(__pyx_t_6 == ((int)-1000))) __PYX_ERR(0, 177, __pyx_L1_error)

     178:

     179:

    +180: class BoundedSemaphore(Semaphore):

    struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore {
      struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore __pyx_base;
    };
    static struct __pyx_vtabstruct_6gevent_11__semaphore_BoundedSemaphore *__pyx_vtabptr_6gevent_11__semaphore_BoundedSemaphore;

     181:     """

     182:     BoundedSemaphore(value=1) -> BoundedSemaphore

     183:

     184:     A bounded semaphore checks to make sure its current value doesn't

     185:     exceed its initial value. If it does, :class:`ValueError` is

     186:     raised. In most situations semaphores are used to guard resources

     187:     with limited capacity. If the semaphore is released too many times

     188:     it's a sign of a bug.

     189:

     190:     If not given, *value* defaults to 1.

     191:     """

     192:

     193:     #: For monkey-patching, allow changing the class of error we raise

    +194:     _OVER_RELEASE_ERROR = ValueError

        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_builtin_ValueError);
        if (PyModule_AddObject(__pyx_m, __pyx_k_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
        #endif
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore);

     195:

    +196:     def __init__(self, *args, **kwargs):

    /* Python wrapper */
    static int __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static int __pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyObject *__pyx_v_args = 0;
      PyObject *__pyx_v_kwargs = 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 (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
      if (unlikely(__pyx_kwds)) {
        __pyx_v_kwargs = __Pyx_KwargsAsDict_VARARGS(__pyx_kwds, __pyx_kwvalues);
        if (unlikely(!__pyx_v_kwargs)) return -1;
        __Pyx_GOTREF(__pyx_v_kwargs);
      } else {
        __pyx_v_kwargs = NULL;
      }
      __Pyx_INCREF(__pyx_args);
      __pyx_v_args = __pyx_args;
      __pyx_r = __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore___init__(((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

      /* function exit code */
      __Pyx_DECREF(__pyx_v_args);
      __Pyx_XDECREF(__pyx_v_kwargs);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static int __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
      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.__semaphore.BoundedSemaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +197:         Semaphore.__init__(self, *args, **kwargs)

      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF((PyObject *)__pyx_v_self);
      __Pyx_GIVEREF((PyObject *)__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
      __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __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;

    +198:         self._initial_value = self.counter

      __pyx_t_4 = __pyx_v_self->__pyx_base.counter;
      __pyx_v_self->_initial_value = __pyx_t_4;

     199:

    +200:     def release(self):

    static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    static int __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch) {
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("release", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (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_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          #endif
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release)) {
            __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, 200, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_r = __pyx_t_6;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L0;
          }
          #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
          __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
          __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
          if (unlikely(__pyx_type_dict_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.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1000;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
    PyDoc_STRVAR(__pyx_doc_6gevent_11__semaphore_16BoundedSemaphore_2release, "BoundedSemaphore.release(self) -> int\n\n        Like :meth:`Semaphore.release`, but raises :class:`ValueError`\n        if the semaphore is being over-released.\n        ");
    static PyMethodDef __pyx_mdef_6gevent_11__semaphore_16BoundedSemaphore_3release = {"release", (PyCFunction)__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release, METH_NOARGS, __pyx_doc_6gevent_11__semaphore_16BoundedSemaphore_2release};
    static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(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("release (wrapper)", 0);
      __pyx_r = __pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_2release(((struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *)__pyx_v_self));

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

    static PyObject *__pyx_pf_6gevent_11__semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_11__semaphore_BoundedSemaphore *__pyx_v_self) {
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("release", 0);
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("gevent.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__21);
      __Pyx_GIVEREF(__pyx_tuple__21);
    /* … */
        #if CYTHON_COMPILING_IN_LIMITED_API
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_16BoundedSemaphore_3release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BoundedSemaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_t_1, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        #else
        __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_11__semaphore_16BoundedSemaphore_3release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BoundedSemaphore_release, NULL, __pyx_n_s_gevent___semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
        #endif
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_release, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
        #else
        if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        PyType_Modified(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore);

     201:         """

     202:         Like :meth:`Semaphore.release`, but raises :class:`ValueError`

     203:         if the semaphore is being over-released.

     204:         """

    +205:         if self.counter >= self._initial_value:

      __pyx_t_7 = ((__pyx_v_self->__pyx_base.counter >= __pyx_v_self->_initial_value) != 0);
      if (unlikely(__pyx_t_7)) {
    /* … */
      }

    +206:             raise self._OVER_RELEASE_ERROR("Semaphore released too many times")

        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_OVER_RELEASE_ERROR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = NULL;
        __pyx_t_6 = 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_6 = 1;
          }
        }
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_s_Semaphore_released_too_many_time};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 206, __pyx_L1_error)

    +207:         return Semaphore.release(self)

      __pyx_t_8 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), 1); if (unlikely(__pyx_t_8 == ((int)-1000))) __PYX_ERR(0, 207, __pyx_L1_error)
      __pyx_r = __pyx_t_8;
      goto __pyx_L0;

     208:

     209:

     210:

     211: # By building the semaphore with Cython under PyPy, we get

     212: # atomic operations (specifically, exiting/releasing), at the

     213: # cost of some speed (one trivial semaphore micro-benchmark put the pure-python version

     214: # at around 1s and the compiled version at around 4s). Some clever subclassing

     215: # and having only the bare minimum be in cython might help reduce that penalty.

     216: # NOTE: You must use version 0.23.4 or later to avoid a memory leak.

     217: # https://mail.python.org/pipermail/cython-devel/2015-October/004571.html

     218: # However, that's all for naught on up to and including PyPy 4.0.1 which

     219: # have some serious crashing bugs with GC interacting with cython.

     220: # It hasn't been tested since then, and PURE_PYTHON is assumed to be true

     221: # for PyPy in all cases anyway, so this does nothing.

     222:

    +223: from gevent._util import import_c_accel

        __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __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, 223, __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, 223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #if CYTHON_COMPILING_IN_LIMITED_API
        __Pyx_INCREF(__pyx_t_2);
        if (PyModule_AddObject(__pyx_m, __pyx_k_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 223, __pyx_L1_error)
        #else
        if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 223, __pyx_L1_error)
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +224: import_c_accel(globals(), 'gevent.__semaphore')

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __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_n_s_gevent___semaphore);
        __Pyx_GIVEREF(__pyx_n_s_gevent___semaphore);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_gevent___semaphore);
        __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, 224, __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;