Server IP : 85.214.239.14 / Your IP : 3.145.110.145 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /srv/modoboa/env/lib64/python3.5/site-packages/gevent/ |
Upload File : |
<!DOCTYPE html> <!-- Generated by Cython 0.29.2 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Cython: _semaphore.py</title> <style type="text/css"> body.cython { font-family: courier; font-size: 12; } .cython.tag { } .cython.line { margin: 0em } .cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; } .cython.line .run { background-color: #B0FFB0; } .cython.line .mis { background-color: #FFB0B0; } .cython.code.run { border-left: 8px solid #B0FFB0; } .cython.code.mis { border-left: 8px solid #FFB0B0; } .cython.code .py_c_api { color: red; } .cython.code .py_macro_api { color: #FF7000; } .cython.code .pyx_c_api { color: #FF3000; } .cython.code .pyx_macro_api { color: #FF7000; } .cython.code .refnanny { color: #FFA000; } .cython.code .trace { color: #FFA000; } .cython.code .error_goto { color: #FFA000; } .cython.code .coerce { color: #008000; border: 1px dotted #008000 } .cython.code .py_attr { color: #FF0000; font-weight: bold; } .cython.code .c_attr { color: #0000FF; } .cython.code .py_call { color: #FF0000; font-weight: bold; } .cython.code .c_call { color: #0000FF; } .cython.score-0 {background-color: #FFFFff;} .cython.score-1 {background-color: #FFFFe7;} .cython.score-2 {background-color: #FFFFd4;} .cython.score-3 {background-color: #FFFFc4;} .cython.score-4 {background-color: #FFFFb6;} .cython.score-5 {background-color: #FFFFaa;} .cython.score-6 {background-color: #FFFF9f;} .cython.score-7 {background-color: #FFFF96;} .cython.score-8 {background-color: #FFFF8d;} .cython.score-9 {background-color: #FFFF86;} .cython.score-10 {background-color: #FFFF7f;} .cython.score-11 {background-color: #FFFF79;} .cython.score-12 {background-color: #FFFF73;} .cython.score-13 {background-color: #FFFF6e;} .cython.score-14 {background-color: #FFFF6a;} .cython.score-15 {background-color: #FFFF66;} .cython.score-16 {background-color: #FFFF62;} .cython.score-17 {background-color: #FFFF5e;} .cython.score-18 {background-color: #FFFF5b;} .cython.score-19 {background-color: #FFFF57;} .cython.score-20 {background-color: #FFFF55;} .cython.score-21 {background-color: #FFFF52;} .cython.score-22 {background-color: #FFFF4f;} .cython.score-23 {background-color: #FFFF4d;} .cython.score-24 {background-color: #FFFF4b;} .cython.score-25 {background-color: #FFFF48;} .cython.score-26 {background-color: #FFFF46;} .cython.score-27 {background-color: #FFFF44;} .cython.score-28 {background-color: #FFFF43;} .cython.score-29 {background-color: #FFFF41;} .cython.score-30 {background-color: #FFFF3f;} .cython.score-31 {background-color: #FFFF3e;} .cython.score-32 {background-color: #FFFF3c;} .cython.score-33 {background-color: #FFFF3b;} .cython.score-34 {background-color: #FFFF39;} .cython.score-35 {background-color: #FFFF38;} .cython.score-36 {background-color: #FFFF37;} .cython.score-37 {background-color: #FFFF36;} .cython.score-38 {background-color: #FFFF35;} .cython.score-39 {background-color: #FFFF34;} .cython.score-40 {background-color: #FFFF33;} .cython.score-41 {background-color: #FFFF32;} .cython.score-42 {background-color: #FFFF31;} .cython.score-43 {background-color: #FFFF30;} .cython.score-44 {background-color: #FFFF2f;} .cython.score-45 {background-color: #FFFF2e;} .cython.score-46 {background-color: #FFFF2d;} .cython.score-47 {background-color: #FFFF2c;} .cython.score-48 {background-color: #FFFF2b;} .cython.score-49 {background-color: #FFFF2b;} .cython.score-50 {background-color: #FFFF2a;} .cython.score-51 {background-color: #FFFF29;} .cython.score-52 {background-color: #FFFF29;} .cython.score-53 {background-color: #FFFF28;} .cython.score-54 {background-color: #FFFF27;} .cython.score-55 {background-color: #FFFF27;} .cython.score-56 {background-color: #FFFF26;} .cython.score-57 {background-color: #FFFF26;} .cython.score-58 {background-color: #FFFF25;} .cython.score-59 {background-color: #FFFF24;} .cython.score-60 {background-color: #FFFF24;} .cython.score-61 {background-color: #FFFF23;} .cython.score-62 {background-color: #FFFF23;} .cython.score-63 {background-color: #FFFF22;} .cython.score-64 {background-color: #FFFF22;} .cython.score-65 {background-color: #FFFF22;} .cython.score-66 {background-color: #FFFF21;} .cython.score-67 {background-color: #FFFF21;} .cython.score-68 {background-color: #FFFF20;} .cython.score-69 {background-color: #FFFF20;} .cython.score-70 {background-color: #FFFF1f;} .cython.score-71 {background-color: #FFFF1f;} .cython.score-72 {background-color: #FFFF1f;} .cython.score-73 {background-color: #FFFF1e;} .cython.score-74 {background-color: #FFFF1e;} .cython.score-75 {background-color: #FFFF1e;} .cython.score-76 {background-color: #FFFF1d;} .cython.score-77 {background-color: #FFFF1d;} .cython.score-78 {background-color: #FFFF1c;} .cython.score-79 {background-color: #FFFF1c;} .cython.score-80 {background-color: #FFFF1c;} .cython.score-81 {background-color: #FFFF1c;} .cython.score-82 {background-color: #FFFF1b;} .cython.score-83 {background-color: #FFFF1b;} .cython.score-84 {background-color: #FFFF1b;} .cython.score-85 {background-color: #FFFF1a;} .cython.score-86 {background-color: #FFFF1a;} .cython.score-87 {background-color: #FFFF1a;} .cython.score-88 {background-color: #FFFF1a;} .cython.score-89 {background-color: #FFFF19;} .cython.score-90 {background-color: #FFFF19;} .cython.score-91 {background-color: #FFFF19;} .cython.score-92 {background-color: #FFFF19;} .cython.score-93 {background-color: #FFFF18;} .cython.score-94 {background-color: #FFFF18;} .cython.score-95 {background-color: #FFFF18;} .cython.score-96 {background-color: #FFFF18;} .cython.score-97 {background-color: #FFFF17;} .cython.score-98 {background-color: #FFFF17;} .cython.score-99 {background-color: #FFFF17;} .cython.score-100 {background-color: #FFFF17;} .cython.score-101 {background-color: #FFFF16;} .cython.score-102 {background-color: #FFFF16;} .cython.score-103 {background-color: #FFFF16;} .cython.score-104 {background-color: #FFFF16;} .cython.score-105 {background-color: #FFFF16;} .cython.score-106 {background-color: #FFFF15;} .cython.score-107 {background-color: #FFFF15;} .cython.score-108 {background-color: #FFFF15;} .cython.score-109 {background-color: #FFFF15;} .cython.score-110 {background-color: #FFFF15;} .cython.score-111 {background-color: #FFFF15;} .cython.score-112 {background-color: #FFFF14;} .cython.score-113 {background-color: #FFFF14;} .cython.score-114 {background-color: #FFFF14;} .cython.score-115 {background-color: #FFFF14;} .cython.score-116 {background-color: #FFFF14;} .cython.score-117 {background-color: #FFFF14;} .cython.score-118 {background-color: #FFFF13;} .cython.score-119 {background-color: #FFFF13;} .cython.score-120 {background-color: #FFFF13;} .cython.score-121 {background-color: #FFFF13;} .cython.score-122 {background-color: #FFFF13;} .cython.score-123 {background-color: #FFFF13;} .cython.score-124 {background-color: #FFFF13;} .cython.score-125 {background-color: #FFFF12;} .cython.score-126 {background-color: #FFFF12;} .cython.score-127 {background-color: #FFFF12;} .cython.score-128 {background-color: #FFFF12;} .cython.score-129 {background-color: #FFFF12;} .cython.score-130 {background-color: #FFFF12;} .cython.score-131 {background-color: #FFFF12;} .cython.score-132 {background-color: #FFFF11;} .cython.score-133 {background-color: #FFFF11;} .cython.score-134 {background-color: #FFFF11;} .cython.score-135 {background-color: #FFFF11;} .cython.score-136 {background-color: #FFFF11;} .cython.score-137 {background-color: #FFFF11;} .cython.score-138 {background-color: #FFFF11;} .cython.score-139 {background-color: #FFFF11;} .cython.score-140 {background-color: #FFFF11;} .cython.score-141 {background-color: #FFFF10;} .cython.score-142 {background-color: #FFFF10;} .cython.score-143 {background-color: #FFFF10;} .cython.score-144 {background-color: #FFFF10;} .cython.score-145 {background-color: #FFFF10;} .cython.score-146 {background-color: #FFFF10;} .cython.score-147 {background-color: #FFFF10;} .cython.score-148 {background-color: #FFFF10;} .cython.score-149 {background-color: #FFFF10;} .cython.score-150 {background-color: #FFFF0f;} .cython.score-151 {background-color: #FFFF0f;} .cython.score-152 {background-color: #FFFF0f;} .cython.score-153 {background-color: #FFFF0f;} .cython.score-154 {background-color: #FFFF0f;} .cython.score-155 {background-color: #FFFF0f;} .cython.score-156 {background-color: #FFFF0f;} .cython.score-157 {background-color: #FFFF0f;} .cython.score-158 {background-color: #FFFF0f;} .cython.score-159 {background-color: #FFFF0f;} .cython.score-160 {background-color: #FFFF0f;} .cython.score-161 {background-color: #FFFF0e;} .cython.score-162 {background-color: #FFFF0e;} .cython.score-163 {background-color: #FFFF0e;} .cython.score-164 {background-color: #FFFF0e;} .cython.score-165 {background-color: #FFFF0e;} .cython.score-166 {background-color: #FFFF0e;} .cython.score-167 {background-color: #FFFF0e;} .cython.score-168 {background-color: #FFFF0e;} .cython.score-169 {background-color: #FFFF0e;} .cython.score-170 {background-color: #FFFF0e;} .cython.score-171 {background-color: #FFFF0e;} .cython.score-172 {background-color: #FFFF0e;} .cython.score-173 {background-color: #FFFF0d;} .cython.score-174 {background-color: #FFFF0d;} .cython.score-175 {background-color: #FFFF0d;} .cython.score-176 {background-color: #FFFF0d;} .cython.score-177 {background-color: #FFFF0d;} .cython.score-178 {background-color: #FFFF0d;} .cython.score-179 {background-color: #FFFF0d;} .cython.score-180 {background-color: #FFFF0d;} .cython.score-181 {background-color: #FFFF0d;} .cython.score-182 {background-color: #FFFF0d;} .cython.score-183 {background-color: #FFFF0d;} .cython.score-184 {background-color: #FFFF0d;} .cython.score-185 {background-color: #FFFF0d;} .cython.score-186 {background-color: #FFFF0d;} .cython.score-187 {background-color: #FFFF0c;} .cython.score-188 {background-color: #FFFF0c;} .cython.score-189 {background-color: #FFFF0c;} .cython.score-190 {background-color: #FFFF0c;} .cython.score-191 {background-color: #FFFF0c;} .cython.score-192 {background-color: #FFFF0c;} .cython.score-193 {background-color: #FFFF0c;} .cython.score-194 {background-color: #FFFF0c;} .cython.score-195 {background-color: #FFFF0c;} .cython.score-196 {background-color: #FFFF0c;} .cython.score-197 {background-color: #FFFF0c;} .cython.score-198 {background-color: #FFFF0c;} .cython.score-199 {background-color: #FFFF0c;} .cython.score-200 {background-color: #FFFF0c;} .cython.score-201 {background-color: #FFFF0c;} .cython.score-202 {background-color: #FFFF0c;} .cython.score-203 {background-color: #FFFF0b;} .cython.score-204 {background-color: #FFFF0b;} .cython.score-205 {background-color: #FFFF0b;} .cython.score-206 {background-color: #FFFF0b;} .cython.score-207 {background-color: #FFFF0b;} .cython.score-208 {background-color: #FFFF0b;} .cython.score-209 {background-color: #FFFF0b;} .cython.score-210 {background-color: #FFFF0b;} .cython.score-211 {background-color: #FFFF0b;} .cython.score-212 {background-color: #FFFF0b;} .cython.score-213 {background-color: #FFFF0b;} .cython.score-214 {background-color: #FFFF0b;} .cython.score-215 {background-color: #FFFF0b;} .cython.score-216 {background-color: #FFFF0b;} .cython.score-217 {background-color: #FFFF0b;} .cython.score-218 {background-color: #FFFF0b;} .cython.score-219 {background-color: #FFFF0b;} .cython.score-220 {background-color: #FFFF0b;} .cython.score-221 {background-color: #FFFF0b;} .cython.score-222 {background-color: #FFFF0a;} .cython.score-223 {background-color: #FFFF0a;} .cython.score-224 {background-color: #FFFF0a;} .cython.score-225 {background-color: #FFFF0a;} .cython.score-226 {background-color: #FFFF0a;} .cython.score-227 {background-color: #FFFF0a;} .cython.score-228 {background-color: #FFFF0a;} .cython.score-229 {background-color: #FFFF0a;} .cython.score-230 {background-color: #FFFF0a;} .cython.score-231 {background-color: #FFFF0a;} .cython.score-232 {background-color: #FFFF0a;} .cython.score-233 {background-color: #FFFF0a;} .cython.score-234 {background-color: #FFFF0a;} .cython.score-235 {background-color: #FFFF0a;} .cython.score-236 {background-color: #FFFF0a;} .cython.score-237 {background-color: #FFFF0a;} .cython.score-238 {background-color: #FFFF0a;} .cython.score-239 {background-color: #FFFF0a;} .cython.score-240 {background-color: #FFFF0a;} .cython.score-241 {background-color: #FFFF0a;} .cython.score-242 {background-color: #FFFF0a;} .cython.score-243 {background-color: #FFFF0a;} .cython.score-244 {background-color: #FFFF0a;} .cython.score-245 {background-color: #FFFF0a;} .cython.score-246 {background-color: #FFFF09;} .cython.score-247 {background-color: #FFFF09;} .cython.score-248 {background-color: #FFFF09;} .cython.score-249 {background-color: #FFFF09;} .cython.score-250 {background-color: #FFFF09;} .cython.score-251 {background-color: #FFFF09;} .cython.score-252 {background-color: #FFFF09;} .cython.score-253 {background-color: #FFFF09;} .cython.score-254 {background-color: #FFFF09;} </style> </head> <body class="cython"> <p><span style="border-bottom: solid 1px grey;">Generated by Cython 0.29.2</span></p> <p> <span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br /> Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it. </p> <p>Raw output: <a href="_semaphore.c">_semaphore.c</a></p> <div class="cython"><pre class="cython line score-8" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">001</span>: # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False</pre> <pre class='cython code score-8 '> __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyDict_NewPresized</span>(0);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; </pre><pre class="cython line score-0"> <span class="">002</span>: from __future__ import print_function, absolute_import, division</pre> <pre class="cython line score-0"> <span class="">003</span>: </pre> <pre class="cython line score-15" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">004</span>: __all__ = [</pre> <pre class='cython code score-15 '> __pyx_t_1 = <span class='py_c_api'>PyList_New</span>(2);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Semaphore); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Semaphore); <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_Semaphore); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_BoundedSemaphore); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_BoundedSemaphore); <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 1, __pyx_n_s_BoundedSemaphore); if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) <span class='error_goto'>__PYX_ERR(0, 4, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-0"> <span class="">005</span>: 'Semaphore',</pre> <pre class="cython line score-0"> <span class="">006</span>: 'BoundedSemaphore',</pre> <pre class="cython line score-0"> <span class="">007</span>: ]</pre> <pre class="cython line score-0"> <span class="">008</span>: </pre> <pre class="cython line score-20" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">009</span>: def _get_linkable():</pre> <pre class='cython code score-20 '>/* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_1_get_linkable(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_get_linkable (wrapper)", 0); __pyx_r = __pyx_pf_6gevent_11__semaphore__get_linkable(__pyx_self); /* function exit code */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_get_linkable", 0); /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore._get_linkable", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_x); <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__3 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_x);<span class='error_goto'> if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 9, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__3); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__3); /* … */ __pyx_t_1 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_get_linkable, __pyx_t_1) < 0) <span class='error_goto'>__PYX_ERR(0, 9, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; __pyx_codeobj__4 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(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);<span class='error_goto'> if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 9, __pyx_L1_error)</span> </pre><pre class="cython line score-7" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">010</span>: x = __import__('gevent._abstract_linkable')</pre> <pre class='cython code score-7 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin___import__, __pyx_tuple_, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_v_x = __pyx_t_1; __pyx_t_1 = 0; /* … */ __pyx_tuple_ = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_s_gevent__abstract_linkable);<span class='error_goto'> if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 10, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple_); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple_); </pre><pre class="cython line score-6" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">011</span>: return x._abstract_linkable.AbstractLinkable</pre> <pre class='cython code score-6 '> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_x, __pyx_n_s_abstract_linkable);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_AbstractLinkable);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; </pre><pre class="cython line score-14" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">012</span>: locals()['AbstractLinkable'] = _get_linkable()</pre> <pre class='cython code score-14 '> <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_1, __pyx_n_s_get_linkable);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = <span class='pyx_c_api'>__Pyx_Globals</span>();<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (unlikely(<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_1, __pyx_n_s_AbstractLinkable, __pyx_t_2) < 0)) <span class='error_goto'>__PYX_ERR(0, 12, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; </pre><pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">013</span>: del _get_linkable</pre> <pre class='cython code score-2 '> if (<span class='pyx_c_api'>__Pyx_PyObject_DelAttrStr</span>(__pyx_m, __pyx_n_s_get_linkable) < 0) <span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">014</span>: </pre> <pre class="cython line score-0"> <span class="">015</span>: </pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">016</span>: class Semaphore(AbstractLinkable): # pylint:disable=undefined-variable</pre> <pre class='cython code score-0 '>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; </pre><pre class="cython line score-0"> <span class="">017</span>: """</pre> <pre class="cython line score-0"> <span class="">018</span>: Semaphore(value=1) -> Semaphore</pre> <pre class="cython line score-0"> <span class="">019</span>: </pre> <pre class="cython line score-0"> <span class="">020</span>: A semaphore manages a counter representing the number of release()</pre> <pre class="cython line score-0"> <span class="">021</span>: calls minus the number of acquire() calls, plus an initial value.</pre> <pre class="cython line score-0"> <span class="">022</span>: The acquire() method blocks if necessary until it can return</pre> <pre class="cython line score-0"> <span class="">023</span>: without making the counter negative.</pre> <pre class="cython line score-0"> <span class="">024</span>: </pre> <pre class="cython line score-0"> <span class="">025</span>: If not given, ``value`` defaults to 1.</pre> <pre class="cython line score-0"> <span class="">026</span>: </pre> <pre class="cython line score-0"> <span class="">027</span>: The semaphore is a context manager and can be used in ``with`` statements.</pre> <pre class="cython line score-0"> <span class="">028</span>: </pre> <pre class="cython line score-0"> <span class="">029</span>: This Semaphore's ``__exit__`` method does not call the trace function</pre> <pre class="cython line score-0"> <span class="">030</span>: on CPython, but does under PyPy.</pre> <pre class="cython line score-0"> <span class="">031</span>: </pre> <pre class="cython line score-0"> <span class="">032</span>: .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents</pre> <pre class="cython line score-0"> <span class="">033</span>: some classes of bugs.</pre> <pre class="cython line score-0"> <span class="">034</span>: </pre> <pre class="cython line score-0"> <span class="">035</span>: .. versionchanged:: 1.4.0</pre> <pre class="cython line score-0"> <span class="">036</span>: </pre> <pre class="cython line score-0"> <span class="">037</span>: The order in which waiters are awakened is not specified. It was not</pre> <pre class="cython line score-0"> <span class="">038</span>: specified previously, but usually went in FIFO order.</pre> <pre class="cython line score-0"> <span class="">039</span>: """</pre> <pre class="cython line score-0"> <span class="">040</span>: </pre> <pre class="cython line score-23" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">041</span>: def __init__(self, value=1):</pre> <pre class='cython code score-23 '>/* 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; int __pyx_r; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)__pyx_int_1); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args); switch (pos_args) { case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_value); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) <span class='error_goto'>__PYX_ERR(0, 41, __pyx_L3_error)</span> } } else { switch (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)) { case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_value = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("__init__", 0, 0, 1, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); <span class='error_goto'>__PYX_ERR(0, 41, __pyx_L3_error)</span> __pyx_L3_error:; <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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); /* function exit code */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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) { int __pyx_r; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } </pre><pre class="cython line score-8" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">042</span>: if value < 0:</pre> <pre class='cython code score-8 '> __pyx_t_1 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_v_value, __pyx_int_0, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)</span> __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) <span class='error_goto'>__PYX_ERR(0, 42, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ } </pre><pre class="cython line score-10" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">043</span>: raise ValueError("semaphore initial value must be >= 0")</pre> <pre class='cython code score-10 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__2, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_1, 0, 0, 0); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; <span class='error_goto'>__PYX_ERR(0, 43, __pyx_L1_error)</span> /* … */ __pyx_tuple__2 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_s_semaphore_initial_value_must_be);<span class='error_goto'> if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 43, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__2); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__2); </pre><pre class="cython line score-32" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">044</span>: super(Semaphore, self).__init__()</pre> <pre class='cython code score-32 '> __pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(2);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore)); <span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore)); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore)); <span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_self)); <span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_self)); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1, ((PyObject *)__pyx_v_self)); __pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_super, __pyx_t_3, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_init);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) <span class='error_goto'>__PYX_ERR(0, 44, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-7" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">045</span>: self.counter = value</pre> <pre class='cython code score-7 '> __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_v_value); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 45, __pyx_L1_error)</span> __pyx_v_self->counter = __pyx_t_5; </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">046</span>: self._notify_all = False</pre> <pre class='cython code score-0 '> __pyx_v_self->__pyx_base._notify_all = 0; </pre><pre class="cython line score-0"> <span class="">047</span>: </pre> <pre class="cython line score-8" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">048</span>: def __str__(self):</pre> <pre class='cython code score-8 '>/* 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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__str__", 0); /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_params); <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } </pre><pre class="cython line score-33" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">049</span>: params = (self.__class__.__name__, self.counter, self.linkcount())</pre> <pre class='cython code score-33 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_class);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_name);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_self->counter);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_linkcount);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) { __pyx_t_5 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_5); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_5) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_4, __pyx_t_5) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) <span class='error_goto'>__PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(3);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_2); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 1, __pyx_t_1); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__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; </pre><pre class="cython line score-3" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">050</span>: return '<%s counter=%s _links[%s]>' % params</pre> <pre class='cython code score-3 '> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyString_Format</span>(__pyx_kp_s_s_counter_s__links_s, __pyx_v_params);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">051</span>: </pre> <pre class="cython line score-71" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">052</span>: def locked(self):</pre> <pre class='cython code score-71 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_locked);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked)) { <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_WriteUnraisable</span>("gevent.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_9Semaphore_4locked[] = "Semaphore.locked(self) -> bool\nReturn a boolean indicating whether the semaphore can be acquired.\n Most useful with binary semaphores."; 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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("locked", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyBool_FromLong</span>(__pyx_f_6gevent_11__semaphore_9Semaphore_locked(__pyx_v_self, 1));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__5 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__5); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__5); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_locked, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 52, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__6 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 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, 52, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 52, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">053</span>: """Return a boolean indicating whether the semaphore can be acquired.</pre> <pre class="cython line score-0"> <span class="">054</span>: Most useful with binary semaphores."""</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">055</span>: return self.counter <= 0</pre> <pre class='cython code score-0 '> __pyx_r = (__pyx_v_self->counter <= 0); goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">056</span>: </pre> <pre class="cython line score-71" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">057</span>: def release(self):</pre> <pre class='cython code score-71 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_release);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_7release)) { <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_9Semaphore_6release[] = "Semaphore.release(self) -> int\n\n Release the semaphore, notifying any waiters if needed.\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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("release", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(__pyx_v_self, 1);<span class='error_goto'> if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 57, __pyx_L1_error)</span> __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__7 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__7); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__7); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 57, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__8 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 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, 57, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 57, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">058</span>: """</pre> <pre class="cython line score-0"> <span class="">059</span>: Release the semaphore, notifying any waiters if needed.</pre> <pre class="cython line score-0"> <span class="">060</span>: """</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">061</span>: self.counter += 1</pre> <pre class='cython code score-0 '> __pyx_v_self->counter = (__pyx_v_self->counter + 1); </pre><pre class="cython line score-1" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">062</span>: self._check_and_notify()</pre> <pre class='cython code score-1 '> __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));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">063</span>: return self.counter</pre> <pre class='cython code score-0 '> __pyx_r = __pyx_v_self->counter; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">064</span>: </pre> <pre class="cython line score-71" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">065</span>: def ready(self):</pre> <pre class='cython code score-71 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_ready);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready)) { <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_WriteUnraisable</span>("gevent.__semaphore.Semaphore.ready", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_9ready(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_9Semaphore_8ready[] = "Semaphore.ready(self) -> bool"; 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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("ready", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyBool_FromLong</span>(__pyx_f_6gevent_11__semaphore_9Semaphore_ready(__pyx_v_self, 1));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.ready", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__9 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__9); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__9); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_ready, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 65, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__10 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 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, 65, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 65, __pyx_L1_error)</span> </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">066</span>: return self.counter > 0</pre> <pre class='cython code score-0 '> __pyx_r = (__pyx_v_self->counter > 0); goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">067</span>: </pre> <pre class="cython line score-63" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">068</span>: def _start_notify(self):</pre> <pre class='cython code score-63 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_start_notify);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__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)) { <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; <span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_None); goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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*/ static char __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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_start_notify", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore__start_notify(__pyx_v_self, 1);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__11 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__11); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__11); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_start_notify, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 68, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__12 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 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, 68, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 68, __pyx_L1_error)</span> </pre><pre class="cython line score-1" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">069</span>: self._check_and_notify()</pre> <pre class='cython code score-1 '> __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));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-0"> <span class="">070</span>: </pre> <pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">071</span>: def _wait_return_value(self, waited, wait_success):</pre> <pre class='cython code score-2 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("_wait_return_value", 0); /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore._wait_return_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } </pre><pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">072</span>: if waited:</pre> <pre class='cython code score-2 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_waited); if (unlikely(__pyx_t_1 < 0)) <span class='error_goto'>__PYX_ERR(0, 72, __pyx_L1_error)</span> if (__pyx_t_1) { /* … */ } </pre><pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">073</span>: return wait_success</pre> <pre class='cython code score-2 '> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_wait_success); __pyx_r = __pyx_v_wait_success; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">074</span>: # We didn't even wait, we must be good to go.</pre> <pre class="cython line score-0"> <span class="">075</span>: # XXX: This is probably dead code, we're careful not to go into the wait</pre> <pre class="cython line score-0"> <span class="">076</span>: # state if we don't expect to need to</pre> <pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">077</span>: return True</pre> <pre class='cython code score-2 '> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); <span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_True); __pyx_r = Py_True; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">078</span>: </pre> <pre class="cython line score-87" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">079</span>: def wait(self, timeout=None):</pre> <pre class='cython code score-87 '>static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_wait);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait)) { <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_timeout) : <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_v_timeout); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_9Semaphore_12wait[] = "Semaphore.wait(self, timeout=None) -> int\n\n wait(timeout=None) -> int\n\n Wait until it is possible to acquire this semaphore, or until the optional\n *timeout* elapses.\n\n .. caution:: If this semaphore was initialized with a size 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.\n "; static PyMethodDef __pyx_mdef_6gevent_11__semaphore_9Semaphore_13wait = {"wait", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_12wait}; static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_13wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_timeout = 0; PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("wait (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args); switch (pos_args) { case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_timeout); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) <span class='error_goto'>__PYX_ERR(0, 79, __pyx_L3_error)</span> } } else { switch (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)) { case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__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:; <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("wait", 0, 0, 1, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); <span class='error_goto'>__PYX_ERR(0, 79, __pyx_L3_error)</span> __pyx_L3_error:; <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("wait", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__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);<span class='error_goto'> if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 79, __pyx_L1_error)</span> __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__13 = <span class='py_c_api'>PyTuple_Pack</span>(2, __pyx_n_s_self, __pyx_n_s_timeout);<span class='error_goto'> if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__13); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__13); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_wait, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 79, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__14 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(2, 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, 79, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 79, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">080</span>: """</pre> <pre class="cython line score-0"> <span class="">081</span>: wait(timeout=None) -> int</pre> <pre class="cython line score-0"> <span class="">082</span>: </pre> <pre class="cython line score-0"> <span class="">083</span>: Wait until it is possible to acquire this semaphore, or until the optional</pre> <pre class="cython line score-0"> <span class="">084</span>: *timeout* elapses.</pre> <pre class="cython line score-0"> <span class="">085</span>: </pre> <pre class="cython line score-0"> <span class="">086</span>: .. caution:: If this semaphore was initialized with a size of 0,</pre> <pre class="cython line score-0"> <span class="">087</span>: this method will block forever if no timeout is given.</pre> <pre class="cython line score-0"> <span class="">088</span>: </pre> <pre class="cython line score-0"> <span class="">089</span>: :keyword float timeout: If given, specifies the maximum amount of seconds</pre> <pre class="cython line score-0"> <span class="">090</span>: this method will block.</pre> <pre class="cython line score-0"> <span class="">091</span>: :return: A number indicating how many times the semaphore can be acquired</pre> <pre class="cython line score-0"> <span class="">092</span>: before blocking.</pre> <pre class="cython line score-0"> <span class="">093</span>: """</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">094</span>: if self.counter > 0:</pre> <pre class='cython code score-0 '> __pyx_t_6 = ((__pyx_v_self->counter > 0) != 0); if (__pyx_t_6) { /* … */ } </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">095</span>: return self.counter</pre> <pre class='cython code score-0 '> __pyx_r = __pyx_v_self->counter; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">096</span>: </pre> <pre class="cython line score-1" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">097</span>: self._wait(timeout) # return value irrelevant, whether we got it or got a timeout</pre> <pre class='cython code score-1 '> __pyx_t_7.__pyx_n = 1; __pyx_t_7.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_7);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">098</span>: return self.counter</pre> <pre class='cython code score-0 '> __pyx_r = __pyx_v_self->counter; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">099</span>: </pre> <pre class="cython line score-127" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">100</span>: def acquire(self, blocking=True, timeout=None):</pre> <pre class='cython code score-127 '>static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_acquire);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__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 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_blocking);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) { __pyx_t_5 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_5); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout}; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0; <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout}; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0; <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_6);<span class='error_goto'> if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7); if (__pyx_t_5) { <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_5); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_timeout); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_timeout); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1+__pyx_t_6, __pyx_v_timeout); __pyx_t_3 = 0; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_7, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0; } <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_8; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_success); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_9Semaphore_14acquire[] = "Semaphore.acquire(self, int blocking=True, timeout=None) -> bool\n\n acquire(blocking=True, timeout=None) -> bool\n\n Acquire the semaphore.\n\n .. caution:: If this semaphore was initialized with a size 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, specifies the maximum amount of seconds\n this method will block.\n :return: A boolean 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*)(PyCFunctionWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_14acquire}; static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_15acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_blocking; PyObject *__pyx_v_timeout = 0; PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("acquire (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,&__pyx_n_s_timeout,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args); switch (pos_args) { case 2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_blocking); if (value) { values[0] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_timeout); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) <span class='error_goto'>__PYX_ERR(0, 100, __pyx_L3_error)</span> } } else { switch (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)) { case 2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } if (values[0]) { __pyx_v_blocking = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 100, __pyx_L3_error)</span> } else { __pyx_v_blocking = ((int)1); } __pyx_v_timeout = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("acquire", 0, 0, 2, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); <span class='error_goto'>__PYX_ERR(0, 100, __pyx_L3_error)</span> __pyx_L3_error:; <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("acquire", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__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);<span class='error_goto'> if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 100, __pyx_L1_error)</span> __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyBool_FromLong</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__15 = <span class='py_c_api'>PyTuple_Pack</span>(3, __pyx_n_s_self, __pyx_n_s_blocking, __pyx_n_s_timeout);<span class='error_goto'> if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__15); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__15); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_acquire, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 100, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__16 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(3, 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, 100, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 100, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">101</span>: """</pre> <pre class="cython line score-0"> <span class="">102</span>: acquire(blocking=True, timeout=None) -> bool</pre> <pre class="cython line score-0"> <span class="">103</span>: </pre> <pre class="cython line score-0"> <span class="">104</span>: Acquire the semaphore.</pre> <pre class="cython line score-0"> <span class="">105</span>: </pre> <pre class="cython line score-0"> <span class="">106</span>: .. caution:: If this semaphore was initialized with a size of 0,</pre> <pre class="cython line score-0"> <span class="">107</span>: this method will block forever (unless a timeout is given or blocking is</pre> <pre class="cython line score-0"> <span class="">108</span>: set to false).</pre> <pre class="cython line score-0"> <span class="">109</span>: </pre> <pre class="cython line score-0"> <span class="">110</span>: :keyword bool blocking: If True (the default), this function will block</pre> <pre class="cython line score-0"> <span class="">111</span>: until the semaphore is acquired.</pre> <pre class="cython line score-0"> <span class="">112</span>: :keyword float timeout: If given, specifies the maximum amount of seconds</pre> <pre class="cython line score-0"> <span class="">113</span>: this method will block.</pre> <pre class="cython line score-0"> <span class="">114</span>: :return: A boolean indicating whether the semaphore was acquired.</pre> <pre class="cython line score-0"> <span class="">115</span>: If ``blocking`` is True and ``timeout`` is None (the default), then</pre> <pre class="cython line score-0"> <span class="">116</span>: (so long as this semaphore was initialized with a size greater than 0)</pre> <pre class="cython line score-0"> <span class="">117</span>: this will always return True. If a timeout was given, and it expired before</pre> <pre class="cython line score-0"> <span class="">118</span>: the semaphore was acquired, False will be returned. (Note that this can still</pre> <pre class="cython line score-0"> <span class="">119</span>: raise a ``Timeout`` exception, if some other caller had already started a timer.)</pre> <pre class="cython line score-0"> <span class="">120</span>: """</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">121</span>: if self.counter > 0:</pre> <pre class='cython code score-0 '> __pyx_t_8 = ((__pyx_v_self->counter > 0) != 0); if (__pyx_t_8) { /* … */ } </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">122</span>: self.counter -= 1</pre> <pre class='cython code score-0 '> __pyx_v_self->counter = (__pyx_v_self->counter - 1); </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">123</span>: return True</pre> <pre class='cython code score-0 '> __pyx_r = 1; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">124</span>: </pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">125</span>: if not blocking:</pre> <pre class='cython code score-0 '> __pyx_t_8 = ((!(__pyx_v_blocking != 0)) != 0); if (__pyx_t_8) { /* … */ } </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">126</span>: return False</pre> <pre class='cython code score-0 '> __pyx_r = 0; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">127</span>: </pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">128</span>: success = self._wait(timeout)</pre> <pre class='cython code score-0 '> __pyx_t_9.__pyx_n = 1; __pyx_t_9.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_9);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_v_success = __pyx_t_1; __pyx_t_1 = 0; </pre><pre class="cython line score-2" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">129</span>: if not success:</pre> <pre class='cython code score-2 '> __pyx_t_8 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_success); if (unlikely(__pyx_t_8 < 0)) <span class='error_goto'>__PYX_ERR(0, 129, __pyx_L1_error)</span> __pyx_t_10 = ((!__pyx_t_8) != 0); if (__pyx_t_10) { /* … */ } </pre><pre class="cython line score-0"> <span class="">130</span>: # Our timer expired.</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">131</span>: return False</pre> <pre class='cython code score-0 '> __pyx_r = 0; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">132</span>: </pre> <pre class="cython line score-0"> <span class="">133</span>: # Neither our timer no another one expired, so we blocked until</pre> <pre class="cython line score-0"> <span class="">134</span>: # awoke. Therefore, the counter is ours</pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">135</span>: self.counter -= 1</pre> <pre class='cython code score-0 '> __pyx_v_self->counter = (__pyx_v_self->counter - 1); </pre><pre class="cython line score-5" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">136</span>: assert self.counter >= 0</pre> <pre class='cython code score-5 '> #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->counter >= 0) != 0))) { <span class='py_c_api'>PyErr_SetNone</span>(PyExc_AssertionError); <span class='error_goto'>__PYX_ERR(0, 136, __pyx_L1_error)</span> } } #endif </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">137</span>: return True</pre> <pre class='cython code score-0 '> __pyx_r = 1; goto __pyx_L0; </pre><pre class="cython line score-0"> <span class="">138</span>: </pre> <pre class="cython line score-13" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">139</span>: _py3k_acquire = acquire # PyPy needs this; it must be static for Cython</pre> <pre class='cython code score-13 '> <span class='pyx_c_api'>__Pyx_GetNameInClass</span>(__pyx_t_2, (PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore, __pyx_n_s_acquire);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_py3k_acquire, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 139, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); </pre><pre class="cython line score-0"> <span class="">140</span>: </pre> <pre class="cython line score-63" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">141</span>: def __enter__(self):</pre> <pre class='cython code score-63 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_enter);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__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__)) { <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; <span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_None); goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__enter__", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_11__semaphore_9Semaphore___enter__(__pyx_v_self, 1);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__17 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__17); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__17); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_enter, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 141, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__18 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 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, 141, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 141, __pyx_L1_error)</span> </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">142</span>: self.acquire()</pre> <pre class='cython code score-0 '> __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->acquire(__pyx_v_self, 0, NULL);<span class='error_goto'> if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 142, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">143</span>: </pre> <pre class="cython line score-117" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">144</span>: def __exit__(self, t, v, tb):</pre> <pre class='cython code score-117 '>static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_exit);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__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__)) { <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb}; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb}; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); } else #endif { __pyx_t_6 = <span class='py_c_api'>PyTuple_New</span>(3+__pyx_t_5);<span class='error_goto'> if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6); if (__pyx_t_4) { <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_t); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_t); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 0+__pyx_t_5, __pyx_v_t); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_v); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_v); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 1+__pyx_t_5, __pyx_v_v); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_tb); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_tb); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb); __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_6, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0; } <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; <span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_None); goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __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*)(PyCFunctionWithKeywords)__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_11__semaphore_9Semaphore_18__exit__}; static PyObject *__pyx_pw_6gevent_11__semaphore_9Semaphore_19__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_t = 0; PyObject *__pyx_v_v = 0; PyObject *__pyx_v_tb = 0; PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__exit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args); switch (pos_args) { case 3: values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--; else { <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("__exit__", 1, 3, 3, 1); <span class='error_goto'>__PYX_ERR(0, 144, __pyx_L3_error)</span> } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = <span class='pyx_c_api'>__Pyx_PyDict_GetItemStr</span>(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; else { <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("__exit__", 1, 3, 3, 2); <span class='error_goto'>__PYX_ERR(0, 144, __pyx_L3_error)</span> } } if (unlikely(kw_args > 0)) { if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) <span class='error_goto'>__PYX_ERR(0, 144, __pyx_L3_error)</span> } } else if (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0); values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1); values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__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:; <span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("__exit__", 1, 3, 3, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); <span class='error_goto'>__PYX_ERR(0, 144, __pyx_L3_error)</span> __pyx_L3_error:; <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__exit__", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__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);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__19 = <span class='py_c_api'>PyTuple_Pack</span>(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb);<span class='error_goto'> if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__19); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__19); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore->tp_dict, __pyx_n_s_exit, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 144, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_Semaphore); __pyx_codeobj__20 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(4, 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, 144, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 144, __pyx_L1_error)</span> </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">145</span>: self.release()</pre> <pre class='cython code score-0 '> __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_11__semaphore_Semaphore *)__pyx_v_self->__pyx_base.__pyx_vtab)->release(__pyx_v_self, 0);<span class='error_goto'> if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 145, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">146</span>: </pre> <pre class="cython line score-0"> <span class="">147</span>: </pre> <pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">148</span>: class BoundedSemaphore(Semaphore):</pre> <pre class='cython code score-0 '>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; </pre><pre class="cython line score-0"> <span class="">149</span>: """</pre> <pre class="cython line score-0"> <span class="">150</span>: BoundedSemaphore(value=1) -> BoundedSemaphore</pre> <pre class="cython line score-0"> <span class="">151</span>: </pre> <pre class="cython line score-0"> <span class="">152</span>: A bounded semaphore checks to make sure its current value doesn't</pre> <pre class="cython line score-0"> <span class="">153</span>: exceed its initial value. If it does, :class:`ValueError` is</pre> <pre class="cython line score-0"> <span class="">154</span>: raised. In most situations semaphores are used to guard resources</pre> <pre class="cython line score-0"> <span class="">155</span>: with limited capacity. If the semaphore is released too many times</pre> <pre class="cython line score-0"> <span class="">156</span>: it's a sign of a bug.</pre> <pre class="cython line score-0"> <span class="">157</span>: </pre> <pre class="cython line score-0"> <span class="">158</span>: If not given, *value* defaults to 1.</pre> <pre class="cython line score-0"> <span class="">159</span>: """</pre> <pre class="cython line score-0"> <span class="">160</span>: </pre> <pre class="cython line score-0"> <span class="">161</span>: #: For monkey-patching, allow changing the class of error we raise</pre> <pre class="cython line score-10" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">162</span>: _OVER_RELEASE_ERROR = ValueError</pre> <pre class='cython code score-10 '> if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) <span class='error_goto'>__PYX_ERR(0, 162, __pyx_L1_error)</span> <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore); </pre><pre class="cython line score-0"> <span class="">163</span>: </pre> <pre class="cython line score-15" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">164</span>: def __init__(self, *args, **kwargs):</pre> <pre class='cython code score-15 '>/* 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; int __pyx_r; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__init__ (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(!<span class='pyx_c_api'>__Pyx_CheckKeywordStrings</span>(__pyx_kwds, "__init__", 1))) return -1; if (unlikely(__pyx_kwds)) { __pyx_v_kwargs = <span class='py_c_api'>PyDict_Copy</span>(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1; <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_v_kwargs); } else { __pyx_v_kwargs = NULL; } <span class='pyx_macro_api'>__Pyx_INCREF</span>(__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 */ <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_args); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_kwargs); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("__init__", 0); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.BoundedSemaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } </pre><pre class="cython line score-20" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">165</span>: Semaphore.__init__(self, *args, **kwargs)</pre> <pre class='cython code score-20 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_ptype_6gevent_11__semaphore_Semaphore), __pyx_n_s_init);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_self)); <span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_self)); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __pyx_t_3 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_2, __pyx_v_args);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">166</span>: self._initial_value = self.counter</pre> <pre class='cython code score-0 '> __pyx_t_4 = __pyx_v_self->__pyx_base.counter; __pyx_v_self->_initial_value = __pyx_t_4; </pre><pre class="cython line score-0"> <span class="">167</span>: </pre> <pre class="cython line score-69" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">168</span>: def release(self):</pre> <pre class='cython code score-69 '>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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0; if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self)))))); else { PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; #endif __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_release);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release)) { <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) { __pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) <span class='error_goto'>__PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_5; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0; obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_<span class='py_c_api'>PyObject_GetDictPtr</span>(((PyObject *)__pyx_v_self))) : 0; if (unlikely(type_dict_guard != tp_dict_version)) { tp_dict_version = obj_dict_version = 0; } #endif <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP } #endif } /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1000; __pyx_L0:; <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6gevent_11__semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6gevent_11__semaphore_16BoundedSemaphore_2release[] = "BoundedSemaphore.release(self) -> int"; 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) { PyObject *__pyx_r = 0; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("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 */ <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); 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; <span class='refnanny'>__Pyx_RefNannyDeclarations</span> <span class='refnanny'>__Pyx_RefNannySetupContext</span>("release", 0); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r); __pyx_t_1 = __pyx_f_6gevent_11__semaphore_16BoundedSemaphore_release(__pyx_v_self, 1);<span class='error_goto'> if (unlikely(__pyx_t_1 == ((int)-1000))) __PYX_ERR(0, 168, __pyx_L1_error)</span> __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_t_1);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); <span class='pyx_c_api'>__Pyx_AddTraceback</span>("gevent.__semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r); <span class='refnanny'>__Pyx_RefNannyFinishContext</span>(); return __pyx_r; } /* … */ __pyx_tuple__21 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_s_self);<span class='error_goto'> if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__21); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__21); /* … */ __pyx_t_2 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__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));<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>((PyObject *)__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_release, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 168, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='py_c_api'>PyType_Modified</span>(__pyx_ptype_6gevent_11__semaphore_BoundedSemaphore); </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">169</span>: if self.counter >= self._initial_value:</pre> <pre class='cython code score-0 '> __pyx_t_6 = ((__pyx_v_self->__pyx_base.counter >= __pyx_v_self->_initial_value) != 0); if (unlikely(__pyx_t_6)) { /* … */ } </pre><pre class="cython line score-19" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">170</span>: raise self._OVER_RELEASE_ERROR("Semaphore released too many times")</pre> <pre class='cython code score-19 '> __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_self), __pyx_n_s_OVER_RELEASE_ERROR);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) { __pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3); <span class='pyx_macro_api'>__Pyx_INCREF</span>(function); <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s_Semaphore_released_too_many_time) : <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, __pyx_kp_s_Semaphore_released_too_many_time); <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) <span class='error_goto'>__PYX_ERR(0, 170, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_1, 0, 0, 0); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; <span class='error_goto'>__PYX_ERR(0, 170, __pyx_L1_error)</span> </pre><pre class="cython line score-0" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">171</span>: Semaphore.release(self)</pre> <pre class='cython code score-0 '> __pyx_t_5 = __pyx_f_6gevent_11__semaphore_9Semaphore_release(((struct __pyx_obj_6gevent_11__semaphore_Semaphore *)__pyx_v_self), 1);<span class='error_goto'> if (unlikely(__pyx_t_5 == ((int)-1000))) __PYX_ERR(0, 171, __pyx_L1_error)</span> </pre><pre class="cython line score-0"> <span class="">172</span>: </pre> <pre class="cython line score-0"> <span class="">173</span>: </pre> <pre class="cython line score-0"> <span class="">174</span>: </pre> <pre class="cython line score-0"> <span class="">175</span>: # By building the semaphore with Cython under PyPy, we get</pre> <pre class="cython line score-0"> <span class="">176</span>: # atomic operations (specifically, exiting/releasing), at the</pre> <pre class="cython line score-0"> <span class="">177</span>: # cost of some speed (one trivial semaphore micro-benchmark put the pure-python version</pre> <pre class="cython line score-0"> <span class="">178</span>: # at around 1s and the compiled version at around 4s). Some clever subclassing</pre> <pre class="cython line score-0"> <span class="">179</span>: # and having only the bare minimum be in cython might help reduce that penalty.</pre> <pre class="cython line score-0"> <span class="">180</span>: # NOTE: You must use version 0.23.4 or later to avoid a memory leak.</pre> <pre class="cython line score-0"> <span class="">181</span>: # https://mail.python.org/pipermail/cython-devel/2015-October/004571.html</pre> <pre class="cython line score-0"> <span class="">182</span>: # However, that's all for naught on up to and including PyPy 4.0.1 which</pre> <pre class="cython line score-0"> <span class="">183</span>: # have some serious crashing bugs with GC interacting with cython.</pre> <pre class="cython line score-0"> <span class="">184</span>: # It hasn't been tested since then, and PURE_PYTHON is assumed to be true</pre> <pre class="cython line score-0"> <span class="">185</span>: # for PyPy in all cases anyway, so this does nothing.</pre> <pre class="cython line score-0"> <span class="">186</span>: </pre> <pre class="cython line score-19" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">187</span>: from gevent._util import import_c_accel</pre> <pre class='cython code score-19 '> __pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_import_c_accel); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_import_c_accel); <span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_import_c_accel); __pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_gevent__util, __pyx_t_2, 0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_import_c_accel);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) <span class='error_goto'>__PYX_ERR(0, 187, __pyx_L1_error)</span> <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; </pre><pre class="cython line score-17" onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<span class="">188</span>: import_c_accel(globals(), 'gevent.__semaphore')</pre> <pre class='cython code score-17 '> <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_1, __pyx_n_s_import_c_accel);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1); __pyx_t_2 = <span class='pyx_c_api'>__Pyx_Globals</span>();<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); __pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(2);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_2); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_gevent___semaphore); <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_gevent___semaphore); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1, __pyx_n_s_gevent___semaphore); __pyx_t_2 = 0; __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_1, __pyx_t_3, NULL);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)</span> <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2); <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0; <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0; </pre></div></body></html>