diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-07-12 23:40:30 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-07-12 23:41:07 -0700 |
commit | c3b9f8c4582882cd1f768b0727eca75475bb4f94 (patch) | |
tree | 5b4a1c693fd5b7416f1d5a75862e633502e77ca7 | |
parent | fe9fe8257740529f5880693992e4eeca35c7ea3e (diff) | |
download | yt-local-c3b9f8c4582882cd1f768b0727eca75475bb4f94.tar.lz yt-local-c3b9f8c4582882cd1f768b0727eca75475bb4f94.tar.xz yt-local-c3b9f8c4582882cd1f768b0727eca75475bb4f94.zip |
track embedded python distribution
80 files changed, 81288 insertions, 6 deletions
@@ -1,12 +1,6 @@ __pycache__/ *.py[cod] *$py.class -youtube_dl_old/ -python/ -gevent/ debug/ data/ banned_addresses.txt -youtube/common_old.py -youtube/common_older.py -youtube/watch_old.py diff --git a/python/brotli.py b/python/brotli.py new file mode 100644 index 0000000..d66966b --- /dev/null +++ b/python/brotli.py @@ -0,0 +1,56 @@ +# Copyright 2016 The Brotli Authors. All rights reserved. +# +# Distributed under MIT license. +# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + +"""Functions to compress and decompress data using the Brotli library.""" + +import _brotli + + +# The library version. +__version__ = _brotli.__version__ + +# The compression mode. +MODE_GENERIC = _brotli.MODE_GENERIC +MODE_TEXT = _brotli.MODE_TEXT +MODE_FONT = _brotli.MODE_FONT + +# The Compressor object. +Compressor = _brotli.Compressor + +# The Decompressor object. +Decompressor = _brotli.Decompressor + +# Compress a byte string. +def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0): + """Compress a byte string. + + Args: + string (bytes): The input data. + mode (int, optional): The compression mode can be MODE_GENERIC (default), + MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0). + quality (int, optional): Controls the compression-speed vs compression- + density tradeoff. The higher the quality, the slower the compression. + Range is 0 to 11. Defaults to 11. + lgwin (int, optional): Base 2 logarithm of the sliding window size. Range + is 10 to 24. Defaults to 22. + lgblock (int, optional): Base 2 logarithm of the maximum input block size. + Range is 16 to 24. If set to 0, the value will be set based on the + quality. Defaults to 0. + + Returns: + The compressed byte string. + + Raises: + brotli.error: If arguments are invalid, or compressor fails. + """ + compressor = Compressor(mode=mode, quality=quality, lgwin=lgwin, + lgblock=lgblock) + return compressor.process(string) + compressor.finish() + +# Decompress a compressed byte string. +decompress = _brotli.decompress + +# Raised if compression or decompression fails. +error = _brotli.error diff --git a/python/gevent/__init__.py b/python/gevent/__init__.py new file mode 100644 index 0000000..65041cc --- /dev/null +++ b/python/gevent/__init__.py @@ -0,0 +1,136 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +""" +gevent is a coroutine-based Python networking library that uses greenlet +to provide a high-level synchronous API on top of libev event loop. + +See http://www.gevent.org/ for the documentation. +""" + +from __future__ import absolute_import + +from collections import namedtuple + +_version_info = namedtuple('version_info', + ('major', 'minor', 'micro', 'releaselevel', 'serial')) + +#: The programatic version identifier. The fields have (roughly) the +#: same meaning as :data:`sys.version_info` +#: Deprecated in 1.2. +version_info = _version_info(1, 2, 2, 'dev', 0) + +#: The human-readable PEP 440 version identifier +__version__ = '1.2.2' + + +__all__ = ['get_hub', + 'Greenlet', + 'GreenletExit', + 'spawn', + 'spawn_later', + 'spawn_raw', + 'iwait', + 'wait', + 'killall', + 'Timeout', + 'with_timeout', + 'getcurrent', + 'sleep', + 'idle', + 'kill', + 'signal', + 'fork', + 'reinit'] + + +import sys +if sys.platform == 'win32': + # trigger WSAStartup call + import socket # pylint:disable=unused-import,useless-suppression + del socket + +from gevent.hub import get_hub, iwait, wait +from gevent.greenlet import Greenlet, joinall, killall +joinall = joinall # export for pylint +spawn = Greenlet.spawn +spawn_later = Greenlet.spawn_later + +from gevent.timeout import Timeout, with_timeout +from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, reinit +try: + from gevent.os import fork +except ImportError: + __all__.remove('fork') + +# See https://github.com/gevent/gevent/issues/648 +# A temporary backwards compatibility shim to enable users to continue +# to treat 'from gevent import signal' as a callable, to matter whether +# the 'gevent.signal' module has been imported first +from gevent.hub import signal as _signal_class +from gevent import signal as _signal_module + +# The object 'gevent.signal' must: +# - be callable, returning a gevent.hub.signal; +# - answer True to isinstance(gevent.signal(...), gevent.signal); +# - answer True to isinstance(gevent.signal(...), gevent.hub.signal) +# - have all the attributes of the module 'gevent.signal'; +# - answer True to isinstance(gevent.signal, types.ModuleType) (optional) + +# The only way to do this is to use a metaclass, an instance of which (a class) +# is put in sys.modules and is substituted for gevent.hub.signal. +# This handles everything except the last one. + + +class _signal_metaclass(type): + + def __getattr__(cls, name): + return getattr(_signal_module, name) + + def __setattr__(cls, name, value): + setattr(_signal_module, name, value) + + def __instancecheck__(cls, instance): + return isinstance(instance, _signal_class) + + def __dir__(cls): + return dir(_signal_module) + + +class signal(object): + + __doc__ = _signal_module.__doc__ + + def __new__(cls, *args, **kwargs): + return _signal_class(*args, **kwargs) + + +# The metaclass is applied after the class declaration +# for Python 2/3 compatibility +signal = _signal_metaclass(str("signal"), + (), + dict(signal.__dict__)) + +sys.modules['gevent.signal'] = signal +sys.modules['gevent.hub'].signal = signal + +del sys + + +# the following makes hidden imports visible to freezing tools like +# py2exe. see https://github.com/gevent/gevent/issues/181 + +def __dependencies_for_freezing(): + # pylint:disable=unused-variable + from gevent import core + from gevent import resolver_thread + from gevent import resolver_ares + from gevent import socket as _socket + from gevent import threadpool + from gevent import thread + from gevent import threading + from gevent import select + from gevent import subprocess + import pprint + import traceback + import signal as _signal + +del __dependencies_for_freezing diff --git a/python/gevent/_compat.py b/python/gevent/_compat.py new file mode 100644 index 0000000..96f5f93 --- /dev/null +++ b/python/gevent/_compat.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +""" +internal gevent python 2/python 3 bridges. Not for external use. +""" + +from __future__ import print_function, absolute_import, division + + +import sys + +PY2 = sys.version_info[0] == 2 +PY3 = sys.version_info[0] >= 3 +PYPY = hasattr(sys, 'pypy_version_info') + +## Types + +if PY3: + string_types = (str,) + integer_types = (int,) + text_type = str + +else: + import __builtin__ # pylint:disable=import-error + string_types = __builtin__.basestring, + text_type = __builtin__.unicode + integer_types = (int, __builtin__.long) + + +## Exceptions +if PY3: + def reraise(t, value, tb=None): # pylint:disable=unused-argument + if value.__traceback__ is not tb and tb is not None: + raise value.with_traceback(tb) + raise value + +else: + from gevent._util_py2 import reraise # pylint:disable=import-error,no-name-in-module + reraise = reraise # export + +## Functions +if PY3: + iteritems = dict.items + itervalues = dict.values + xrange = range +else: + iteritems = dict.iteritems # python 3: pylint:disable=no-member + itervalues = dict.itervalues # python 3: pylint:disable=no-member + xrange = __builtin__.xrange diff --git a/python/gevent/_fileobjectcommon.py b/python/gevent/_fileobjectcommon.py new file mode 100644 index 0000000..435f0d8 --- /dev/null +++ b/python/gevent/_fileobjectcommon.py @@ -0,0 +1,128 @@ + +try: + from errno import EBADF +except ImportError: + EBADF = 9 + +from io import TextIOWrapper + +class cancel_wait_ex(IOError): + + def __init__(self): + super(cancel_wait_ex, self).__init__( + EBADF, 'File descriptor was closed in another greenlet') + + +class FileObjectClosed(IOError): + + def __init__(self): + super(FileObjectClosed, self).__init__( + EBADF, 'Bad file descriptor (FileObject was closed)') + +class FileObjectBase(object): + """ + Internal base class to ensure a level of consistency + between FileObjectPosix and FileObjectThread + """ + + # List of methods we delegate to the wrapping IO object, if they + # implement them and we do not. + _delegate_methods = ( + # General methods + 'flush', + 'fileno', + 'writable', + 'readable', + 'seek', + 'seekable', + 'tell', + + # Read + 'read', + 'readline', + 'readlines', + 'read1', + + # Write + 'write', + 'writelines', + 'truncate', + ) + + + # Whether we are translating universal newlines or not. + _translate = False + + def __init__(self, io, closefd): + """ + :param io: An io.IOBase-like object. + """ + self._io = io + # We don't actually use this property ourself, but we save it (and + # pass it along) for compatibility. + self._close = closefd + + if self._translate: + # This automatically handles delegation. + self.translate_newlines(None) + else: + self._do_delegate_methods() + + + io = property(lambda s: s._io, + # Historically we either hand-wrote all the delegation methods + # to use self.io, or we simply used __getattr__ to look them up at + # runtime. This meant people could change the io attribute on the fly + # and it would mostly work (subprocess.py used to do that). We don't recommend + # that, but we still support it. + lambda s, nv: setattr(s, '_io', nv) or s._do_delegate_methods()) + + def _do_delegate_methods(self): + for meth_name in self._delegate_methods: + meth = getattr(self._io, meth_name, None) + implemented_by_class = hasattr(type(self), meth_name) + if meth and not implemented_by_class: + setattr(self, meth_name, self._wrap_method(meth)) + elif hasattr(self, meth_name) and not implemented_by_class: + delattr(self, meth_name) + + def _wrap_method(self, method): + """ + Wrap a method we're copying into our dictionary from the underlying + io object to do something special or different, if necessary. + """ + return method + + def translate_newlines(self, mode, *text_args, **text_kwargs): + wrapper = TextIOWrapper(self._io, *text_args, **text_kwargs) + if mode: + wrapper.mode = mode + self.io = wrapper + self._translate = True + + @property + def closed(self): + """True if the file is closed""" + return self._io is None + + def close(self): + if self._io is None: + return + + io = self._io + self._io = None + self._do_close(io, self._close) + + def _do_close(self, fobj, closefd): + raise NotImplementedError() + + def __getattr__(self, name): + if self._io is None: + raise FileObjectClosed() + return getattr(self._io, name) + + def __repr__(self): + return '<%s _fobj=%r%s>' % (self.__class__.__name__, self.io, self._extra_repr()) + + def _extra_repr(self): + return '' diff --git a/python/gevent/_fileobjectposix.py b/python/gevent/_fileobjectposix.py new file mode 100644 index 0000000..73551cf --- /dev/null +++ b/python/gevent/_fileobjectposix.py @@ -0,0 +1,285 @@ +from __future__ import absolute_import +import os +import io +from io import BufferedReader +from io import BufferedWriter +from io import BytesIO +from io import DEFAULT_BUFFER_SIZE +from io import RawIOBase +from io import UnsupportedOperation + +from gevent._fileobjectcommon import cancel_wait_ex +from gevent._fileobjectcommon import FileObjectBase +from gevent.hub import get_hub +from gevent.os import _read +from gevent.os import _write +from gevent.os import ignored_errors +from gevent.os import make_nonblocking + + +class GreenFileDescriptorIO(RawIOBase): + + # Note that RawIOBase has a __del__ method that calls + # self.close(). (In C implementations like CPython, this is + # the type's tp_dealloc slot; prior to Python 3, the object doesn't + # appear to have a __del__ method, even though it functionally does) + + _read_event = None + _write_event = None + + def __init__(self, fileno, mode='r', closefd=True): + RawIOBase.__init__(self) # Python 2: pylint:disable=no-member,non-parent-init-called + self._closed = False + self._closefd = closefd + self._fileno = fileno + make_nonblocking(fileno) + self._readable = 'r' in mode + self._writable = 'w' in mode + self.hub = get_hub() + + io_watcher = self.hub.loop.io + if self._readable: + self._read_event = io_watcher(fileno, 1) + + if self._writable: + self._write_event = io_watcher(fileno, 2) + + self._seekable = None + + def readable(self): + return self._readable + + def writable(self): + return self._writable + + def seekable(self): + if self._seekable is None: + try: + os.lseek(self._fileno, 0, os.SEEK_CUR) + except OSError: + self._seekable = False + else: + self._seekable = True + return self._seekable + + def fileno(self): + return self._fileno + + @property + def closed(self): + return self._closed + + def close(self): + if self._closed: + return + self.flush() + self._closed = True + if self._readable: + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + if self._writable: + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + fileno = self._fileno + if self._closefd: + self._fileno = None + os.close(fileno) + + # RawIOBase provides a 'read' method that will call readall() if + # the `size` was missing or -1 and otherwise call readinto(). We + # want to take advantage of this to avoid single byte reads when + # possible. This is highlighted by a bug in BufferedIOReader that + # calls read() in a loop when its readall() method is invoked; + # this was fixed in Python 3.3. See + # https://github.com/gevent/gevent/issues/675) + def __read(self, n): + if not self._readable: + raise UnsupportedOperation('read') + while True: + try: + return _read(self._fileno, n) + except (IOError, OSError) as ex: + if ex.args[0] not in ignored_errors: + raise + self.hub.wait(self._read_event) + + def readall(self): + ret = BytesIO() + while True: + data = self.__read(DEFAULT_BUFFER_SIZE) + if not data: + break + ret.write(data) + return ret.getvalue() + + def readinto(self, b): + data = self.__read(len(b)) + n = len(data) + try: + b[:n] = data + except TypeError as err: + import array + if not isinstance(b, array.array): + raise err + b[:n] = array.array(b'b', data) + return n + + def write(self, b): + if not self._writable: + raise UnsupportedOperation('write') + while True: + try: + return _write(self._fileno, b) + except (IOError, OSError) as ex: + if ex.args[0] not in ignored_errors: + raise + self.hub.wait(self._write_event) + + def seek(self, offset, whence=0): + return os.lseek(self._fileno, offset, whence) + +class FlushingBufferedWriter(BufferedWriter): + + def write(self, b): + ret = BufferedWriter.write(self, b) + self.flush() + return ret + +class FileObjectPosix(FileObjectBase): + """ + A file-like object that operates on non-blocking files but + provides a synchronous, cooperative interface. + + .. caution:: + This object is only effective wrapping files that can be used meaningfully + with :func:`select.select` such as sockets and pipes. + + In general, on most platforms, operations on regular files + (e.g., ``open('a_file.txt')``) are considered non-blocking + already, even though they can take some time to complete as + data is copied to the kernel and flushed to disk: this time + is relatively bounded compared to sockets or pipes, though. + A :func:`~os.read` or :func:`~os.write` call on such a file + will still effectively block for some small period of time. + Therefore, wrapping this class around a regular file is + unlikely to make IO gevent-friendly: reading or writing large + amounts of data could still block the event loop. + + If you'll be working with regular files and doing IO in large + chunks, you may consider using + :class:`~gevent.fileobject.FileObjectThread` or + :func:`~gevent.os.tp_read` and :func:`~gevent.os.tp_write` to bypass this + concern. + + .. note:: + Random read/write (e.g., ``mode='rwb'``) is not supported. + For that, use :class:`io.BufferedRWPair` around two instance of this + class. + + .. tip:: + Although this object provides a :meth:`fileno` method and so + can itself be passed to :func:`fcntl.fcntl`, setting the + :data:`os.O_NONBLOCK` flag will have no effect (reads will + still block the greenlet, although other greenlets can run). + However, removing that flag *will cause this object to no + longer be cooperative* (other greenlets will no longer run). + + You can use the internal ``fileio`` attribute of this object + (a :class:`io.RawIOBase`) to perform non-blocking byte reads. + Note, however, that once you begin directly using this + attribute, the results from using methods of *this* object + are undefined, especially in text mode. (See :issue:`222`.) + + .. versionchanged:: 1.1 + Now uses the :mod:`io` package internally. Under Python 2, previously + used the undocumented class :class:`socket._fileobject`. This provides + better file-like semantics (and portability to Python 3). + .. versionchanged:: 1.2a1 + Document the ``fileio`` attribute for non-blocking reads. + """ + + #: platform specific default for the *bufsize* parameter + default_bufsize = io.DEFAULT_BUFFER_SIZE + + def __init__(self, fobj, mode='rb', bufsize=-1, close=True): + """ + :param fobj: Either an integer fileno, or an object supporting the + usual :meth:`socket.fileno` method. The file *will* be + put in non-blocking mode using :func:`gevent.os.make_nonblocking`. + :keyword str mode: The manner of access to the file, one of "rb", "rU" or "wb" + (where the "b" or "U" can be omitted). + If "U" is part of the mode, IO will be done on text, otherwise bytes. + :keyword int bufsize: If given, the size of the buffer to use. The default + value means to use a platform-specific default + Other values are interpreted as for the :mod:`io` package. + Buffering is ignored in text mode. + + .. versionchanged:: 1.2a1 + + A bufsize of 0 in write mode is no longer forced to be 1. + Instead, the underlying buffer is flushed after every write + operation to simulate a bufsize of 0. In gevent 1.0, a + bufsize of 0 was flushed when a newline was written, while + in gevent 1.1 it was flushed when more than one byte was + written. Note that this may have performance impacts. + """ + + if isinstance(fobj, int): + fileno = fobj + fobj = None + else: + fileno = fobj.fileno() + if not isinstance(fileno, int): + raise TypeError('fileno must be int: %r' % fileno) + + orig_mode = mode + mode = (mode or 'rb').replace('b', '') + if 'U' in mode: + self._translate = True + mode = mode.replace('U', '') + else: + self._translate = False + + if len(mode) != 1 and mode not in 'rw': # pragma: no cover + # Python 3 builtin `open` raises a ValueError for invalid modes; + # Python 2 ignores it. In the past, we raised an AssertionError, if __debug__ was + # enabled (which it usually was). Match Python 3 because it makes more sense + # and because __debug__ may not be enabled. + # NOTE: This is preventing a mode like 'rwb' for binary random access; + # that code was never tested and was explicitly marked as "not used" + raise ValueError('mode can only be [rb, rU, wb], not %r' % (orig_mode,)) + + self._fobj = fobj + + # This attribute is documented as available for non-blocking reads. + self.fileio = GreenFileDescriptorIO(fileno, mode, closefd=close) + + self._orig_bufsize = bufsize + if bufsize < 0 or bufsize == 1: + bufsize = self.default_bufsize + elif bufsize == 0: + bufsize = 1 + + if mode == 'r': + IOFamily = BufferedReader + else: + assert mode == 'w' + IOFamily = BufferedWriter + if self._orig_bufsize == 0: + # We could also simply pass self.fileio as *io*, but this way + # we at least consistently expose a BufferedWriter in our *io* + # attribute. + IOFamily = FlushingBufferedWriter + + super(FileObjectPosix, self).__init__(IOFamily(self.fileio, bufsize), close) + + def _do_close(self, fobj, closefd): + try: + fobj.close() + # self.fileio already knows whether or not to close the + # file descriptor + self.fileio.close() + finally: + self._fobj = None + self.fileio = None + + def __iter__(self): + return self._io diff --git a/python/gevent/_semaphore.pxd b/python/gevent/_semaphore.pxd new file mode 100644 index 0000000..6382d56 --- /dev/null +++ b/python/gevent/_semaphore.pxd @@ -0,0 +1,23 @@ +cdef class Semaphore: + cdef public int counter + cdef readonly object _links + cdef readonly object _notifier + cdef public int _dirty + cdef object __weakref__ + + cpdef bint locked(self) + cpdef int release(self) except -1000 + cpdef rawlink(self, object callback) + cpdef unlink(self, object callback) + cpdef _start_notify(self) + cpdef _notify_links(self) + cdef _do_wait(self, object timeout) + cpdef int wait(self, object timeout=*) except -1000 + cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 + cpdef __enter__(self) + cpdef __exit__(self, object t, object v, object tb) + +cdef class BoundedSemaphore(Semaphore): + cdef readonly int _initial_value + + cpdef int release(self) except -1000 diff --git a/python/gevent/_semaphore.py b/python/gevent/_semaphore.py new file mode 100644 index 0000000..c6e1162 --- /dev/null +++ b/python/gevent/_semaphore.py @@ -0,0 +1,269 @@ +import sys +from gevent.hub import get_hub, getcurrent +from gevent.timeout import Timeout + + +__all__ = ['Semaphore', 'BoundedSemaphore'] + + +class Semaphore(object): + """ + Semaphore(value=1) -> Semaphore + + A semaphore manages a counter representing the number of release() + calls minus the number of acquire() calls, plus an initial value. + The acquire() method blocks if necessary until it can return + without making the counter negative. + + If not given, ``value`` defaults to 1. + + The semaphore is a context manager and can be used in ``with`` statements. + + This Semaphore's ``__exit__`` method does not call the trace function + on CPython, but does under PyPy. + + .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents + some classes of bugs. + """ + + def __init__(self, value=1): + if value < 0: + raise ValueError("semaphore initial value must be >= 0") + self.counter = value + self._dirty = False + # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef + # readonly` or simply `cdef` attributes of type `object` can appear to leak if + # a Python subclass is used (this is visible simply + # instantiating this subclass if _links=[]). Our _links and + # _notifier are such attributes, and gevent.thread subclasses + # this class. Thus, we carefully manage the lifetime of the + # objects we put in these attributes so that, in the normal + # case of a semaphore used correctly (deallocated when it's not + # locked and no one is waiting), the leak goes away (because + # these objects are back to None). This can also be solved on PyPy + # by simply not declaring these objects in the pxd file, but that doesn't work for + # CPython ("No attribute...") + # See https://github.com/gevent/gevent/issues/660 + self._links = None + self._notifier = None + # we don't want to do get_hub() here to allow defining module-level locks + # without initializing the hub + + def __str__(self): + params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) + return '<%s counter=%s _links[%s]>' % params + + def locked(self): + """Return a boolean indicating whether the semaphore can be acquired. + Most useful with binary semaphores.""" + return self.counter <= 0 + + def release(self): + """ + Release the semaphore, notifying any waiters if needed. + """ + self.counter += 1 + self._start_notify() + return self.counter + + def _start_notify(self): + if self._links and self.counter > 0 and not self._notifier: + # We create a new self._notifier each time through the loop, + # if needed. (it has a __bool__ method that tells whether it has + # been run; once it's run once---at the end of the loop---it becomes + # false.) + # NOTE: Passing the bound method will cause a memory leak on PyPy + # with Cython <= 0.23.3. You must use >= 0.23.4. + # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546 + self._notifier = get_hub().loop.run_callback(self._notify_links) + + def _notify_links(self): + # Subclasses CANNOT override. This is a cdef method. + + # We release self._notifier here. We are called by it + # at the end of the loop, and it is now false in a boolean way (as soon + # as this method returns). + # If we get acquired/released again, we will create a new one, but there's + # no need to keep it around until that point (making it potentially climb + # into older GC generations, notably on PyPy) + notifier = self._notifier + try: + while True: + self._dirty = False + if not self._links: + # In case we were manually unlinked before + # the callback. Which shouldn't happen + return + for link in self._links: + if self.counter <= 0: + return + try: + link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + except: # pylint:disable=bare-except + getcurrent().handle_error((link, self), *sys.exc_info()) + if self._dirty: + # We mutated self._links so we need to start over + break + if not self._dirty: + return + finally: + # We should not have created a new notifier even if callbacks + # released us because we loop through *all* of our links on the + # same callback while self._notifier is still true. + assert self._notifier is notifier + self._notifier = None + + def rawlink(self, callback): + """ + rawlink(callback) -> None + + Register a callback to call when a counter is more than zero. + + *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API. + *callback* will be passed one argument: this instance. + + This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code + will not need to use it. + """ + if not callable(callback): + raise TypeError('Expected callable:', callback) + if self._links is None: + self._links = [callback] + else: + self._links.append(callback) + self._dirty = True + + def unlink(self, callback): + """ + unlink(callback) -> None + + Remove the callback set by :meth:`rawlink`. + + This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most + code will not need to use it. + """ + try: + self._links.remove(callback) + self._dirty = True + except (ValueError, AttributeError): + pass + if not self._links: + self._links = None + # TODO: Cancel a notifier if there are no links? + + def _do_wait(self, timeout): + """ + Wait for up to *timeout* seconds to expire. If timeout + elapses, return the exception. Otherwise, return None. + Raises timeout if a different timer expires. + """ + switch = getcurrent().switch + self.rawlink(switch) + try: + timer = Timeout._start_new_or_dummy(timeout) + try: + try: + result = get_hub().switch() + assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + except Timeout as ex: + if ex is not timer: + raise + return ex + finally: + timer.cancel() + finally: + self.unlink(switch) + + def wait(self, timeout=None): + """ + wait(timeout=None) -> int + + Wait until it is possible to acquire this semaphore, or until the optional + *timeout* elapses. + + .. caution:: If this semaphore was initialized with a size of 0, + this method will block forever if no timeout is given. + + :keyword float timeout: If given, specifies the maximum amount of seconds + this method will block. + :return: A number indicating how many times the semaphore can be acquired + before blocking. + """ + if self.counter > 0: + return self.counter + + self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout + return self.counter + + def acquire(self, blocking=True, timeout=None): + """ + acquire(blocking=True, timeout=None) -> bool + + Acquire the semaphore. + + .. caution:: If this semaphore was initialized with a size of 0, + this method will block forever (unless a timeout is given or blocking is + set to false). + + :keyword bool blocking: If True (the default), this function will block + until the semaphore is acquired. + :keyword float timeout: If given, specifies the maximum amount of seconds + this method will block. + :return: A boolean indicating whether the semaphore was acquired. + If ``blocking`` is True and ``timeout`` is None (the default), then + (so long as this semaphore was initialized with a size greater than 0) + this will always return True. If a timeout was given, and it expired before + the semaphore was acquired, False will be returned. (Note that this can still + raise a ``Timeout`` exception, if some other caller had already started a timer.) + """ + if self.counter > 0: + self.counter -= 1 + return True + + if not blocking: + return False + + timeout = self._do_wait(timeout) + if timeout is not None: + # Our timer expired. + return False + + # Neither our timer no another one expired, so we blocked until + # awoke. Therefore, the counter is ours + self.counter -= 1 + assert self.counter >= 0 + return True + + _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + + def __enter__(self): + self.acquire() + + def __exit__(self, t, v, tb): + self.release() + + +class BoundedSemaphore(Semaphore): + """ + BoundedSemaphore(value=1) -> BoundedSemaphore + + A bounded semaphore checks to make sure its current value doesn't + exceed its initial value. If it does, :class:`ValueError` is + raised. In most situations semaphores are used to guard resources + with limited capacity. If the semaphore is released too many times + it's a sign of a bug. + + If not given, *value* defaults to 1. + """ + + #: For monkey-patching, allow changing the class of error we raise + _OVER_RELEASE_ERROR = ValueError + + def __init__(self, *args, **kwargs): + Semaphore.__init__(self, *args, **kwargs) + self._initial_value = self.counter + + def release(self): + if self.counter >= self._initial_value: + raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + return Semaphore.release(self) diff --git a/python/gevent/_socket2.py b/python/gevent/_socket2.py new file mode 100644 index 0000000..dbcf1f7 --- /dev/null +++ b/python/gevent/_socket2.py @@ -0,0 +1,539 @@ +# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. +""" +Python 2 socket module. +""" +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable + +import time +from gevent import _socketcommon +from gevent._util import copy_globals +from gevent._compat import PYPY + +copy_globals(_socketcommon, globals(), + names_to_ignore=_socketcommon.__py3_imports__ + _socketcommon.__extensions__, + dunder_names_to_keep=()) + +__socket__ = _socketcommon.__socket__ +__implements__ = _socketcommon._implements +__extensions__ = _socketcommon.__extensions__ +__imports__ = [i for i in _socketcommon.__imports__ if i not in _socketcommon.__py3_imports__] +__dns__ = _socketcommon.__dns__ +try: + _fileobject = __socket__._fileobject + _socketmethods = __socket__._socketmethods +except AttributeError: + # Allow this module to be imported under Python 3 + # for building the docs + _fileobject = object + _socketmethods = ('bind', 'connect', 'connect_ex', + 'fileno', 'listen', 'getpeername', + 'getsockname', 'getsockopt', + 'setsockopt', 'sendall', + 'setblocking', 'settimeout', + 'gettimeout', 'shutdown') +else: + # Python 2 doesn't natively support with statements on _fileobject; + # but it eases our test cases if we can do the same with on both Py3 + # and Py2. Implementation copied from Python 3 + if not hasattr(_fileobject, '__enter__'): + # we could either patch in place: + #_fileobject.__enter__ = lambda self: self + #_fileobject.__exit__ = lambda self, *args: self.close() if not self.closed else None + # or we could subclass. subclassing has the benefit of not + # changing the behaviour of the stdlib if we're just imported; OTOH, + # under Python 2.6/2.7, test_urllib2net.py asserts that the class IS + # socket._fileobject (sigh), so we have to work around that. + class _fileobject(_fileobject): # pylint:disable=function-redefined + + def __enter__(self): + return self + + def __exit__(self, *args): + if not self.closed: + self.close() + +def _get_memory(data): + try: + mv = memoryview(data) + if mv.shape: + return mv + # No shape, probably working with a ctypes object, + # or something else exotic that supports the buffer interface + return mv.tobytes() + except TypeError: + # fixes "python2.7 array.array doesn't support memoryview used in + # gevent.socket.send" issue + # (http://code.google.com/p/gevent/issues/detail?id=94) + return buffer(data) + + +class _closedsocket(object): + __slots__ = [] + + def _dummy(*args, **kwargs): # pylint:disable=no-method-argument,unused-argument + raise error(EBADF, 'Bad file descriptor') + # All _delegate_methods must also be initialized here. + send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy + + if PYPY: + + def _drop(self): + pass + + def _reuse(self): + pass + + __getattr__ = _dummy + + +timeout_default = object() + + +class socket(object): + """ + gevent `socket.socket <https://docs.python.org/2/library/socket.html#socket-objects>`_ + for Python 2. + + This object should have the same API as the standard library socket linked to above. Not all + methods are specifically documented here; when they are they may point out a difference + to be aware of or may document a method the standard library does not. + """ + + # pylint:disable=too-many-public-methods + + def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None): + if _sock is None: + self._sock = _realsocket(family, type, proto) + self.timeout = _socket.getdefaulttimeout() + else: + if hasattr(_sock, '_sock'): + self._sock = _sock._sock + self.timeout = getattr(_sock, 'timeout', False) + if self.timeout is False: + self.timeout = _socket.getdefaulttimeout() + else: + self._sock = _sock + self.timeout = _socket.getdefaulttimeout() + if PYPY: + self._sock._reuse() + self._sock.setblocking(0) + fileno = self._sock.fileno() + self.hub = get_hub() + io = self.hub.loop.io + self._read_event = io(fileno, 1) + self._write_event = io(fileno, 2) + + def __repr__(self): + return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo()) + + def __str__(self): + return '<%s %s>' % (type(self).__name__, self._formatinfo()) + + def _formatinfo(self): + # pylint:disable=broad-except + try: + fileno = self.fileno() + except Exception as ex: + fileno = str(ex) + try: + sockname = self.getsockname() + sockname = '%s:%s' % sockname + except Exception: + sockname = None + try: + peername = self.getpeername() + peername = '%s:%s' % peername + except Exception: + peername = None + result = 'fileno=%s' % fileno + if sockname is not None: + result += ' sock=' + str(sockname) + if peername is not None: + result += ' peer=' + str(peername) + if getattr(self, 'timeout', None) is not None: + result += ' timeout=' + str(self.timeout) + return result + + def _get_ref(self): + return self._read_event.ref or self._write_event.ref + + def _set_ref(self, value): + self._read_event.ref = value + self._write_event.ref = value + + ref = property(_get_ref, _set_ref) + + def _wait(self, watcher, timeout_exc=timeout('timed out')): + """Block the current greenlet until *watcher* has pending events. + + If *timeout* is non-negative, then *timeout_exc* is raised after *timeout* second has passed. + By default *timeout_exc* is ``socket.timeout('timed out')``. + + If :func:`cancel_wait` is called, raise ``socket.error(EBADF, 'File descriptor was closed in another greenlet')``. + """ + if watcher.callback is not None: + raise _socketcommon.ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (watcher.callback, )) + if self.timeout is not None: + timeout = Timeout.start_new(self.timeout, timeout_exc, ref=False) + else: + timeout = None + try: + self.hub.wait(watcher) + finally: + if timeout is not None: + timeout.cancel() + + def accept(self): + sock = self._sock + while True: + try: + client_socket, address = sock.accept() + break + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + sockobj = socket(_sock=client_socket) + if PYPY: + client_socket._drop() + return sockobj, address + + def close(self, _closedsocket=_closedsocket, cancel_wait_ex=cancel_wait_ex): + # This function should not reference any globals. See Python issue #808164. + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + s = self._sock + self._sock = _closedsocket() + if PYPY: + s._drop() + + @property + def closed(self): + return isinstance(self._sock, _closedsocket) + + def connect(self, address): + if self.timeout == 0.0: + return self._sock.connect(address) + sock = self._sock + if isinstance(address, tuple): + r = getaddrinfo(address[0], address[1], sock.family) + address = r[0][-1] + if self.timeout is not None: + timer = Timeout.start_new(self.timeout, timeout('timed out')) + else: + timer = None + try: + while True: + err = sock.getsockopt(SOL_SOCKET, SO_ERROR) + if err: + raise error(err, strerror(err)) + result = sock.connect_ex(address) + if not result or result == EISCONN: + break + elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows): + self._wait(self._write_event) + else: + raise error(result, strerror(result)) + finally: + if timer is not None: + timer.cancel() + + def connect_ex(self, address): + try: + return self.connect(address) or 0 + except timeout: + return EAGAIN + except error as ex: + if type(ex) is error: # pylint:disable=unidiomatic-typecheck + return ex.args[0] + else: + raise # gaierror is not silenced by connect_ex + + def dup(self): + """dup() -> socket object + + Return a new socket object connected to the same system resource. + Note, that the new socket does not inherit the timeout.""" + return socket(_sock=self._sock) + + def makefile(self, mode='r', bufsize=-1): + # Two things to look out for: + # 1) Closing the original socket object should not close the + # socket (hence creating a new instance) + # 2) The resulting fileobject must keep the timeout in order + # to be compatible with the stdlib's socket.makefile. + # Pass self as _sock to preserve timeout. + fobj = _fileobject(type(self)(_sock=self), mode, bufsize) + if PYPY: + self._sock._drop() + return fobj + + def recv(self, *args): + sock = self._sock # keeping the reference so that fd is not closed during waiting + while True: + try: + return sock.recv(*args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + # QQQ without clearing exc_info test__refcount.test_clean_exit fails + sys.exc_clear() + self._wait(self._read_event) + + def recvfrom(self, *args): + sock = self._sock + while True: + try: + return sock.recvfrom(*args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + + def recvfrom_into(self, *args): + sock = self._sock + while True: + try: + return sock.recvfrom_into(*args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + + def recv_into(self, *args): + sock = self._sock + while True: + try: + return sock.recv_into(*args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + + def send(self, data, flags=0, timeout=timeout_default): + sock = self._sock + if timeout is timeout_default: + timeout = self.timeout + try: + return sock.send(data, flags) + except error as ex: + if ex.args[0] != EWOULDBLOCK or timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event) + try: + return sock.send(data, flags) + except error as ex2: + if ex2.args[0] == EWOULDBLOCK: + return 0 + raise + + def __send_chunk(self, data_memory, flags, timeleft, end): + """ + Send the complete contents of ``data_memory`` before returning. + This is the core loop around :meth:`send`. + + :param timeleft: Either ``None`` if there is no timeout involved, + or a float indicating the timeout to use. + :param end: Either ``None`` if there is no timeout involved, or + a float giving the absolute end time. + :return: An updated value for ``timeleft`` (or None) + :raises timeout: If ``timeleft`` was given and elapsed while + sending this chunk. + """ + data_sent = 0 + len_data_memory = len(data_memory) + started_timer = 0 + while data_sent < len_data_memory: + chunk = data_memory[data_sent:] + if timeleft is None: + data_sent += self.send(chunk, flags) + elif started_timer and timeleft <= 0: + # Check before sending to guarantee a check + # happens even if each chunk successfully sends its data + # (especially important for SSL sockets since they have large + # buffers). But only do this if we've actually tried to + # send something once to avoid spurious timeouts on non-blocking + # sockets. + raise timeout('timed out') + else: + started_timer = 1 + data_sent += self.send(chunk, flags, timeout=timeleft) + timeleft = end - time.time() + + return timeleft + + def sendall(self, data, flags=0): + if isinstance(data, unicode): + data = data.encode() + # this sendall is also reused by gevent.ssl.SSLSocket subclass, + # so it should not call self._sock methods directly + data_memory = _get_memory(data) + len_data_memory = len(data_memory) + if not len_data_memory: + # Don't send empty data, can cause SSL EOFError. + # See issue 719 + return 0 + + # On PyPy up through 2.6.0, subviews of a memoryview() object + # copy the underlying bytes the first time the builtin + # socket.send() method is called. On a non-blocking socket + # (that thus calls socket.send() many times) with a large + # input, this results in many repeated copies of an ever + # smaller string, depending on the networking buffering. For + # example, if each send() can process 1MB of a 50MB input, and + # we naively pass the entire remaining subview each time, we'd + # copy 49MB, 48MB, 47MB, etc, thus completely killing + # performance. To workaround this problem, we work in + # reasonable, fixed-size chunks. This results in a 10x + # improvement to bench_sendall.py, while having no measurable impact on + # CPython (since it doesn't copy at all the only extra overhead is + # a few python function calls, which is negligible for large inputs). + + # See https://bitbucket.org/pypy/pypy/issues/2091/non-blocking-socketsend-slow-gevent + + # Too small of a chunk (the socket's buf size is usually too + # small) results in reduced perf due to *too many* calls to send and too many + # small copies. With a buffer of 143K (the default on my system), for + # example, bench_sendall.py yields ~264MB/s, while using 1MB yields + # ~653MB/s (matching CPython). 1MB is arbitrary and might be better + # chosen, say, to match a page size? + chunk_size = max(self.getsockopt(SOL_SOCKET, SO_SNDBUF), 1024 * 1024) # pylint:disable=no-member + + data_sent = 0 + end = None + timeleft = None + if self.timeout is not None: + timeleft = self.timeout + end = time.time() + timeleft + + while data_sent < len_data_memory: + chunk_end = min(data_sent + chunk_size, len_data_memory) + chunk = data_memory[data_sent:chunk_end] + + timeleft = self.__send_chunk(chunk, flags, timeleft, end) + data_sent += len(chunk) # Guaranteed it sent the whole thing + + def sendto(self, *args): + sock = self._sock + try: + return sock.sendto(*args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event) + try: + return sock.sendto(*args) + except error as ex2: + if ex2.args[0] == EWOULDBLOCK: + return 0 + raise + + def setblocking(self, flag): + if flag: + self.timeout = None + else: + self.timeout = 0.0 + + def settimeout(self, howlong): + if howlong is not None: + try: + f = howlong.__float__ + except AttributeError: + raise TypeError('a float is required') + howlong = f() + if howlong < 0.0: + raise ValueError('Timeout value out of range') + self.__dict__['timeout'] = howlong # avoid recursion with any property on self.timeout + + def gettimeout(self): + return self.__dict__['timeout'] # avoid recursion with any property on self.timeout + + def shutdown(self, how): + if how == 0: # SHUT_RD + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + elif how == 1: # SHUT_WR + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + else: + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + self._sock.shutdown(how) + + family = property(lambda self: self._sock.family) + type = property(lambda self: self._sock.type) + proto = property(lambda self: self._sock.proto) + + def fileno(self): + return self._sock.fileno() + + def getsockname(self): + return self._sock.getsockname() + + def getpeername(self): + return self._sock.getpeername() + + # delegate the functions that we haven't implemented to the real socket object + + _s = "def %s(self, *args): return self._sock.%s(*args)\n\n" + _m = None + for _m in set(_socketmethods) - set(locals()): + exec(_s % (_m, _m,)) + del _m, _s + + if PYPY: + + def _reuse(self): + self._sock._reuse() + + def _drop(self): + self._sock._drop() + + +SocketType = socket + +if hasattr(_socket, 'socketpair'): + + def socketpair(family=getattr(_socket, 'AF_UNIX', _socket.AF_INET), + type=_socket.SOCK_STREAM, proto=0): + one, two = _socket.socketpair(family, type, proto) + result = socket(_sock=one), socket(_sock=two) + if PYPY: + one._drop() + two._drop() + return result +elif 'socketpair' in __implements__: + __implements__.remove('socketpair') + +if hasattr(_socket, 'fromfd'): + + def fromfd(fd, family, type, proto=0): + s = _socket.fromfd(fd, family, type, proto) + result = socket(_sock=s) + if PYPY: + s._drop() + return result + +elif 'fromfd' in __implements__: + __implements__.remove('fromfd') + +if hasattr(__socket__, 'ssl'): + + def ssl(sock, keyfile=None, certfile=None): + # deprecated in 2.7.9 but still present; + # sometimes backported by distros. See ssl.py + # Note that we import gevent.ssl, not _ssl2, to get the correct + # version. + from gevent import ssl as _sslmod + # wrap_socket is 2.7.9/backport, sslwrap_simple is older. They take + # the same arguments. + wrap = getattr(_sslmod, 'wrap_socket', None) or getattr(_sslmod, 'sslwrap_simple') + return wrap(sock, keyfile, certfile) + __implements__.append('ssl') + +__all__ = __implements__ + __extensions__ + __imports__ diff --git a/python/gevent/_socket3.py b/python/gevent/_socket3.py new file mode 100644 index 0000000..d659d88 --- /dev/null +++ b/python/gevent/_socket3.py @@ -0,0 +1,1065 @@ +# Port of Python 3.3's socket module to gevent +""" +Python 3 socket module. +""" +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable +# pylint: disable=too-many-statements,too-many-branches +# pylint: disable=too-many-public-methods,unused-argument +from __future__ import absolute_import +import io +import os +import sys +import time +from gevent import _socketcommon +from gevent._util import copy_globals +from gevent._compat import PYPY +import _socket +from os import dup + +copy_globals(_socketcommon, globals(), + names_to_ignore=_socketcommon.__extensions__, + dunder_names_to_keep=()) + +__socket__ = _socketcommon.__socket__ +__implements__ = _socketcommon._implements +__extensions__ = _socketcommon.__extensions__ +__imports__ = _socketcommon.__imports__ +__dns__ = _socketcommon.__dns__ + + +SocketIO = __socket__.SocketIO # pylint:disable=no-member + + +def _get_memory(data): + mv = memoryview(data) + if mv.shape: + return mv + # No shape, probably working with a ctypes object, + # or something else exotic that supports the buffer interface + return mv.tobytes() + +timeout_default = object() + + +class _wrefsocket(_socket.socket): + # Plain stdlib socket.socket objects subclass _socket.socket + # and add weakref ability. The ssl module, for one, counts on this. + # We don't create socket.socket objects (because they may have been + # monkey patched to be the object from this module), but we still + # need to make sure what we do create can be weakrefd. + + __slots__ = ("__weakref__", ) + + if PYPY: + # server.py unwraps the socket object to get the raw _sock; + # it depends on having a timeout property alias, which PyPy does not + # provide. + timeout = property(lambda s: s.gettimeout(), + lambda s, nv: s.settimeout(nv)) + + +class socket(object): + """ + gevent `socket.socket <https://docs.python.org/3/library/socket.html#socket-objects>`_ + for Python 3. + + This object should have the same API as the standard library socket linked to above. Not all + methods are specifically documented here; when they are they may point out a difference + to be aware of or may document a method the standard library does not. + """ + + # Subclasses can set this to customize the type of the + # native _socket.socket we create. It MUST be a subclass + # of _wrefsocket. (gevent internal usage only) + _gevent_sock_class = _wrefsocket + + def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None): + # Take the same approach as socket2: wrap a real socket object, + # don't subclass it. This lets code that needs the raw _sock (not tied to the hub) + # get it. This shows up in tests like test__example_udp_server. + self._sock = self._gevent_sock_class(family, type, proto, fileno) + self._io_refs = 0 + self._closed = False + _socket.socket.setblocking(self._sock, False) + fileno = _socket.socket.fileno(self._sock) + self.hub = get_hub() + io_class = self.hub.loop.io + self._read_event = io_class(fileno, 1) + self._write_event = io_class(fileno, 2) + self.timeout = _socket.getdefaulttimeout() + + def __getattr__(self, name): + return getattr(self._sock, name) + + if hasattr(_socket, 'SOCK_NONBLOCK'): + # Only defined under Linux + @property + def type(self): + # See https://github.com/gevent/gevent/pull/399 + if self.timeout != 0.0: + return self._sock.type & ~_socket.SOCK_NONBLOCK # pylint:disable=no-member + return self._sock.type + + def __enter__(self): + return self + + def __exit__(self, *args): + if not self._closed: + self.close() + + def __repr__(self): + """Wrap __repr__() to reveal the real class name.""" + try: + s = _socket.socket.__repr__(self._sock) + except Exception as ex: # pylint:disable=broad-except + # Observed on Windows Py3.3, printing the repr of a socket + # that just sufferred a ConnectionResetError [WinError 10054]: + # "OverflowError: no printf formatter to display the socket descriptor in decimal" + # Not sure what the actual cause is or if there's a better way to handle this + s = '<socket [%r]>' % ex + + if s.startswith("<socket object"): + s = "<%s.%s%s%s" % (self.__class__.__module__, + self.__class__.__name__, + getattr(self, '_closed', False) and " [closed] " or "", + s[7:]) + return s + + def __getstate__(self): + raise TypeError("Cannot serialize socket object") + + def _get_ref(self): + return self._read_event.ref or self._write_event.ref + + def _set_ref(self, value): + self._read_event.ref = value + self._write_event.ref = value + + ref = property(_get_ref, _set_ref) + + def _wait(self, watcher, timeout_exc=timeout('timed out')): + """Block the current greenlet until *watcher* has pending events. + + If *timeout* is non-negative, then *timeout_exc* is raised after *timeout* second has passed. + By default *timeout_exc* is ``socket.timeout('timed out')``. + + If :func:`cancel_wait` is called, raise ``socket.error(EBADF, 'File descriptor was closed in another greenlet')``. + """ + if watcher.callback is not None: + raise _socketcommon.ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (watcher.callback, )) + if self.timeout is not None: + timeout = Timeout.start_new(self.timeout, timeout_exc, ref=False) + else: + timeout = None + try: + self.hub.wait(watcher) + finally: + if timeout is not None: + timeout.cancel() + + def dup(self): + """dup() -> socket object + + Return a new socket object connected to the same system resource. + """ + fd = dup(self.fileno()) + sock = self.__class__(self.family, self.type, self.proto, fileno=fd) + sock.settimeout(self.gettimeout()) + return sock + + def accept(self): + """accept() -> (socket object, address info) + + Wait for an incoming connection. Return a new socket + representing the connection, and the address of the client. + For IP sockets, the address info is a pair (hostaddr, port). + """ + while True: + try: + fd, addr = self._accept() + break + except BlockingIOError: + if self.timeout == 0.0: + raise + self._wait(self._read_event) + sock = socket(self.family, self.type, self.proto, fileno=fd) + # Python Issue #7995: if no default timeout is set and the listening + # socket had a (non-zero) timeout, force the new socket in blocking + # mode to override platform-specific socket flags inheritance. + # XXX do we need to do this? + if getdefaulttimeout() is None and self.gettimeout(): + sock.setblocking(True) + return sock, addr + + def makefile(self, mode="r", buffering=None, *, + encoding=None, errors=None, newline=None): + """Return an I/O stream connected to the socket + + The arguments are as for io.open() after the filename, + except the only mode characters supported are 'r', 'w' and 'b'. + The semantics are similar too. + """ + # (XXX refactor to share code?) + for c in mode: + if c not in {"r", "w", "b"}: + raise ValueError("invalid mode %r (only r, w, b allowed)") + writing = "w" in mode + reading = "r" in mode or not writing + assert reading or writing + binary = "b" in mode + rawmode = "" + if reading: + rawmode += "r" + if writing: + rawmode += "w" + raw = SocketIO(self, rawmode) + self._io_refs += 1 + if buffering is None: + buffering = -1 + if buffering < 0: + buffering = io.DEFAULT_BUFFER_SIZE + if buffering == 0: + if not binary: + raise ValueError("unbuffered streams must be binary") + return raw + if reading and writing: + buffer = io.BufferedRWPair(raw, raw, buffering) + elif reading: + buffer = io.BufferedReader(raw, buffering) + else: + assert writing + buffer = io.BufferedWriter(raw, buffering) + if binary: + return buffer + text = io.TextIOWrapper(buffer, encoding, errors, newline) + text.mode = mode + return text + + def _decref_socketios(self): + if self._io_refs > 0: + self._io_refs -= 1 + if self._closed: + self.close() + + def _real_close(self, _ss=_socket.socket, cancel_wait_ex=cancel_wait_ex): + # This function should not reference any globals. See Python issue #808164. + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + _ss.close(self._sock) + + # Break any references to the underlying socket object. Tested + # by test__refcount. (Why does this matter?). Be sure to + # preserve our same family/type/proto if possible (if we + # don't, we can get TypeError instead of OSError; see + # test_socket.SendmsgUDP6Test.testSendmsgAfterClose)... but + # this isn't always possible (see test_socket.test_unknown_socket_family_repr) + # TODO: Can we use a simpler proxy, like _socket2 does? + try: + self._sock = self._gevent_sock_class(self.family, self.type, self.proto) + except OSError: + pass + else: + _ss.close(self._sock) + + + def close(self): + # This function should not reference any globals. See Python issue #808164. + self._closed = True + if self._io_refs <= 0: + self._real_close() + + @property + def closed(self): + return self._closed + + def detach(self): + """detach() -> file descriptor + + Close the socket object without closing the underlying file descriptor. + The object cannot be used after this call, but the file descriptor + can be reused for other purposes. The file descriptor is returned. + """ + self._closed = True + return self._sock.detach() + + def connect(self, address): + if self.timeout == 0.0: + return _socket.socket.connect(self._sock, address) + if isinstance(address, tuple): + r = getaddrinfo(address[0], address[1], self.family) + address = r[0][-1] + if self.timeout is not None: + timer = Timeout.start_new(self.timeout, timeout('timed out')) + else: + timer = None + try: + while True: + err = self.getsockopt(SOL_SOCKET, SO_ERROR) + if err: + raise error(err, strerror(err)) + result = _socket.socket.connect_ex(self._sock, address) + if not result or result == EISCONN: + break + elif (result in (EWOULDBLOCK, EINPROGRESS, EALREADY)) or (result == EINVAL and is_windows): + self._wait(self._write_event) + else: + raise error(result, strerror(result)) + finally: + if timer is not None: + timer.cancel() + + def connect_ex(self, address): + try: + return self.connect(address) or 0 + except timeout: + return EAGAIN + except gaierror: + # gaierror/overflowerror/typerror is not silenced by connect_ex; + # gaierror extends OSError (aka error) so catch it first + raise + except error as ex: + # error is now OSError and it has various subclasses. + # Only those that apply to actually connecting are silenced by + # connect_ex. + if ex.errno: + return ex.errno + raise # pragma: no cover + + def recv(self, *args): + while True: + try: + return _socket.socket.recv(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + if hasattr(_socket.socket, 'sendmsg'): + # Only on Unix + + def recvmsg(self, *args): + while True: + try: + return _socket.socket.recvmsg(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + def recvmsg_into(self, *args): + while True: + try: + return _socket.socket.recvmsg_into(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + def recvfrom(self, *args): + while True: + try: + return _socket.socket.recvfrom(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + def recvfrom_into(self, *args): + while True: + try: + return _socket.socket.recvfrom_into(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + def recv_into(self, *args): + while True: + try: + return _socket.socket.recv_into(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._read_event) + + def send(self, data, flags=0, timeout=timeout_default): + if timeout is timeout_default: + timeout = self.timeout + try: + return _socket.socket.send(self._sock, data, flags) + except error as ex: + if ex.args[0] != EWOULDBLOCK or timeout == 0.0: + raise + self._wait(self._write_event) + try: + return _socket.socket.send(self._sock, data, flags) + except error as ex2: + if ex2.args[0] == EWOULDBLOCK: + return 0 + raise + + def sendall(self, data, flags=0): + # XXX Now that we run on PyPy3, see the notes in _socket2.py's sendall() + # and implement that here if needed. + # PyPy3 is not optimized for performance yet, and is known to be slower than + # PyPy2, so it's possibly premature to do this. However, there is a 3.5 test case that + # possibly exposes this in a severe way. + data_memory = _get_memory(data) + len_data_memory = len(data_memory) + if not len_data_memory: + # Don't try to send empty data at all, no point, and breaks ssl + # See issue 719 + return 0 + + if self.timeout is None: + data_sent = 0 + while data_sent < len_data_memory: + data_sent += self.send(data_memory[data_sent:], flags) + else: + timeleft = self.timeout + end = time.time() + timeleft + data_sent = 0 + while True: + data_sent += self.send(data_memory[data_sent:], flags, timeout=timeleft) + if data_sent >= len_data_memory: + break + timeleft = end - time.time() + if timeleft <= 0: + raise timeout('timed out') + + def sendto(self, *args): + try: + return _socket.socket.sendto(self._sock, *args) + except error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._write_event) + try: + return _socket.socket.sendto(self._sock, *args) + except error as ex2: + if ex2.args[0] == EWOULDBLOCK: + return 0 + raise + + if hasattr(_socket.socket, 'sendmsg'): + # Only on Unix + def sendmsg(self, buffers, ancdata=(), flags=0, address=None): + try: + return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address) + except error as ex: + if flags & getattr(_socket, 'MSG_DONTWAIT', 0): + # Enable non-blocking behaviour + # XXX: Do all platforms that have sendmsg have MSG_DONTWAIT? + raise + + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + self._wait(self._write_event) + try: + return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address) + except error as ex2: + if ex2.args[0] == EWOULDBLOCK: + return 0 + raise + + def setblocking(self, flag): + if flag: + self.timeout = None + else: + self.timeout = 0.0 + + def settimeout(self, howlong): + if howlong is not None: + try: + f = howlong.__float__ + except AttributeError: + raise TypeError('a float is required') + howlong = f() + if howlong < 0.0: + raise ValueError('Timeout value out of range') + self.__dict__['timeout'] = howlong + + def gettimeout(self): + return self.__dict__['timeout'] + + def shutdown(self, how): + if how == 0: # SHUT_RD + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + elif how == 1: # SHUT_WR + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + else: + self.hub.cancel_wait(self._read_event, cancel_wait_ex) + self.hub.cancel_wait(self._write_event, cancel_wait_ex) + self._sock.shutdown(how) + + # sendfile: new in 3.5. But there's no real reason to not + # support it everywhere. Note that we can't use os.sendfile() + # because it's not cooperative. + def _sendfile_use_sendfile(self, file, offset=0, count=None): + # This is called directly by tests + raise __socket__._GiveupOnSendfile() # pylint:disable=no-member + + def _sendfile_use_send(self, file, offset=0, count=None): + self._check_sendfile_params(file, offset, count) + if self.gettimeout() == 0: + raise ValueError("non-blocking sockets are not supported") + if offset: + file.seek(offset) + blocksize = min(count, 8192) if count else 8192 + total_sent = 0 + # localize variable access to minimize overhead + file_read = file.read + sock_send = self.send + try: + while True: + if count: + blocksize = min(count - total_sent, blocksize) + if blocksize <= 0: + break + data = memoryview(file_read(blocksize)) + if not data: + break # EOF + while True: + try: + sent = sock_send(data) + except BlockingIOError: + continue + else: + total_sent += sent + if sent < len(data): + data = data[sent:] + else: + break + return total_sent + finally: + if total_sent > 0 and hasattr(file, 'seek'): + file.seek(offset + total_sent) + + def _check_sendfile_params(self, file, offset, count): + if 'b' not in getattr(file, 'mode', 'b'): + raise ValueError("file should be opened in binary mode") + if not self.type & SOCK_STREAM: + raise ValueError("only SOCK_STREAM type sockets are supported") + if count is not None: + if not isinstance(count, int): + raise TypeError( + "count must be a positive integer (got {!r})".format(count)) + if count <= 0: + raise ValueError( + "count must be a positive integer (got {!r})".format(count)) + + def sendfile(self, file, offset=0, count=None): + """sendfile(file[, offset[, count]]) -> sent + + Send a file until EOF is reached by using high-performance + os.sendfile() and return the total number of bytes which + were sent. + *file* must be a regular file object opened in binary mode. + If os.sendfile() is not available (e.g. Windows) or file is + not a regular file socket.send() will be used instead. + *offset* tells from where to start reading the file. + If specified, *count* is the total number of bytes to transmit + as opposed to sending the file until EOF is reached. + File position is updated on return or also in case of error in + which case file.tell() can be used to figure out the number of + bytes which were sent. + The socket must be of SOCK_STREAM type. + Non-blocking sockets are not supported. + + .. versionadded:: 1.1rc4 + Added in Python 3.5, but available under all Python 3 versions in + gevent. + """ + return self._sendfile_use_send(file, offset, count) + + # get/set_inheritable new in 3.4 + if hasattr(os, 'get_inheritable') or hasattr(os, 'get_handle_inheritable'): + # pylint:disable=no-member + if os.name == 'nt': + def get_inheritable(self): + return os.get_handle_inheritable(self.fileno()) + + def set_inheritable(self, inheritable): + os.set_handle_inheritable(self.fileno(), inheritable) + else: + def get_inheritable(self): + return os.get_inheritable(self.fileno()) + + def set_inheritable(self, inheritable): + os.set_inheritable(self.fileno(), inheritable) + _added = "\n\n.. versionadded:: 1.1rc4 Added in Python 3.4" + get_inheritable.__doc__ = "Get the inheritable flag of the socket" + _added + set_inheritable.__doc__ = "Set the inheritable flag of the socket" + _added + del _added + + +if sys.version_info[:2] == (3, 4) and sys.version_info[:3] <= (3, 4, 2): + # Python 3.4, up to and including 3.4.2, had a bug where the + # SocketType enumeration overwrote the SocketType class imported + # from _socket. This was fixed in 3.4.3 (http://bugs.python.org/issue20386 + # and https://github.com/python/cpython/commit/0d2f85f38a9691efdfd1e7285c4262cab7f17db7). + # Prior to that, if we replace SocketType with our own class, the implementation + # of socket.type breaks with "OSError: [Errno 97] Address family not supported by protocol". + # Therefore, on these old versions, we must preserve it as an enum; while this + # seems like it could lead to non-green behaviour, code on those versions + # cannot possibly be using SocketType as a class anyway. + SocketType = __socket__.SocketType # pylint:disable=no-member + # Fixup __all__; note that we get exec'd multiple times during unit tests + if 'SocketType' in __implements__: + __implements__.remove('SocketType') + if 'SocketType' not in __imports__: + __imports__.append('SocketType') +else: + SocketType = socket + + +def fromfd(fd, family, type, proto=0): + """ fromfd(fd, family, type[, proto]) -> socket object + + Create a socket object from a duplicate of the given file + descriptor. The remaining arguments are the same as for socket(). + """ + nfd = dup(fd) + return socket(family, type, proto, nfd) + + +if hasattr(_socket.socket, "share"): + def fromshare(info): + """ fromshare(info) -> socket object + + Create a socket object from a the bytes object returned by + socket.share(pid). + """ + return socket(0, 0, 0, info) + + __implements__.append('fromshare') + +if hasattr(_socket, "socketpair"): + + def socketpair(family=None, type=SOCK_STREAM, proto=0): + """socketpair([family[, type[, proto]]]) -> (socket object, socket object) + + Create a pair of socket objects from the sockets returned by the platform + socketpair() function. + The arguments are the same as for socket() except the default family is + AF_UNIX if defined on the platform; otherwise, the default is AF_INET. + + .. versionchanged:: 1.2 + All Python 3 versions on Windows supply this function (natively + supplied by Python 3.5 and above). + """ + if family is None: + try: + family = AF_UNIX + except NameError: + family = AF_INET + a, b = _socket.socketpair(family, type, proto) + a = socket(family, type, proto, a.detach()) + b = socket(family, type, proto, b.detach()) + return a, b + +else: + # Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. + + # gevent: taken from 3.6 release. Expected to be used only on Win. Added to Win/3.5 + # gevent: for < 3.5, pass the default value of 128 to lsock.listen() + # (3.5+ uses this as a default and the original code passed no value) + + _LOCALHOST = '127.0.0.1' + _LOCALHOST_V6 = '::1' + + def socketpair(family=AF_INET, type=SOCK_STREAM, proto=0): + if family == AF_INET: + host = _LOCALHOST + elif family == AF_INET6: + host = _LOCALHOST_V6 + else: + raise ValueError("Only AF_INET and AF_INET6 socket address families " + "are supported") + if type != SOCK_STREAM: + raise ValueError("Only SOCK_STREAM socket type is supported") + if proto != 0: + raise ValueError("Only protocol zero is supported") + + # We create a connected TCP socket. Note the trick with + # setblocking(False) that prevents us from having to create a thread. + lsock = socket(family, type, proto) + try: + lsock.bind((host, 0)) + lsock.listen(128) + # On IPv6, ignore flow_info and scope_id + addr, port = lsock.getsockname()[:2] + csock = socket(family, type, proto) + try: + csock.setblocking(False) + try: + csock.connect((addr, port)) + except (BlockingIOError, InterruptedError): + pass + csock.setblocking(True) + ssock, _ = lsock.accept() + except: + csock.close() + raise + finally: + lsock.close() + return (ssock, csock) + + if sys.version_info[:2] < (3, 5): + # Not provided natively + if 'socketpair' in __implements__: + # Multiple imports can cause this to be missing if _socketcommon + # was successfully imported, leading to subsequent imports to cause + # ValueError + __implements__.remove('socketpair') + + +# PyPy needs drop and reuse +def _do_reuse_or_drop(sock, methname): + try: + method = getattr(sock, methname) + except (AttributeError, TypeError): + pass + else: + method() + +from io import BytesIO + + +class _basefileobject(object): + """Faux file object attached to a socket object.""" + + default_bufsize = 8192 + name = "<socket>" + + __slots__ = ["mode", "bufsize", "softspace", + # "closed" is a property, see below + "_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf", "_wbuf_len", + "_close"] + + def __init__(self, sock, mode='rb', bufsize=-1, close=False): + _do_reuse_or_drop(sock, '_reuse') + self._sock = sock + self.mode = mode # Not actually used in this version + if bufsize < 0: + bufsize = self.default_bufsize + self.bufsize = bufsize + self.softspace = False + # _rbufsize is the suggested recv buffer size. It is *strictly* + # obeyed within readline() for recv calls. If it is larger than + # default_bufsize it will be used for recv calls within read(). + if bufsize == 0: + self._rbufsize = 1 + elif bufsize == 1: + self._rbufsize = self.default_bufsize + else: + self._rbufsize = bufsize + self._wbufsize = bufsize + # We use BytesIO for the read buffer to avoid holding a list + # of variously sized string objects which have been known to + # fragment the heap due to how they are malloc()ed and often + # realloc()ed down much smaller than their original allocation. + self._rbuf = BytesIO() + self._wbuf = [] # A list of strings + self._wbuf_len = 0 + self._close = close + + def _getclosed(self): + return self._sock is None + closed = property(_getclosed, doc="True if the file is closed") + + def close(self): + try: + if self._sock: + self.flush() + finally: + s = self._sock + self._sock = None + if s is not None: + if self._close: + s.close() + else: + _do_reuse_or_drop(s, '_drop') + + def __del__(self): + try: + self.close() + except: # pylint:disable=bare-except + # close() may fail if __init__ didn't complete + pass + + def flush(self): + if self._wbuf: + data = b"".join(self._wbuf) + self._wbuf = [] + self._wbuf_len = 0 + buffer_size = max(self._rbufsize, self.default_bufsize) + data_size = len(data) + write_offset = 0 + view = memoryview(data) + try: + while write_offset < data_size: + self._sock.sendall(view[write_offset:write_offset + buffer_size]) + write_offset += buffer_size + finally: + if write_offset < data_size: + remainder = data[write_offset:] + del view, data # explicit free + self._wbuf.append(remainder) + self._wbuf_len = len(remainder) + + def fileno(self): + return self._sock.fileno() + + def write(self, data): + if not isinstance(data, bytes): + raise TypeError("Non-bytes data") + if not data: + return + self._wbuf.append(data) + self._wbuf_len += len(data) + if (self._wbufsize == 0 or (self._wbufsize == 1 and b'\n' in data) or + (self._wbufsize > 1 and self._wbuf_len >= self._wbufsize)): + self.flush() + + def writelines(self, list): + # XXX We could do better here for very long lists + # XXX Should really reject non-string non-buffers + lines = filter(None, map(str, list)) + self._wbuf_len += sum(map(len, lines)) + self._wbuf.extend(lines) + if self._wbufsize <= 1 or self._wbuf_len >= self._wbufsize: + self.flush() + + def read(self, size=-1): + # Use max, disallow tiny reads in a loop as they are very inefficient. + # We never leave read() with any leftover data from a new recv() call + # in our internal buffer. + rbufsize = max(self._rbufsize, self.default_bufsize) + # Our use of BytesIO rather than lists of string objects returned by + # recv() minimizes memory usage and fragmentation that occurs when + # rbufsize is large compared to the typical return value of recv(). + buf = self._rbuf + buf.seek(0, 2) # seek end + if size < 0: + # Read until EOF + self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. + while True: + try: + data = self._sock.recv(rbufsize) + except InterruptedError: + continue + if not data: + break + buf.write(data) + return buf.getvalue() + else: + # Read until size bytes or EOF seen, whichever comes first + buf_len = buf.tell() + if buf_len >= size: + # Already have size bytes in our buffer? Extract and return. + buf.seek(0) + rv = buf.read(size) + self._rbuf = BytesIO() + self._rbuf.write(buf.read()) + return rv + + self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. + while True: + left = size - buf_len + # recv() will malloc the amount of memory given as its + # parameter even though it often returns much less data + # than that. The returned data string is short lived + # as we copy it into a BytesIO and free it. This avoids + # fragmentation issues on many platforms. + try: + data = self._sock.recv(left) + except InterruptedError: + continue + + if not data: + break + n = len(data) + if n == size and not buf_len: + # Shortcut. Avoid buffer data copies when: + # - We have no data in our buffer. + # AND + # - Our call to recv returned exactly the + # number of bytes we were asked to read. + return data + if n == left: + buf.write(data) + del data # explicit free + break + assert n <= left, "recv(%d) returned %d bytes" % (left, n) + buf.write(data) + buf_len += n + del data # explicit free + #assert buf_len == buf.tell() + return buf.getvalue() + + def readline(self, size=-1): + # pylint:disable=too-many-return-statements + buf = self._rbuf + buf.seek(0, 2) # seek end + if buf.tell() > 0: + # check if we already have it in our buffer + buf.seek(0) + bline = buf.readline(size) + if bline.endswith(b'\n') or len(bline) == size: + self._rbuf = BytesIO() + self._rbuf.write(buf.read()) + return bline + del bline + if size < 0: # pylint:disable=too-many-nested-blocks + # Read until \n or EOF, whichever comes first + if self._rbufsize <= 1: + # Speed up unbuffered case + buf.seek(0) + buffers = [buf.read()] + self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. + data = None + recv = self._sock.recv + while True: + try: + while data != b"\n": + data = recv(1) + if not data: + break + buffers.append(data) + except InterruptedError: + # The try..except to catch EINTR was moved outside the + # recv loop to avoid the per byte overhead. + continue + + break + return b"".join(buffers) + + buf.seek(0, 2) # seek end + self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. + while True: + try: + data = self._sock.recv(self._rbufsize) + except InterruptedError: + continue + + if not data: + break + nl = data.find(b'\n') + if nl >= 0: + nl += 1 + buf.write(data[:nl]) + self._rbuf.write(data[nl:]) + del data + break + buf.write(data) + return buf.getvalue() + else: + # Read until size bytes or \n or EOF seen, whichever comes first + buf.seek(0, 2) # seek end + buf_len = buf.tell() + if buf_len >= size: + buf.seek(0) + rv = buf.read(size) + self._rbuf = BytesIO() + self._rbuf.write(buf.read()) + return rv + self._rbuf = BytesIO() # reset _rbuf. we consume it via buf. + while True: + try: + data = self._sock.recv(self._rbufsize) + except InterruptedError: + continue + + if not data: + break + left = size - buf_len + # did we just receive a newline? + nl = data.find(b'\n', 0, left) + if nl >= 0: + nl += 1 + # save the excess data to _rbuf + self._rbuf.write(data[nl:]) + if buf_len: + buf.write(data[:nl]) + break + else: + # Shortcut. Avoid data copy through buf when returning + # a substring of our first recv(). + return data[:nl] + n = len(data) + if n == size and not buf_len: + # Shortcut. Avoid data copy through buf when + # returning exactly all of our first recv(). + return data + if n >= left: + buf.write(data[:left]) + self._rbuf.write(data[left:]) + break + buf.write(data) + buf_len += n + #assert buf_len == buf.tell() + return buf.getvalue() + + def readlines(self, sizehint=0): + total = 0 + list = [] + while True: + line = self.readline() + if not line: + break + list.append(line) + total += len(line) + if sizehint and total >= sizehint: + break + return list + + # Iterator protocols + + def __iter__(self): + return self + + def next(self): + line = self.readline() + if not line: + raise StopIteration + return line + __next__ = next + +try: + from gevent.fileobject import FileObjectPosix +except ImportError: + # Manual implementation + _fileobject = _basefileobject +else: + class _fileobject(FileObjectPosix): + # Add the proper drop/reuse support for pypy, and match + # the close=False default in the constructor + def __init__(self, sock, mode='rb', bufsize=-1, close=False): + _do_reuse_or_drop(sock, '_reuse') + self._sock = sock + FileObjectPosix.__init__(self, sock, mode, bufsize, close) + + def close(self): + try: + if self._sock: + self.flush() + finally: + s = self._sock + self._sock = None + if s is not None: + if self._close: + FileObjectPosix.close(self) + else: + _do_reuse_or_drop(s, '_drop') + + def __del__(self): + try: + self.close() + except: # pylint:disable=bare-except + # close() may fail if __init__ didn't complete + pass + + +__all__ = __implements__ + __extensions__ + __imports__ diff --git a/python/gevent/_socketcommon.py b/python/gevent/_socketcommon.py new file mode 100644 index 0000000..4da29c8 --- /dev/null +++ b/python/gevent/_socketcommon.py @@ -0,0 +1,343 @@ +# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. +from __future__ import absolute_import + +# standard functions and classes that this module re-implements in a gevent-aware way: +_implements = [ + 'create_connection', + 'socket', + 'SocketType', + 'fromfd', + 'socketpair', +] + +__dns__ = [ + 'getaddrinfo', + 'gethostbyname', + 'gethostbyname_ex', + 'gethostbyaddr', + 'getnameinfo', + 'getfqdn', +] + +_implements += __dns__ + +# non-standard functions that this module provides: +__extensions__ = [ + 'cancel_wait', + 'wait_read', + 'wait_write', + 'wait_readwrite', +] + +# standard functions and classes that this module re-imports +__imports__ = [ + 'error', + 'gaierror', + 'herror', + 'htonl', + 'htons', + 'ntohl', + 'ntohs', + 'inet_aton', + 'inet_ntoa', + 'inet_pton', + 'inet_ntop', + 'timeout', + 'gethostname', + 'getprotobyname', + 'getservbyname', + 'getservbyport', + 'getdefaulttimeout', + 'setdefaulttimeout', + # Windows: + 'errorTab', +] + +__py3_imports__ = [ + # Python 3 + 'AddressFamily', + 'SocketKind', + 'CMSG_LEN', + 'CMSG_SPACE', + 'dup', + 'if_indextoname', + 'if_nameindex', + 'if_nametoindex', + 'sethostname', +] + +__imports__.extend(__py3_imports__) + + +import sys +from gevent.hub import get_hub +from gevent.hub import ConcurrentObjectUseError +from gevent.timeout import Timeout +from gevent._compat import string_types, integer_types, PY3 +from gevent._util import copy_globals +from gevent._util import _NONE + +is_windows = sys.platform == 'win32' +# pylint:disable=no-name-in-module,unused-import +if is_windows: + # no such thing as WSAEPERM or error code 10001 according to winsock.h or MSDN + from errno import WSAEINVAL as EINVAL + from errno import WSAEWOULDBLOCK as EWOULDBLOCK + from errno import WSAEINPROGRESS as EINPROGRESS + from errno import WSAEALREADY as EALREADY + from errno import WSAEISCONN as EISCONN + from gevent.win32util import formatError as strerror + EAGAIN = EWOULDBLOCK +else: + from errno import EINVAL + from errno import EWOULDBLOCK + from errno import EINPROGRESS + from errno import EALREADY + from errno import EAGAIN + from errno import EISCONN + from os import strerror + +try: + from errno import EBADF +except ImportError: + EBADF = 9 + +import _socket +_realsocket = _socket.socket +import socket as __socket__ + +_name = _value = None +__imports__ = copy_globals(__socket__, globals(), + only_names=__imports__, + ignore_missing_names=True) + +for _name in __socket__.__all__: + _value = getattr(__socket__, _name) + if isinstance(_value, (integer_types, string_types)): + globals()[_name] = _value + __imports__.append(_name) + +del _name, _value + +_timeout_error = timeout # pylint: disable=undefined-variable + + +def wait(io, timeout=None, timeout_exc=_NONE): + """ + Block the current greenlet until *io* is ready. + + If *timeout* is non-negative, then *timeout_exc* is raised after + *timeout* second has passed. By default *timeout_exc* is + ``socket.timeout('timed out')``. + + If :func:`cancel_wait` is called on *io* by another greenlet, + raise an exception in this blocking greenlet + (``socket.error(EBADF, 'File descriptor was closed in another + greenlet')`` by default). + + :param io: A libev watcher, most commonly an IO watcher obtained from + :meth:`gevent.core.loop.io` + :keyword timeout_exc: The exception to raise if the timeout expires. + By default, a :class:`socket.timeout` exception is raised. + If you pass a value for this keyword, it is interpreted as for + :class:`gevent.timeout.Timeout`. + """ + if io.callback is not None: + raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (io.callback, )) + if timeout is not None: + timeout_exc = timeout_exc if timeout_exc is not _NONE else _timeout_error('timed out') + timeout = Timeout.start_new(timeout, timeout_exc) + + try: + return get_hub().wait(io) + finally: + if timeout is not None: + timeout.cancel() + # rename "io" to "watcher" because wait() works with any watcher + + +def wait_read(fileno, timeout=None, timeout_exc=_NONE): + """ + Block the current greenlet until *fileno* is ready to read. + + For the meaning of the other parameters and possible exceptions, + see :func:`wait`. + + .. seealso:: :func:`cancel_wait` + """ + io = get_hub().loop.io(fileno, 1) + return wait(io, timeout, timeout_exc) + + +def wait_write(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): + """ + Block the current greenlet until *fileno* is ready to write. + + For the meaning of the other parameters and possible exceptions, + see :func:`wait`. + + :keyword event: Ignored. Applications should not pass this parameter. + In the future, it may become an error. + + .. seealso:: :func:`cancel_wait` + """ + # pylint:disable=unused-argument + io = get_hub().loop.io(fileno, 2) + return wait(io, timeout, timeout_exc) + + +def wait_readwrite(fileno, timeout=None, timeout_exc=_NONE, event=_NONE): + """ + Block the current greenlet until *fileno* is ready to read or + write. + + For the meaning of the other parameters and possible exceptions, + see :func:`wait`. + + :keyword event: Ignored. Applications should not pass this parameter. + In the future, it may become an error. + + .. seealso:: :func:`cancel_wait` + """ + # pylint:disable=unused-argument + io = get_hub().loop.io(fileno, 3) + return wait(io, timeout, timeout_exc) + +#: The exception raised by default on a call to :func:`cancel_wait` +class cancel_wait_ex(error): # pylint: disable=undefined-variable + def __init__(self): + super(cancel_wait_ex, self).__init__( + EBADF, + 'File descriptor was closed in another greenlet') + + +def cancel_wait(watcher, error=cancel_wait_ex): + """See :meth:`gevent.hub.Hub.cancel_wait`""" + get_hub().cancel_wait(watcher, error) + + +class BlockingResolver(object): + + def __init__(self, hub=None): + pass + + def close(self): + pass + + for method in ['gethostbyname', + 'gethostbyname_ex', + 'getaddrinfo', + 'gethostbyaddr', + 'getnameinfo']: + locals()[method] = staticmethod(getattr(_socket, method)) + + +def gethostbyname(hostname): + """ + gethostbyname(host) -> address + + Return the IP address (a string of the form '255.255.255.255') for a host. + + .. seealso:: :doc:`dns` + """ + return get_hub().resolver.gethostbyname(hostname) + + +def gethostbyname_ex(hostname): + """ + gethostbyname_ex(host) -> (name, aliaslist, addresslist) + + Return the true host name, a list of aliases, and a list of IP addresses, + for a host. The host argument is a string giving a host name or IP number. + Resolve host and port into list of address info entries. + + .. seealso:: :doc:`dns` + """ + return get_hub().resolver.gethostbyname_ex(hostname) + + +def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0): + """ + Resolve host and port into list of address info entries. + + Translate the host/port argument into a sequence of 5-tuples that contain + all the necessary arguments for creating a socket connected to that service. + host is a domain name, a string representation of an IPv4/v6 address or + None. port is a string service name such as 'http', a numeric port number or + None. By passing None as the value of host and port, you can pass NULL to + the underlying C API. + + The family, type and proto arguments can be optionally specified in order to + narrow the list of addresses returned. Passing zero as a value for each of + these arguments selects the full range of results. + + .. seealso:: :doc:`dns` + """ + return get_hub().resolver.getaddrinfo(host, port, family, socktype, proto, flags) + +if PY3: + # The name of the socktype param changed to type in Python 3. + # See https://github.com/gevent/gevent/issues/960 + # Using inspect here to directly detect the condition is painful because we have to + # wrap it with a try/except TypeError because not all Python 2 + # versions can get the args of a builtin; we also have to use a with to suppress + # the deprecation warning. + d = getaddrinfo.__doc__ + + def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): # pylint:disable=function-redefined + return get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags) + getaddrinfo.__doc__ = d + del d + + +def gethostbyaddr(ip_address): + """ + gethostbyaddr(ip_address) -> (name, aliaslist, addresslist) + + Return the true host name, a list of aliases, and a list of IP addresses, + for a host. The host argument is a string giving a host name or IP number. + + .. seealso:: :doc:`dns` + """ + return get_hub().resolver.gethostbyaddr(ip_address) + + +def getnameinfo(sockaddr, flags): + """ + getnameinfo(sockaddr, flags) -> (host, port) + + Get host and port for a sockaddr. + + .. seealso:: :doc:`dns` + """ + return get_hub().resolver.getnameinfo(sockaddr, flags) + + +def getfqdn(name=''): + """Get fully qualified domain name from name. + + An empty argument is interpreted as meaning the local host. + + First the hostname returned by gethostbyaddr() is checked, then + possibly existing aliases. In case no FQDN is available, hostname + from gethostname() is returned. + """ + # pylint: disable=undefined-variable + name = name.strip() + if not name or name == '0.0.0.0': + name = gethostname() + try: + hostname, aliases, _ = gethostbyaddr(name) + except error: + pass + else: + aliases.insert(0, hostname) + for name in aliases: # EWW! pylint:disable=redefined-argument-from-local + if isinstance(name, bytes): + if b'.' in name: + break + elif '.' in name: + break + else: + name = hostname + return name diff --git a/python/gevent/_ssl2.py b/python/gevent/_ssl2.py new file mode 100644 index 0000000..cf76aca --- /dev/null +++ b/python/gevent/_ssl2.py @@ -0,0 +1,436 @@ +# Wrapper module for _ssl. Written by Bill Janssen. +# Ported to gevent by Denis Bilenko. +"""SSL wrapper for socket objects on Python 2.7.8 and below. + +For the documentation, refer to :mod:`ssl` module manual. + +This module implements cooperative SSL socket wrappers. +""" + +from __future__ import absolute_import +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable,arguments-differ,no-member + +import ssl as __ssl__ + +_ssl = __ssl__._ssl + +import sys +import errno +from gevent._socket2 import socket +from gevent.socket import _fileobject, timeout_default +from gevent.socket import error as socket_error, EWOULDBLOCK +from gevent.socket import timeout as _socket_timeout +from gevent._compat import PYPY +from gevent._util import copy_globals + + +__implements__ = ['SSLSocket', + 'wrap_socket', + 'get_server_certificate', + 'sslwrap_simple'] + +# Import all symbols from Python's ssl.py, except those that we are implementing +# and "private" symbols. +__imports__ = copy_globals(__ssl__, globals(), + # SSLSocket *must* subclass gevent.socket.socket; see issue 597 + names_to_ignore=__implements__ + ['socket'], + dunder_names_to_keep=()) + + +# Py2.6 can get RAND_status added twice +__all__ = list(set(__implements__) | set(__imports__)) +if 'namedtuple' in __all__: + __all__.remove('namedtuple') + +class SSLSocket(socket): + """ + gevent `ssl.SSLSocket <https://docs.python.org/2.6/library/ssl.html#sslsocket-objects>`_ + for Pythons < 2.7.9. + """ + + def __init__(self, sock, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, + ciphers=None): + socket.__init__(self, _sock=sock) + + if PYPY: + sock._drop() + + if certfile and not keyfile: + keyfile = certfile + # see if it's connected + try: + socket.getpeername(self) + except socket_error as e: + if e.args[0] != errno.ENOTCONN: + raise + # no, no connection yet + self._sslobj = None + else: + # yes, create the SSL object + if ciphers is None: + self._sslobj = _ssl.sslwrap(self._sock, server_side, + keyfile, certfile, + cert_reqs, ssl_version, ca_certs) + else: + self._sslobj = _ssl.sslwrap(self._sock, server_side, + keyfile, certfile, + cert_reqs, ssl_version, ca_certs, + ciphers) + if do_handshake_on_connect: + self.do_handshake() + self.keyfile = keyfile + self.certfile = certfile + self.cert_reqs = cert_reqs + self.ssl_version = ssl_version + self.ca_certs = ca_certs + self.ciphers = ciphers + self.do_handshake_on_connect = do_handshake_on_connect + self.suppress_ragged_eofs = suppress_ragged_eofs + self._makefile_refs = 0 + + def read(self, len=1024): + """Read up to LEN bytes and return them. + Return zero-length string on EOF.""" + while True: + try: + return self._sslobj.read(len) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: + return '' + elif ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + sys.exc_clear() + # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional + self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) + else: + raise + + def write(self, data): + """Write DATA to the underlying SSL channel. Returns + number of bytes of DATA actually transmitted.""" + while True: + try: + return self._sslobj.write(data) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) + else: + raise + + def getpeercert(self, binary_form=False): + """Returns a formatted version of the data in the + certificate provided by the other end of the SSL channel. + Return None if no certificate was provided, {} if a + certificate was provided, but not validated.""" + return self._sslobj.peer_certificate(binary_form) + + def cipher(self): + if not self._sslobj: + return None + return self._sslobj.cipher() + + def send(self, data, flags=0, timeout=timeout_default): + if timeout is timeout_default: + timeout = self.timeout + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to send() on %s" % + self.__class__) + while True: + try: + v = self._sslobj.write(data) + except SSLError as x: + if x.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + return 0 + sys.exc_clear() + self._wait(self._read_event) + elif x.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + return 0 + sys.exc_clear() + self._wait(self._write_event) + else: + raise + else: + return v + else: + return socket.send(self, data, flags, timeout) + # is it possible for sendall() to send some data without encryption if another end shut down SSL? + + def sendall(self, data, flags=0): + try: + socket.sendall(self, data) + except _socket_timeout as ex: + if self.timeout == 0.0: + # Python 2 simply *hangs* in this case, which is bad, but + # Python 3 raises SSLWantWriteError. We do the same. + raise SSLError(SSL_ERROR_WANT_WRITE) + # Convert the socket.timeout back to the sslerror + raise SSLError(*ex.args) + + def sendto(self, *args): + if self._sslobj: + raise ValueError("sendto not allowed on instances of %s" % + self.__class__) + else: + return socket.sendto(self, *args) + + def recv(self, buflen=1024, flags=0): + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to recv() on %s" % + self.__class__) + # QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior? + return self.read(buflen) + else: + return socket.recv(self, buflen, flags) + + def recv_into(self, buffer, nbytes=None, flags=0): + if buffer and (nbytes is None): + nbytes = len(buffer) + elif nbytes is None: + nbytes = 1024 + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to recv_into() on %s" % + self.__class__) + while True: + try: + tmp_buffer = self.read(nbytes) + v = len(tmp_buffer) + buffer[:v] = tmp_buffer + return v + except SSLError as x: + if x.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + continue + else: + raise + else: + return socket.recv_into(self, buffer, nbytes, flags) + + def recvfrom(self, *args): + if self._sslobj: + raise ValueError("recvfrom not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom(self, *args) + + def recvfrom_into(self, *args): + if self._sslobj: + raise ValueError("recvfrom_into not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom_into(self, *args) + + def pending(self): + if self._sslobj: + return self._sslobj.pending() + return 0 + + def _sslobj_shutdown(self): + while True: + try: + return self._sslobj.shutdown() + except SSLError as ex: + if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: + return '' + elif ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) + else: + raise + + def unwrap(self): + if self._sslobj: + s = self._sslobj_shutdown() + self._sslobj = None + return socket(_sock=s) + else: + raise ValueError("No SSL wrapper around " + str(self)) + + def shutdown(self, how): + self._sslobj = None + socket.shutdown(self, how) + + def close(self): + if self._makefile_refs < 1: + self._sslobj = None + socket.close(self) + else: + self._makefile_refs -= 1 + + if PYPY: + + def _reuse(self): + self._makefile_refs += 1 + + def _drop(self): + if self._makefile_refs < 1: + self.close() + else: + self._makefile_refs -= 1 + + def do_handshake(self): + """Perform a TLS/SSL handshake.""" + while True: + try: + return self._sslobj.do_handshake() + except SSLError as ex: + if ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) + else: + raise + + def connect(self, addr): + """Connects to remote ADDR, and then wraps the connection in + an SSL channel.""" + # Here we assume that the socket is client-side, and not + # connected at the time of the call. We connect it, then wrap it. + if self._sslobj: + raise ValueError("attempt to connect already-connected SSLSocket!") + socket.connect(self, addr) + if self.ciphers is None: + self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile, + self.cert_reqs, self.ssl_version, + self.ca_certs) + else: + self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile, + self.cert_reqs, self.ssl_version, + self.ca_certs, self.ciphers) + if self.do_handshake_on_connect: + self.do_handshake() + + def accept(self): + """Accepts a new connection from a remote client, and returns + a tuple containing that new connection wrapped with a server-side + SSL channel, and the address of the remote client.""" + sock = self._sock + while True: + try: + client_socket, address = sock.accept() + break + except socket_error as ex: + if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event) + + sslobj = SSLSocket(client_socket, + keyfile=self.keyfile, + certfile=self.certfile, + server_side=True, + cert_reqs=self.cert_reqs, + ssl_version=self.ssl_version, + ca_certs=self.ca_certs, + do_handshake_on_connect=self.do_handshake_on_connect, + suppress_ragged_eofs=self.suppress_ragged_eofs, + ciphers=self.ciphers) + + return sslobj, address + + def makefile(self, mode='r', bufsize=-1): + """Make and return a file-like object that + works with the SSL connection. Just use the code + from the socket module.""" + if not PYPY: + self._makefile_refs += 1 + # close=True so as to decrement the reference count when done with + # the file-like object. + return _fileobject(self, mode, bufsize, close=True) + +if PYPY or not hasattr(SSLSocket, 'timeout'): + # PyPy (and certain versions of CPython) doesn't have a direct + # 'timeout' property on raw sockets, because that's not part of + # the documented specification. We may wind up wrapping a raw + # socket (when ssl is used with PyWSGI) or a gevent socket, which + # does have a read/write timeout property as an alias for + # get/settimeout, so make sure that's always the case because + # pywsgi can depend on that. + SSLSocket.timeout = property(lambda self: self.gettimeout(), + lambda self, value: self.settimeout(value)) + + +_SSLErrorReadTimeout = SSLError('The read operation timed out') +_SSLErrorWriteTimeout = SSLError('The write operation timed out') +_SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out') + + +def wrap_socket(sock, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, ciphers=None): + """Create a new :class:`SSLSocket` instance.""" + return SSLSocket(sock, keyfile=keyfile, certfile=certfile, + server_side=server_side, cert_reqs=cert_reqs, + ssl_version=ssl_version, ca_certs=ca_certs, + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs, + ciphers=ciphers) + + +def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): + """Retrieve the certificate from the server at the specified address, + and return it as a PEM-encoded string. + If 'ca_certs' is specified, validate the server cert against it. + If 'ssl_version' is specified, use it in the connection attempt.""" + + if ca_certs is not None: + cert_reqs = CERT_REQUIRED + else: + cert_reqs = CERT_NONE + s = wrap_socket(socket(), ssl_version=ssl_version, + cert_reqs=cert_reqs, ca_certs=ca_certs) + s.connect(addr) + dercert = s.getpeercert(True) + s.close() + return DER_cert_to_PEM_cert(dercert) + + +def sslwrap_simple(sock, keyfile=None, certfile=None): + """A replacement for the old socket.ssl function. Designed + for compatability with Python 2.5 and earlier. Will disappear in + Python 3.0.""" + return SSLSocket(sock, keyfile, certfile) diff --git a/python/gevent/_ssl3.py b/python/gevent/_ssl3.py new file mode 100644 index 0000000..81b709c --- /dev/null +++ b/python/gevent/_ssl3.py @@ -0,0 +1,661 @@ +# Wrapper module for _ssl. Written by Bill Janssen. +# Ported to gevent by Denis Bilenko. +"""SSL wrapper for socket objects on Python 3. + +For the documentation, refer to :mod:`ssl` module manual. + +This module implements cooperative SSL socket wrappers. +""" +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable + +from __future__ import absolute_import +import ssl as __ssl__ + +_ssl = __ssl__._ssl # pylint:disable=no-member + +import errno +from gevent.socket import socket, timeout_default +from gevent.socket import error as socket_error +from gevent.socket import timeout as _socket_timeout +from gevent._util import copy_globals + +from weakref import ref as _wref + +__implements__ = [ + 'SSLContext', + 'SSLSocket', + 'wrap_socket', + 'get_server_certificate', +] + +# Import all symbols from Python's ssl.py, except those that we are implementing +# and "private" symbols. +__imports__ = copy_globals(__ssl__, globals(), + # SSLSocket *must* subclass gevent.socket.socket; see issue 597 + names_to_ignore=__implements__ + ['socket'], + dunder_names_to_keep=()) + +__all__ = __implements__ + __imports__ +if 'namedtuple' in __all__: + __all__.remove('namedtuple') + +orig_SSLContext = __ssl__.SSLContext # pylint:disable=no-member + + +class SSLContext(orig_SSLContext): + def wrap_socket(self, sock, server_side=False, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, + server_hostname=None, + session=None): + # pylint:disable=arguments-differ + # (3.6 adds session) + # Sadly, using *args and **kwargs doesn't work + return SSLSocket(sock=sock, server_side=server_side, + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs, + server_hostname=server_hostname, + _context=self, + _session=session) + + if not hasattr(orig_SSLContext, 'check_hostname'): + # Python 3.3 lacks this + check_hostname = False + + if hasattr(orig_SSLContext.options, 'setter'): + # In 3.6, these became properties. They want to access the + # property __set__ method in the superclass, and they do so by using + # super(SSLContext, SSLContext). But we rebind SSLContext when we monkey + # patch, which causes infinite recursion. + # https://github.com/python/cpython/commit/328067c468f82e4ec1b5c510a4e84509e010f296 + # pylint:disable=no-member + @orig_SSLContext.options.setter + def options(self, value): + super(orig_SSLContext, orig_SSLContext).options.__set__(self, value) + + @orig_SSLContext.verify_flags.setter + def verify_flags(self, value): + super(orig_SSLContext, orig_SSLContext).verify_flags.__set__(self, value) + + @orig_SSLContext.verify_mode.setter + def verify_mode(self, value): + super(orig_SSLContext, orig_SSLContext).verify_mode.__set__(self, value) + + +class _contextawaresock(socket._gevent_sock_class): # Python 2: pylint:disable=slots-on-old-class + # We have to pass the raw stdlib socket to SSLContext.wrap_socket. + # That method in turn can pass that object on to things like SNI callbacks. + # It wouldn't have access to any of the attributes on the SSLSocket, like + # context, that it's supposed to (see test_ssl.test_sni_callback). Our + # solution is to keep a weak reference to the SSLSocket on the raw + # socket and delegate. + + # We keep it in a slot to avoid having the ability to set any attributes + # we're not prepared for (because we don't know what to delegate.) + + __slots__ = ('_sslsock',) + + @property + def context(self): + return self._sslsock().context + + @context.setter + def context(self, ctx): + self._sslsock().context = ctx + + @property + def session(self): + """The SSLSession for client socket.""" + return self._sslsock().session + + @session.setter + def session(self, session): + self._sslsock().session = session + + def __getattr__(self, name): + try: + return getattr(self._sslsock(), name) + except RuntimeError: + # XXX: If the attribute doesn't exist, + # we infinitely recurse + pass + raise AttributeError(name) + + +class SSLSocket(socket): + """ + gevent `ssl.SSLSocket <https://docs.python.org/3/library/ssl.html#ssl-sockets>`_ + for Python 3. + """ + + # pylint:disable=too-many-instance-attributes,too-many-public-methods + + _gevent_sock_class = _contextawaresock + + def __init__(self, sock=None, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, + suppress_ragged_eofs=True, npn_protocols=None, ciphers=None, + server_hostname=None, + _session=None, # 3.6 + _context=None): + # pylint:disable=too-many-locals,too-many-statements,too-many-branches + if _context: + self._context = _context + else: + if server_side and not certfile: + raise ValueError("certfile must be specified for server-side " + "operations") + if keyfile and not certfile: + raise ValueError("certfile must be specified") + if certfile and not keyfile: + keyfile = certfile + self._context = SSLContext(ssl_version) + self._context.verify_mode = cert_reqs + if ca_certs: + self._context.load_verify_locations(ca_certs) + if certfile: + self._context.load_cert_chain(certfile, keyfile) + if npn_protocols: + self._context.set_npn_protocols(npn_protocols) + if ciphers: + self._context.set_ciphers(ciphers) + self.keyfile = keyfile + self.certfile = certfile + self.cert_reqs = cert_reqs + self.ssl_version = ssl_version + self.ca_certs = ca_certs + self.ciphers = ciphers + # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get + # mixed in. + if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: + raise NotImplementedError("only stream sockets are supported") + if server_side: + if server_hostname: + raise ValueError("server_hostname can only be specified " + "in client mode") + if _session is not None: + raise ValueError("session can only be specified " + "in client mode") + if self._context.check_hostname and not server_hostname: + raise ValueError("check_hostname requires server_hostname") + self._session = _session + self.server_side = server_side + self.server_hostname = server_hostname + self.do_handshake_on_connect = do_handshake_on_connect + self.suppress_ragged_eofs = suppress_ragged_eofs + connected = False + if sock is not None: + socket.__init__(self, + family=sock.family, + type=sock.type, + proto=sock.proto, + fileno=sock.fileno()) + self.settimeout(sock.gettimeout()) + # see if it's connected + try: + sock.getpeername() + except socket_error as e: + if e.errno != errno.ENOTCONN: + raise + else: + connected = True + sock.detach() + elif fileno is not None: + socket.__init__(self, fileno=fileno) + else: + socket.__init__(self, family=family, type=type, proto=proto) + + self._sock._sslsock = _wref(self) + self._closed = False + self._sslobj = None + self._connected = connected + if connected: + # create the SSL object + try: + self._sslobj = self._context._wrap_socket(self._sock, server_side, + server_hostname) + if _session is not None: # 3.6 + self._sslobj = SSLObject(self._sslobj, owner=self, session=self._session) + if do_handshake_on_connect: + timeout = self.gettimeout() + if timeout == 0.0: + # non-blocking + raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") + self.do_handshake() + + except socket_error as x: + self.close() + raise x + + @property + def context(self): + return self._context + + @context.setter + def context(self, ctx): + self._context = ctx + self._sslobj.context = ctx + + @property + def session(self): + """The SSLSession for client socket.""" + if self._sslobj is not None: + return self._sslobj.session + + @session.setter + def session(self, session): + self._session = session + if self._sslobj is not None: + self._sslobj.session = session + + @property + def session_reused(self): + """Was the client session reused during handshake""" + if self._sslobj is not None: + return self._sslobj.session_reused + + def dup(self): + raise NotImplementedError("Can't dup() %s instances" % + self.__class__.__name__) + + def _checkClosed(self, msg=None): + # raise an exception here if you wish to check for spurious closes + pass + + def _check_connected(self): + if not self._connected: + # getpeername() will raise ENOTCONN if the socket is really + # not connected; note that we can be connected even without + # _connected being set, e.g. if connect() first returned + # EAGAIN. + self.getpeername() + + def read(self, len=1024, buffer=None): + """Read up to LEN bytes and return them. + Return zero-length string on EOF.""" + # pylint:disable=too-many-branches + self._checkClosed() + + while True: + if not self._sslobj: + raise ValueError("Read on closed or unwrapped SSL socket.") + if len == 0: + return b'' if buffer is None else 0 + # Negative lengths are handled natively when the buffer is None + # to raise a ValueError + try: + if buffer is not None: + return self._sslobj.read(len, buffer) + return self._sslobj.read(len or 1024) + except SSLWantReadError: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) + except SSLWantWriteError: + if self.timeout == 0.0: + raise + # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional + self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: + if buffer is None: + return b'' + return 0 + else: + raise + + def write(self, data): + """Write DATA to the underlying SSL channel. Returns + number of bytes of DATA actually transmitted.""" + self._checkClosed() + + while True: + if not self._sslobj: + raise ValueError("Write on closed or unwrapped SSL socket.") + + try: + return self._sslobj.write(data) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) + else: + raise + + def getpeercert(self, binary_form=False): + """Returns a formatted version of the data in the + certificate provided by the other end of the SSL channel. + Return None if no certificate was provided, {} if a + certificate was provided, but not validated.""" + + self._checkClosed() + self._check_connected() + try: + c = self._sslobj.peer_certificate + except AttributeError: + # 3.6 + c = self._sslobj.getpeercert + + return c(binary_form) + + def selected_npn_protocol(self): + self._checkClosed() + if not self._sslobj or not _ssl.HAS_NPN: + return None + return self._sslobj.selected_npn_protocol() + + if hasattr(_ssl, 'HAS_ALPN'): + # 3.5+ + def selected_alpn_protocol(self): + self._checkClosed() + if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member + return None + return self._sslobj.selected_alpn_protocol() + + def shared_ciphers(self): + """Return a list of ciphers shared by the client during the handshake or + None if this is not a valid server connection. + """ + return self._sslobj.shared_ciphers() + + def version(self): + """Return a string identifying the protocol version used by the + current SSL channel. """ + if not self._sslobj: + return None + return self._sslobj.version() + + # We inherit sendfile from super(); it always uses `send` + + def cipher(self): + self._checkClosed() + if not self._sslobj: + return None + return self._sslobj.cipher() + + def compression(self): + self._checkClosed() + if not self._sslobj: + return None + return self._sslobj.compression() + + def send(self, data, flags=0, timeout=timeout_default): + self._checkClosed() + if timeout is timeout_default: + timeout = self.timeout + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to send() on %s" % + self.__class__) + while True: + try: + return self._sslobj.write(data) + except SSLWantReadError: + if self.timeout == 0.0: + return 0 + self._wait(self._read_event) + except SSLWantWriteError: + if self.timeout == 0.0: + return 0 + self._wait(self._write_event) + else: + return socket.send(self, data, flags, timeout) + + def sendto(self, data, flags_or_addr, addr=None): + self._checkClosed() + if self._sslobj: + raise ValueError("sendto not allowed on instances of %s" % + self.__class__) + elif addr is None: + return socket.sendto(self, data, flags_or_addr) + else: + return socket.sendto(self, data, flags_or_addr, addr) + + def sendmsg(self, *args, **kwargs): + # Ensure programs don't send data unencrypted if they try to + # use this method. + raise NotImplementedError("sendmsg not allowed on instances of %s" % + self.__class__) + + def sendall(self, data, flags=0): + self._checkClosed() + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to sendall() on %s" % + self.__class__) + + try: + return socket.sendall(self, data, flags) + except _socket_timeout: + if self.timeout == 0.0: + # Raised by the stdlib on non-blocking sockets + raise SSLWantWriteError("The operation did not complete (write)") + raise + + def recv(self, buflen=1024, flags=0): + self._checkClosed() + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to recv() on %s" % + self.__class__) + if buflen == 0: + # https://github.com/python/cpython/commit/00915577dd84ba75016400793bf547666e6b29b5 + # Python #23804 + return b'' + return self.read(buflen) + else: + return socket.recv(self, buflen, flags) + + def recv_into(self, buffer, nbytes=None, flags=0): + self._checkClosed() + if buffer and (nbytes is None): + nbytes = len(buffer) + elif nbytes is None: + nbytes = 1024 + if self._sslobj: + if flags != 0: + raise ValueError("non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) + return self.read(nbytes, buffer) + else: + return socket.recv_into(self, buffer, nbytes, flags) + + def recvfrom(self, buflen=1024, flags=0): + self._checkClosed() + if self._sslobj: + raise ValueError("recvfrom not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom(self, buflen, flags) + + def recvfrom_into(self, buffer, nbytes=None, flags=0): + self._checkClosed() + if self._sslobj: + raise ValueError("recvfrom_into not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom_into(self, buffer, nbytes, flags) + + def recvmsg(self, *args, **kwargs): + raise NotImplementedError("recvmsg not allowed on instances of %s" % + self.__class__) + + def recvmsg_into(self, *args, **kwargs): + raise NotImplementedError("recvmsg_into not allowed on instances of " + "%s" % self.__class__) + + def pending(self): + self._checkClosed() + if self._sslobj: + return self._sslobj.pending() + return 0 + + def shutdown(self, how): + self._checkClosed() + self._sslobj = None + socket.shutdown(self, how) + + def unwrap(self): + if self._sslobj: + while True: + try: + s = self._sslobj.shutdown() + break + except SSLWantReadError: + if self.timeout == 0.0: + return 0 + self._wait(self._read_event) + except SSLWantWriteError: + if self.timeout == 0.0: + return 0 + self._wait(self._write_event) + + self._sslobj = None + # The return value of shutting down the SSLObject is the + # original wrapped socket, i.e., _contextawaresock. But that + # object doesn't have the gevent wrapper around it so it can't + # be used. We have to wrap it back up with a gevent wrapper. + sock = socket(family=s.family, type=s.type, proto=s.proto, fileno=s.fileno()) + s.detach() + return sock + else: + raise ValueError("No SSL wrapper around " + str(self)) + + def _real_close(self): + self._sslobj = None + # self._closed = True + socket._real_close(self) + + def do_handshake(self): + """Perform a TLS/SSL handshake.""" + self._check_connected() + while True: + try: + self._sslobj.do_handshake() + break + except SSLWantReadError: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) + except SSLWantWriteError: + if self.timeout == 0.0: + raise + self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) + + if self._context.check_hostname: + if not self.server_hostname: + raise ValueError("check_hostname needs server_hostname " + "argument") + match_hostname(self.getpeercert(), self.server_hostname) + + def _real_connect(self, addr, connect_ex): + if self.server_side: + raise ValueError("can't connect in server-side mode") + # Here we assume that the socket is client-side, and not + # connected at the time of the call. We connect it, then wrap it. + if self._connected: + raise ValueError("attempt to connect already-connected SSLSocket!") + self._sslobj = self._context._wrap_socket(self._sock, False, self.server_hostname) + if self._session is not None: # 3.6 + self._sslobj = SSLObject(self._sslobj, owner=self, session=self._session) + try: + if connect_ex: + rc = socket.connect_ex(self, addr) + else: + rc = None + socket.connect(self, addr) + if not rc: + if self.do_handshake_on_connect: + self.do_handshake() + self._connected = True + return rc + except socket_error: + self._sslobj = None + raise + + def connect(self, addr): + """Connects to remote ADDR, and then wraps the connection in + an SSL channel.""" + self._real_connect(addr, False) + + def connect_ex(self, addr): + """Connects to remote ADDR, and then wraps the connection in + an SSL channel.""" + return self._real_connect(addr, True) + + def accept(self): + """Accepts a new connection from a remote client, and returns + a tuple containing that new connection wrapped with a server-side + SSL channel, and the address of the remote client.""" + + newsock, addr = socket.accept(self) + newsock = self._context.wrap_socket(newsock, + do_handshake_on_connect=self.do_handshake_on_connect, + suppress_ragged_eofs=self.suppress_ragged_eofs, + server_side=True) + return newsock, addr + + def get_channel_binding(self, cb_type="tls-unique"): + """Get channel binding data for current connection. Raise ValueError + if the requested `cb_type` is not supported. Return bytes of the data + or None if the data is not available (e.g. before the handshake). + """ + if cb_type not in CHANNEL_BINDING_TYPES: + raise ValueError("Unsupported channel binding type") + if cb_type != "tls-unique": + raise NotImplementedError("{0} channel binding type not implemented".format(cb_type)) + if self._sslobj is None: + return None + return self._sslobj.tls_unique_cb() + + +# Python 3.2 onwards raise normal timeout errors, not SSLError. +# See https://bugs.python.org/issue10272 +_SSLErrorReadTimeout = _socket_timeout('The read operation timed out') +_SSLErrorWriteTimeout = _socket_timeout('The write operation timed out') +_SSLErrorHandshakeTimeout = _socket_timeout('The handshake operation timed out') + + +def wrap_socket(sock, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, + ciphers=None): + + return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile, + server_side=server_side, cert_reqs=cert_reqs, + ssl_version=ssl_version, ca_certs=ca_certs, + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs, + ciphers=ciphers) + + +def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): + """Retrieve the certificate from the server at the specified address, + and return it as a PEM-encoded string. + If 'ca_certs' is specified, validate the server cert against it. + If 'ssl_version' is specified, use it in the connection attempt.""" + + _, _ = addr + if ca_certs is not None: + cert_reqs = CERT_REQUIRED + else: + cert_reqs = CERT_NONE + s = create_connection(addr) + s = wrap_socket(s, ssl_version=ssl_version, + cert_reqs=cert_reqs, ca_certs=ca_certs) + dercert = s.getpeercert(True) + s.close() + return DER_cert_to_PEM_cert(dercert) diff --git a/python/gevent/_sslgte279.py b/python/gevent/_sslgte279.py new file mode 100644 index 0000000..92280ad --- /dev/null +++ b/python/gevent/_sslgte279.py @@ -0,0 +1,714 @@ +# Wrapper module for _ssl. Written by Bill Janssen. +# Ported to gevent by Denis Bilenko. +"""SSL wrapper for socket objects on Python 2.7.9 and above. + +For the documentation, refer to :mod:`ssl` module manual. + +This module implements cooperative SSL socket wrappers. +""" + +from __future__ import absolute_import +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable +# pylint: disable=too-many-instance-attributes,too-many-locals,too-many-statements,too-many-branches +# pylint: disable=arguments-differ,too-many-public-methods + +import ssl as __ssl__ + +_ssl = __ssl__._ssl # pylint:disable=no-member + +import errno +from gevent._socket2 import socket +from gevent.socket import timeout_default +from gevent.socket import create_connection +from gevent.socket import error as socket_error +from gevent.socket import timeout as _socket_timeout +from gevent._compat import PYPY +from gevent._util import copy_globals + +__implements__ = [ + 'SSLContext', + 'SSLSocket', + 'wrap_socket', + 'get_server_certificate', + 'create_default_context', + '_create_unverified_context', + '_create_default_https_context', + '_create_stdlib_context', +] + +# Import all symbols from Python's ssl.py, except those that we are implementing +# and "private" symbols. +__imports__ = copy_globals(__ssl__, globals(), + # SSLSocket *must* subclass gevent.socket.socket; see issue 597 and 801 + names_to_ignore=__implements__ + ['socket', 'create_connection'], + dunder_names_to_keep=()) + +try: + _delegate_methods +except NameError: # PyPy doesn't expose this detail + _delegate_methods = ('recv', 'recvfrom', 'recv_into', 'recvfrom_into', 'send', 'sendto') + +__all__ = __implements__ + __imports__ +if 'namedtuple' in __all__: + __all__.remove('namedtuple') + +orig_SSLContext = __ssl__.SSLContext # pylint: disable=no-member + + +class SSLContext(orig_SSLContext): + def wrap_socket(self, sock, server_side=False, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, + server_hostname=None): + return SSLSocket(sock=sock, server_side=server_side, + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs, + server_hostname=server_hostname, + _context=self) + + +def create_default_context(purpose=Purpose.SERVER_AUTH, cafile=None, + capath=None, cadata=None): + """Create a SSLContext object with default settings. + + NOTE: The protocol and settings may change anytime without prior + deprecation. The values represent a fair balance between maximum + compatibility and security. + """ + if not isinstance(purpose, _ASN1Object): + raise TypeError(purpose) + + context = SSLContext(PROTOCOL_SSLv23) + + # SSLv2 considered harmful. + context.options |= OP_NO_SSLv2 + + # SSLv3 has problematic security and is only required for really old + # clients such as IE6 on Windows XP + context.options |= OP_NO_SSLv3 + + # disable compression to prevent CRIME attacks (OpenSSL 1.0+) + context.options |= getattr(_ssl, "OP_NO_COMPRESSION", 0) + + if purpose == Purpose.SERVER_AUTH: + # verify certs and host name in client mode + context.verify_mode = CERT_REQUIRED + context.check_hostname = True # pylint: disable=attribute-defined-outside-init + elif purpose == Purpose.CLIENT_AUTH: + # Prefer the server's ciphers by default so that we get stronger + # encryption + context.options |= getattr(_ssl, "OP_CIPHER_SERVER_PREFERENCE", 0) + + # Use single use keys in order to improve forward secrecy + context.options |= getattr(_ssl, "OP_SINGLE_DH_USE", 0) + context.options |= getattr(_ssl, "OP_SINGLE_ECDH_USE", 0) + + # disallow ciphers with known vulnerabilities + context.set_ciphers(_RESTRICTED_SERVER_CIPHERS) + + if cafile or capath or cadata: + context.load_verify_locations(cafile, capath, cadata) + elif context.verify_mode != CERT_NONE: + # no explicit cafile, capath or cadata but the verify mode is + # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system + # root CA certificates for the given purpose. This may fail silently. + context.load_default_certs(purpose) + return context + +def _create_unverified_context(protocol=PROTOCOL_SSLv23, cert_reqs=None, + check_hostname=False, purpose=Purpose.SERVER_AUTH, + certfile=None, keyfile=None, + cafile=None, capath=None, cadata=None): + """Create a SSLContext object for Python stdlib modules + + All Python stdlib modules shall use this function to create SSLContext + objects in order to keep common settings in one place. The configuration + is less restrict than create_default_context()'s to increase backward + compatibility. + """ + if not isinstance(purpose, _ASN1Object): + raise TypeError(purpose) + + context = SSLContext(protocol) + # SSLv2 considered harmful. + context.options |= OP_NO_SSLv2 + # SSLv3 has problematic security and is only required for really old + # clients such as IE6 on Windows XP + context.options |= OP_NO_SSLv3 + + if cert_reqs is not None: + context.verify_mode = cert_reqs + context.check_hostname = check_hostname # pylint: disable=attribute-defined-outside-init + + if keyfile and not certfile: + raise ValueError("certfile must be specified") + if certfile or keyfile: + context.load_cert_chain(certfile, keyfile) + + # load CA root certs + if cafile or capath or cadata: + context.load_verify_locations(cafile, capath, cadata) + elif context.verify_mode != CERT_NONE: + # no explicit cafile, capath or cadata but the verify mode is + # CERT_OPTIONAL or CERT_REQUIRED. Let's try to load default system + # root CA certificates for the given purpose. This may fail silently. + context.load_default_certs(purpose) + + return context + +# Used by http.client if no context is explicitly passed. +_create_default_https_context = create_default_context + + +# Backwards compatibility alias, even though it's not a public name. +_create_stdlib_context = _create_unverified_context + +class SSLSocket(socket): + """ + gevent `ssl.SSLSocket <https://docs.python.org/2/library/ssl.html#ssl-sockets>`_ + for Pythons >= 2.7.9 but less than 3. + """ + + def __init__(self, sock=None, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, + suppress_ragged_eofs=True, npn_protocols=None, ciphers=None, + server_hostname=None, + _context=None): + # fileno is ignored + # pylint: disable=unused-argument + if _context: + self._context = _context + else: + if server_side and not certfile: + raise ValueError("certfile must be specified for server-side " + "operations") + if keyfile and not certfile: + raise ValueError("certfile must be specified") + if certfile and not keyfile: + keyfile = certfile + self._context = SSLContext(ssl_version) + self._context.verify_mode = cert_reqs + if ca_certs: + self._context.load_verify_locations(ca_certs) + if certfile: + self._context.load_cert_chain(certfile, keyfile) + if npn_protocols: + self._context.set_npn_protocols(npn_protocols) + if ciphers: + self._context.set_ciphers(ciphers) + self.keyfile = keyfile + self.certfile = certfile + self.cert_reqs = cert_reqs + self.ssl_version = ssl_version + self.ca_certs = ca_certs + self.ciphers = ciphers + # Can't use sock.type as other flags (such as SOCK_NONBLOCK) get + # mixed in. + if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: + raise NotImplementedError("only stream sockets are supported") + + if PYPY: + socket.__init__(self, _sock=sock) + sock._drop() + else: + # CPython: XXX: Must pass the underlying socket, not our + # potential wrapper; test___example_servers fails the SSL test + # with a client-side EOF error. (Why?) + socket.__init__(self, _sock=sock._sock) + + # The initializer for socket overrides the methods send(), recv(), etc. + # in the instance, which we don't need -- but we want to provide the + # methods defined in SSLSocket. + for attr in _delegate_methods: + try: + delattr(self, attr) + except AttributeError: + pass + if server_side and server_hostname: + raise ValueError("server_hostname can only be specified " + "in client mode") + if self._context.check_hostname and not server_hostname: + raise ValueError("check_hostname requires server_hostname") + self.server_side = server_side + self.server_hostname = server_hostname + self.do_handshake_on_connect = do_handshake_on_connect + self.suppress_ragged_eofs = suppress_ragged_eofs + self.settimeout(sock.gettimeout()) + + # See if we are connected + try: + self.getpeername() + except socket_error as e: + if e.errno != errno.ENOTCONN: + raise + connected = False + else: + connected = True + + self._makefile_refs = 0 + self._closed = False + self._sslobj = None + self._connected = connected + if connected: + # create the SSL object + try: + self._sslobj = self._context._wrap_socket(self._sock, server_side, + server_hostname, ssl_sock=self) + if do_handshake_on_connect: + timeout = self.gettimeout() + if timeout == 0.0: + # non-blocking + raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") + self.do_handshake() + + except socket_error as x: + self.close() + raise x + + + @property + def context(self): + return self._context + + @context.setter + def context(self, ctx): + self._context = ctx + self._sslobj.context = ctx + + def dup(self): + raise NotImplementedError("Can't dup() %s instances" % + self.__class__.__name__) + + def _checkClosed(self, msg=None): + # raise an exception here if you wish to check for spurious closes + pass + + def _check_connected(self): + if not self._connected: + # getpeername() will raise ENOTCONN if the socket is really + # not connected; note that we can be connected even without + # _connected being set, e.g. if connect() first returned + # EAGAIN. + self.getpeername() + + def read(self, len=1024, buffer=None): + """Read up to LEN bytes and return them. + Return zero-length string on EOF.""" + self._checkClosed() + + while 1: + if not self._sslobj: + raise ValueError("Read on closed or unwrapped SSL socket.") + if len == 0: + return b'' if buffer is None else 0 + if len < 0 and buffer is None: + # This is handled natively in python 2.7.12+ + raise ValueError("Negative read length") + try: + if buffer is not None: + return self._sslobj.read(len, buffer) + return self._sslobj.read(len or 1024) + except SSLWantReadError: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) + except SSLWantWriteError: + if self.timeout == 0.0: + raise + # note: using _SSLErrorReadTimeout rather than _SSLErrorWriteTimeout below is intentional + self._wait(self._write_event, timeout_exc=_SSLErrorReadTimeout) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: + if buffer is not None: + return 0 + return b'' + else: + raise + + def write(self, data): + """Write DATA to the underlying SSL channel. Returns + number of bytes of DATA actually transmitted.""" + self._checkClosed() + + while 1: + if not self._sslobj: + raise ValueError("Write on closed or unwrapped SSL socket.") + + try: + return self._sslobj.write(data) + except SSLError as ex: + if ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) + else: + raise + + def getpeercert(self, binary_form=False): + """Returns a formatted version of the data in the + certificate provided by the other end of the SSL channel. + Return None if no certificate was provided, {} if a + certificate was provided, but not validated.""" + + self._checkClosed() + self._check_connected() + return self._sslobj.peer_certificate(binary_form) + + def selected_npn_protocol(self): + self._checkClosed() + if not self._sslobj or not _ssl.HAS_NPN: + return None + return self._sslobj.selected_npn_protocol() + + if hasattr(_ssl, 'HAS_ALPN'): + # 2.7.10+ + def selected_alpn_protocol(self): + self._checkClosed() + if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member + return None + return self._sslobj.selected_alpn_protocol() + + def cipher(self): + self._checkClosed() + if not self._sslobj: + return None + return self._sslobj.cipher() + + def compression(self): + self._checkClosed() + if not self._sslobj: + return None + return self._sslobj.compression() + + def __check_flags(self, meth, flags): + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to %s on %s" % + (meth, self.__class__)) + + def send(self, data, flags=0, timeout=timeout_default): + self._checkClosed() + self.__check_flags('send', flags) + + if timeout is timeout_default: + timeout = self.timeout + + if not self._sslobj: + return socket.send(self, data, flags, timeout) + + while True: + try: + return self._sslobj.write(data) + except SSLWantReadError: + if self.timeout == 0.0: + return 0 + self._wait(self._read_event) + except SSLWantWriteError: + if self.timeout == 0.0: + return 0 + self._wait(self._write_event) + + def sendto(self, data, flags_or_addr, addr=None): + self._checkClosed() + if self._sslobj: + raise ValueError("sendto not allowed on instances of %s" % + self.__class__) + elif addr is None: + return socket.sendto(self, data, flags_or_addr) + else: + return socket.sendto(self, data, flags_or_addr, addr) + + def sendmsg(self, *args, **kwargs): + # Ensure programs don't send data unencrypted if they try to + # use this method. + raise NotImplementedError("sendmsg not allowed on instances of %s" % + self.__class__) + + def sendall(self, data, flags=0): + self._checkClosed() + self.__check_flags('sendall', flags) + + try: + socket.sendall(self, data) + except _socket_timeout as ex: + if self.timeout == 0.0: + # Python 2 simply *hangs* in this case, which is bad, but + # Python 3 raises SSLWantWriteError. We do the same. + raise SSLWantWriteError("The operation did not complete (write)") + # Convert the socket.timeout back to the sslerror + raise SSLError(*ex.args) + + def recv(self, buflen=1024, flags=0): + self._checkClosed() + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to recv() on %s" % + self.__class__) + if buflen == 0: + return b'' + return self.read(buflen) + else: + return socket.recv(self, buflen, flags) + + def recv_into(self, buffer, nbytes=None, flags=0): + self._checkClosed() + if buffer is not None and (nbytes is None): + # Fix for python bug #23804: bool(bytearray()) is False, + # but we should read 0 bytes. + nbytes = len(buffer) + elif nbytes is None: + nbytes = 1024 + if self._sslobj: + if flags != 0: + raise ValueError( + "non-zero flags not allowed in calls to recv_into() on %s" % + self.__class__) + return self.read(nbytes, buffer) + else: + return socket.recv_into(self, buffer, nbytes, flags) + + def recvfrom(self, buflen=1024, flags=0): + self._checkClosed() + if self._sslobj: + raise ValueError("recvfrom not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom(self, buflen, flags) + + def recvfrom_into(self, buffer, nbytes=None, flags=0): + self._checkClosed() + if self._sslobj: + raise ValueError("recvfrom_into not allowed on instances of %s" % + self.__class__) + else: + return socket.recvfrom_into(self, buffer, nbytes, flags) + + def recvmsg(self, *args, **kwargs): + raise NotImplementedError("recvmsg not allowed on instances of %s" % + self.__class__) + + def recvmsg_into(self, *args, **kwargs): + raise NotImplementedError("recvmsg_into not allowed on instances of " + "%s" % self.__class__) + + def pending(self): + self._checkClosed() + if self._sslobj: + return self._sslobj.pending() + return 0 + + def shutdown(self, how): + self._checkClosed() + self._sslobj = None + socket.shutdown(self, how) + + def close(self): + if self._makefile_refs < 1: + self._sslobj = None + socket.close(self) + else: + self._makefile_refs -= 1 + + if PYPY: + + def _reuse(self): + self._makefile_refs += 1 + + def _drop(self): + if self._makefile_refs < 1: + self.close() + else: + self._makefile_refs -= 1 + + def _sslobj_shutdown(self): + while True: + try: + return self._sslobj.shutdown() + except SSLError as ex: + if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: + return '' + elif ex.args[0] == SSL_ERROR_WANT_READ: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) + elif ex.args[0] == SSL_ERROR_WANT_WRITE: + if self.timeout == 0.0: + raise + sys.exc_clear() + self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout) + else: + raise + + def unwrap(self): + if self._sslobj: + s = self._sslobj_shutdown() + self._sslobj = None + return socket(_sock=s) # match _ssl2; critical to drop/reuse here on PyPy + else: + raise ValueError("No SSL wrapper around " + str(self)) + + def _real_close(self): + self._sslobj = None + socket._real_close(self) # pylint: disable=no-member + + def do_handshake(self): + """Perform a TLS/SSL handshake.""" + self._check_connected() + while True: + try: + self._sslobj.do_handshake() + break + except SSLWantReadError: + if self.timeout == 0.0: + raise + self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout) + except SSLWantWriteError: + if self.timeout == 0.0: + raise + self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout) + + if self._context.check_hostname: + if not self.server_hostname: + raise ValueError("check_hostname needs server_hostname " + "argument") + match_hostname(self.getpeercert(), self.server_hostname) + + def _real_connect(self, addr, connect_ex): + if self.server_side: + raise ValueError("can't connect in server-side mode") + # Here we assume that the socket is client-side, and not + # connected at the time of the call. We connect it, then wrap it. + if self._connected: + raise ValueError("attempt to connect already-connected SSLSocket!") + self._sslobj = self._context._wrap_socket(self._sock, False, self.server_hostname, ssl_sock=self) + try: + if connect_ex: + rc = socket.connect_ex(self, addr) + else: + rc = None + socket.connect(self, addr) + if not rc: + self._connected = True + if self.do_handshake_on_connect: + self.do_handshake() + return rc + except socket_error: + self._sslobj = None + raise + + def connect(self, addr): + """Connects to remote ADDR, and then wraps the connection in + an SSL channel.""" + self._real_connect(addr, False) + + def connect_ex(self, addr): + """Connects to remote ADDR, and then wraps the connection in + an SSL channel.""" + return self._real_connect(addr, True) + + def accept(self): + """Accepts a new connection from a remote client, and returns + a tuple containing that new connection wrapped with a server-side + SSL channel, and the address of the remote client.""" + + newsock, addr = socket.accept(self) + newsock = self._context.wrap_socket(newsock, + do_handshake_on_connect=self.do_handshake_on_connect, + suppress_ragged_eofs=self.suppress_ragged_eofs, + server_side=True) + return newsock, addr + + def makefile(self, mode='r', bufsize=-1): + + """Make and return a file-like object that + works with the SSL connection. Just use the code + from the socket module.""" + if not PYPY: + self._makefile_refs += 1 + # close=True so as to decrement the reference count when done with + # the file-like object. + return _fileobject(self, mode, bufsize, close=True) + + def get_channel_binding(self, cb_type="tls-unique"): + """Get channel binding data for current connection. Raise ValueError + if the requested `cb_type` is not supported. Return bytes of the data + or None if the data is not available (e.g. before the handshake). + """ + if cb_type not in CHANNEL_BINDING_TYPES: + raise ValueError("Unsupported channel binding type") + if cb_type != "tls-unique": + raise NotImplementedError( + "{0} channel binding type not implemented" + .format(cb_type)) + if self._sslobj is None: + return None + return self._sslobj.tls_unique_cb() + + def version(self): + """ + Return a string identifying the protocol version used by the + current SSL channel, or None if there is no established channel. + """ + if self._sslobj is None: + return None + return self._sslobj.version() + +if PYPY or not hasattr(SSLSocket, 'timeout'): + # PyPy (and certain versions of CPython) doesn't have a direct + # 'timeout' property on raw sockets, because that's not part of + # the documented specification. We may wind up wrapping a raw + # socket (when ssl is used with PyWSGI) or a gevent socket, which + # does have a read/write timeout property as an alias for + # get/settimeout, so make sure that's always the case because + # pywsgi can depend on that. + SSLSocket.timeout = property(lambda self: self.gettimeout(), + lambda self, value: self.settimeout(value)) + + + +_SSLErrorReadTimeout = SSLError('The read operation timed out') +_SSLErrorWriteTimeout = SSLError('The write operation timed out') +_SSLErrorHandshakeTimeout = SSLError('The handshake operation timed out') + +def wrap_socket(sock, keyfile=None, certfile=None, + server_side=False, cert_reqs=CERT_NONE, + ssl_version=PROTOCOL_SSLv23, ca_certs=None, + do_handshake_on_connect=True, + suppress_ragged_eofs=True, + ciphers=None): + + return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile, + server_side=server_side, cert_reqs=cert_reqs, + ssl_version=ssl_version, ca_certs=ca_certs, + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs, + ciphers=ciphers) + +def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None): + """Retrieve the certificate from the server at the specified address, + and return it as a PEM-encoded string. + If 'ca_certs' is specified, validate the server cert against it. + If 'ssl_version' is specified, use it in the connection attempt.""" + + _, _ = addr + if ca_certs is not None: + cert_reqs = CERT_REQUIRED + else: + cert_reqs = CERT_NONE + context = _create_stdlib_context(ssl_version, + cert_reqs=cert_reqs, + cafile=ca_certs) + with closing(create_connection(addr)) as sock: + with closing(context.wrap_socket(sock)) as sslsock: + dercert = sslsock.getpeercert(True) + return DER_cert_to_PEM_cert(dercert) diff --git a/python/gevent/_tblib.py b/python/gevent/_tblib.py new file mode 100644 index 0000000..91edb01 --- /dev/null +++ b/python/gevent/_tblib.py @@ -0,0 +1,431 @@ +# -*- coding: utf-8 -*- +# A vendored version of part of https://github.com/ionelmc/python-tblib +# pylint:disable=redefined-outer-name,reimported,function-redefined,bare-except,no-else-return,broad-except +#### +# Copyright (c) 2013-2016, Ionel Cristian Mărieș +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +# following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following +# disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#### + +# cpython.py + +""" +Taken verbatim from Jinja2. + +https://github.com/mitsuhiko/jinja2/blob/master/jinja2/debug.py#L267 +""" +#import platform # XXX: gevent cannot import platform at the top level; interferes with monkey patching +import sys + + +def _init_ugly_crap(): + """This function implements a few ugly things so that we can patch the + traceback objects. The function returned allows resetting `tb_next` on + any python traceback object. Do not attempt to use this on non cpython + interpreters + """ + import ctypes + from types import TracebackType + + # figure out side of _Py_ssize_t + if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'): + _Py_ssize_t = ctypes.c_int64 + else: + _Py_ssize_t = ctypes.c_int + + # regular python + class _PyObject(ctypes.Structure): + pass + + _PyObject._fields_ = [ + ('ob_refcnt', _Py_ssize_t), + ('ob_type', ctypes.POINTER(_PyObject)) + ] + + # python with trace + if hasattr(sys, 'getobjects'): + class _PyObject(ctypes.Structure): + pass + + _PyObject._fields_ = [ + ('_ob_next', ctypes.POINTER(_PyObject)), + ('_ob_prev', ctypes.POINTER(_PyObject)), + ('ob_refcnt', _Py_ssize_t), + ('ob_type', ctypes.POINTER(_PyObject)) + ] + + class _Traceback(_PyObject): + pass + + _Traceback._fields_ = [ + ('tb_next', ctypes.POINTER(_Traceback)), + ('tb_frame', ctypes.POINTER(_PyObject)), + ('tb_lasti', ctypes.c_int), + ('tb_lineno', ctypes.c_int) + ] + + def tb_set_next(tb, next): + """Set the tb_next attribute of a traceback object.""" + if not (isinstance(tb, TracebackType) and (next is None or isinstance(next, TracebackType))): + raise TypeError('tb_set_next arguments must be traceback objects') + obj = _Traceback.from_address(id(tb)) + if tb.tb_next is not None: + old = _Traceback.from_address(id(tb.tb_next)) + old.ob_refcnt -= 1 + if next is None: + obj.tb_next = ctypes.POINTER(_Traceback)() + else: + next = _Traceback.from_address(id(next)) + next.ob_refcnt += 1 + obj.tb_next = ctypes.pointer(next) + + return tb_set_next + + +tb_set_next = None +#try: +# if platform.python_implementation() == 'CPython': +# tb_set_next = _init_ugly_crap() +#except Exception as exc: +# sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc)) +#del _init_ugly_crap + +# __init__.py +import re +from types import CodeType +from types import TracebackType + +try: + from __pypy__ import tproxy +except ImportError: + tproxy = None + +__version__ = '1.3.0' +__all__ = ('Traceback',) + +PY3 = sys.version_info[0] == 3 +FRAME_RE = re.compile(r'^\s*File "(?P<co_filename>.+)", line (?P<tb_lineno>\d+)(, in (?P<co_name>.+))?$') + + +class _AttrDict(dict): + __slots__ = () + __getattr__ = dict.__getitem__ + + +# noinspection PyPep8Naming +class __traceback_maker(Exception): + pass + + +class TracebackParseError(Exception): + pass + + +class Code(object): + def __init__(self, code): + self.co_filename = code.co_filename + self.co_name = code.co_name + # gevent: copy more attributes + self.co_nlocals = code.co_nlocals + self.co_stacksize = code.co_stacksize + self.co_flags = code.co_flags + self.co_firstlineno = code.co_firstlineno + + +class Frame(object): + def __init__(self, frame): + self.f_globals = dict([ + (k, v) + for k, v in frame.f_globals.items() + if k in ("__file__", "__name__") + ]) + self.f_code = Code(frame.f_code) + + def clear(self): + # For compatibility with PyPy 3.5; + # clear was added to frame in Python 3.4 + # and is called by traceback.clear_frames(), which + # in turn is called by unittest.TestCase.assertRaises + pass + +class Traceback(object): + + tb_next = None + + def __init__(self, tb): + self.tb_frame = Frame(tb.tb_frame) + # noinspection SpellCheckingInspection + self.tb_lineno = int(tb.tb_lineno) + + # Build in place to avoid exceeding the recursion limit + tb = tb.tb_next + prev_traceback = self + cls = type(self) + while tb is not None: + traceback = object.__new__(cls) + traceback.tb_frame = Frame(tb.tb_frame) + traceback.tb_lineno = int(tb.tb_lineno) + prev_traceback.tb_next = traceback + prev_traceback = traceback + tb = tb.tb_next + + def as_traceback(self): + if tproxy: + return tproxy(TracebackType, self.__tproxy_handler) + if not tb_set_next: + raise RuntimeError("Cannot re-create traceback !") + + current = self + top_tb = None + tb = None + while current: + f_code = current.tb_frame.f_code + code = compile('\n' * (current.tb_lineno - 1) + 'raise __traceback_maker', current.tb_frame.f_code.co_filename, 'exec') + if PY3: + code = CodeType( + 0, code.co_kwonlyargcount, + code.co_nlocals, code.co_stacksize, code.co_flags, + code.co_code, code.co_consts, code.co_names, code.co_varnames, + f_code.co_filename, f_code.co_name, + code.co_firstlineno, code.co_lnotab, (), () + ) + else: + code = CodeType( + 0, + code.co_nlocals, code.co_stacksize, code.co_flags, + code.co_code, code.co_consts, code.co_names, code.co_varnames, + f_code.co_filename.encode(), f_code.co_name.encode(), + code.co_firstlineno, code.co_lnotab, (), () + ) + + # noinspection PyBroadException + try: + exec(code, current.tb_frame.f_globals, {}) + except: + next_tb = sys.exc_info()[2].tb_next + if top_tb is None: + top_tb = next_tb + if tb is not None: + tb_set_next(tb, next_tb) + tb = next_tb + del next_tb + + current = current.tb_next + try: + return top_tb + finally: + del top_tb + del tb + + + # noinspection SpellCheckingInspection + def __tproxy_handler(self, operation, *args, **kwargs): + if operation in ('__getattribute__', '__getattr__'): + if args[0] == 'tb_next': + return self.tb_next and self.tb_next.as_traceback() + else: + return getattr(self, args[0]) + else: + return getattr(self, operation)(*args, **kwargs) + + def to_dict(self): + """Convert a Traceback into a dictionary representation""" + if self.tb_next is None: + tb_next = None + else: + tb_next = self.tb_next.to_dict() + + code = { + 'co_filename': self.tb_frame.f_code.co_filename, + 'co_name': self.tb_frame.f_code.co_name, + } + frame = { + 'f_globals': self.tb_frame.f_globals, + 'f_code': code, + } + return { + 'tb_frame': frame, + 'tb_lineno': self.tb_lineno, + 'tb_next': tb_next, + } + + @classmethod + def from_dict(cls, dct): + if dct['tb_next']: + tb_next = cls.from_dict(dct['tb_next']) + else: + tb_next = None + + code = _AttrDict( + co_filename=dct['tb_frame']['f_code']['co_filename'], + co_name=dct['tb_frame']['f_code']['co_name'], + ) + frame = _AttrDict( + f_globals=dct['tb_frame']['f_globals'], + f_code=code, + ) + tb = _AttrDict( + tb_frame=frame, + tb_lineno=dct['tb_lineno'], + tb_next=tb_next, + ) + return cls(tb) + + @classmethod + def from_string(cls, string, strict=True): + frames = [] + header = strict + + for line in string.splitlines(): + line = line.rstrip() + if header: + if line == 'Traceback (most recent call last):': + header = False + continue + frame_match = FRAME_RE.match(line) + if frame_match: + frames.append(frame_match.groupdict()) + elif line.startswith(' '): + pass + elif strict: + break # traceback ended + + if frames: + previous = None + for frame in reversed(frames): + previous = _AttrDict( + frame, + tb_frame=_AttrDict( + frame, + f_globals=_AttrDict( + __file__=frame['co_filename'], + __name__='?', + ), + f_code=_AttrDict(frame), + ), + tb_next=previous, + ) + return cls(previous) + else: + raise TracebackParseError("Could not find any frames in %r." % string) + +# pickling_support.py + + +def unpickle_traceback(tb_frame, tb_lineno, tb_next): + ret = object.__new__(Traceback) + ret.tb_frame = tb_frame + ret.tb_lineno = tb_lineno + ret.tb_next = tb_next + return ret.as_traceback() + + +def pickle_traceback(tb): + return unpickle_traceback, (Frame(tb.tb_frame), tb.tb_lineno, tb.tb_next and Traceback(tb.tb_next)) + + +def install(): + try: + import copy_reg + except ImportError: + import copyreg as copy_reg + + copy_reg.pickle(TracebackType, pickle_traceback) + +# Added by gevent + +# We have to defer the initialization, and especially the import of platform, +# until runtime. If we're monkey patched, we need to be sure to use +# the original __import__ to avoid switching through the hub due to +# import locks on Python 2. See also builtins.py for details. + + +def _unlocked_imports(f): + def g(a): + if sys is None: # pragma: no cover + # interpreter shutdown on Py2 + return + + gb = None + if 'gevent.builtins' in sys.modules: + gb = sys.modules['gevent.builtins'] + gb._unlock_imports() + try: + return f(a) + finally: + if gb is not None: + gb._lock_imports() + g.__name__ = f.__name__ + g.__module__ = f.__module__ + return g + + +def _import_dump_load(): + global dumps + global loads + try: + import cPickle as pickle + except ImportError: + import pickle + dumps = pickle.dumps + loads = pickle.loads + +dumps = loads = None + +_installed = False + + +def _init(): + global _installed + global tb_set_next + if _installed: + return + + _installed = True + import platform + try: + if platform.python_implementation() == 'CPython': + tb_set_next = _init_ugly_crap() + except Exception as exc: + sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc)) + + try: + from __pypy__ import tproxy + except ImportError: + tproxy = None + + if not tb_set_next and not tproxy: + raise ImportError("Cannot use tblib. Runtime not supported.") + _import_dump_load() + install() + + +@_unlocked_imports +def dump_traceback(tb): + # Both _init and dump/load have to be unlocked, because + # copy_reg and pickle can do imports to resolve class names; those + # class names are in this module and greenlet safe though + _init() + return dumps(tb) + + +@_unlocked_imports +def load_traceback(s): + _init() + return loads(s) diff --git a/python/gevent/_threading.py b/python/gevent/_threading.py new file mode 100644 index 0000000..2f5ffbc --- /dev/null +++ b/python/gevent/_threading.py @@ -0,0 +1,515 @@ +"""A clone of threading module (version 2.7.2) that always +targets real OS threads. (Unlike 'threading' which flips between +green and OS threads based on whether the monkey patching is in effect +or not). + +This module is missing 'Thread' class, but includes 'Queue'. +""" +from __future__ import absolute_import +try: + from Queue import Full, Empty +except ImportError: + from queue import Full, Empty # pylint:disable=import-error +from collections import deque +import heapq +from time import time as _time, sleep as _sleep + +from gevent import monkey +from gevent._compat import PY3 + + +__all__ = ['Condition', + 'Event', + 'Lock', + 'RLock', + 'Semaphore', + 'BoundedSemaphore', + 'Queue', + 'local', + 'stack_size'] + + +thread_name = '_thread' if PY3 else 'thread' +start_new_thread, Lock, get_ident, local, stack_size = monkey.get_original(thread_name, [ + 'start_new_thread', 'allocate_lock', 'get_ident', '_local', 'stack_size']) + + +class RLock(object): + + def __init__(self): + self.__block = Lock() + self.__owner = None + self.__count = 0 + + def __repr__(self): + owner = self.__owner + return "<%s owner=%r count=%d>" % ( + self.__class__.__name__, owner, self.__count) + + def acquire(self, blocking=1): + me = get_ident() + if self.__owner == me: + self.__count = self.__count + 1 + return 1 + rc = self.__block.acquire(blocking) + if rc: + self.__owner = me + self.__count = 1 + return rc + + __enter__ = acquire + + def release(self): + if self.__owner != get_ident(): + raise RuntimeError("cannot release un-acquired lock") + self.__count = count = self.__count - 1 + if not count: + self.__owner = None + self.__block.release() + + def __exit__(self, t, v, tb): + self.release() + + # Internal methods used by condition variables + + def _acquire_restore(self, count_owner): + count, owner = count_owner + self.__block.acquire() + self.__count = count + self.__owner = owner + + def _release_save(self): + count = self.__count + self.__count = 0 + owner = self.__owner + self.__owner = None + self.__block.release() + return (count, owner) + + def _is_owned(self): + return self.__owner == get_ident() + + +class Condition(object): + # pylint:disable=method-hidden + + def __init__(self, lock=None): + if lock is None: + lock = RLock() + self.__lock = lock + # Export the lock's acquire() and release() methods + self.acquire = lock.acquire + self.release = lock.release + # If the lock defines _release_save() and/or _acquire_restore(), + # these override the default implementations (which just call + # release() and acquire() on the lock). Ditto for _is_owned(). + try: + self._release_save = lock._release_save + except AttributeError: + pass + try: + self._acquire_restore = lock._acquire_restore + except AttributeError: + pass + try: + self._is_owned = lock._is_owned + except AttributeError: + pass + self.__waiters = [] + + def __enter__(self): + return self.__lock.__enter__() + + def __exit__(self, *args): + return self.__lock.__exit__(*args) + + def __repr__(self): + return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters)) + + def _release_save(self): + self.__lock.release() # No state to save + + def _acquire_restore(self, x): # pylint:disable=unused-argument + self.__lock.acquire() # Ignore saved state + + def _is_owned(self): + # Return True if lock is owned by current_thread. + # This method is called only if __lock doesn't have _is_owned(). + if self.__lock.acquire(0): + self.__lock.release() + return False + return True + + def wait(self, timeout=None): + if not self._is_owned(): + raise RuntimeError("cannot wait on un-acquired lock") + waiter = Lock() + waiter.acquire() + self.__waiters.append(waiter) + saved_state = self._release_save() + try: # restore state no matter what (e.g., KeyboardInterrupt) + if timeout is None: + waiter.acquire() + else: + # Balancing act: We can't afford a pure busy loop, so we + # have to sleep; but if we sleep the whole timeout time, + # we'll be unresponsive. The scheme here sleeps very + # little at first, longer as time goes on, but never longer + # than 20 times per second (or the timeout time remaining). + endtime = _time() + timeout + delay = 0.0005 # 500 us -> initial delay of 1 ms + while True: + gotit = waiter.acquire(0) + if gotit: + break + remaining = endtime - _time() + if remaining <= 0: + break + delay = min(delay * 2, remaining, .05) + _sleep(delay) + if not gotit: + try: + self.__waiters.remove(waiter) + except ValueError: + pass + finally: + self._acquire_restore(saved_state) + + def notify(self, n=1): + if not self._is_owned(): + raise RuntimeError("cannot notify on un-acquired lock") + __waiters = self.__waiters + waiters = __waiters[:n] + if not waiters: + return + for waiter in waiters: + waiter.release() + try: + __waiters.remove(waiter) + except ValueError: + pass + + def notify_all(self): + self.notify(len(self.__waiters)) + + +class Semaphore(object): + + # After Tim Peters' semaphore class, but not quite the same (no maximum) + + def __init__(self, value=1): + if value < 0: + raise ValueError("semaphore initial value must be >= 0") + self.__cond = Condition(Lock()) + self.__value = value + + def acquire(self, blocking=1): + rc = False + self.__cond.acquire() + while self.__value == 0: + if not blocking: + break + self.__cond.wait() + else: + self.__value = self.__value - 1 + rc = True + self.__cond.release() + return rc + + __enter__ = acquire + + def release(self): + self.__cond.acquire() + self.__value = self.__value + 1 + self.__cond.notify() + self.__cond.release() + + def __exit__(self, t, v, tb): + self.release() + + +class BoundedSemaphore(Semaphore): + """Semaphore that checks that # releases is <= # acquires""" + def __init__(self, value=1): + Semaphore.__init__(self, value) + self._initial_value = value + + def release(self): + if self.Semaphore__value >= self._initial_value: # pylint:disable=no-member + raise ValueError("Semaphore released too many times") + return Semaphore.release(self) + + +class Event(object): + + # After Tim Peters' event class (without is_posted()) + + def __init__(self): + self.__cond = Condition(Lock()) + self.__flag = False + + def _reset_internal_locks(self): + # private! called by Thread._reset_internal_locks by _after_fork() + self.__cond.__init__() + + def is_set(self): + return self.__flag + + def set(self): + self.__cond.acquire() + try: + self.__flag = True + self.__cond.notify_all() + finally: + self.__cond.release() + + def clear(self): + self.__cond.acquire() + try: + self.__flag = False + finally: + self.__cond.release() + + def wait(self, timeout=None): + self.__cond.acquire() + try: + if not self.__flag: + self.__cond.wait(timeout) + return self.__flag + finally: + self.__cond.release() + + +class Queue: # pylint:disable=old-style-class + """Create a queue object with a given maximum size. + + If maxsize is <= 0, the queue size is infinite. + """ + def __init__(self, maxsize=0): + self.maxsize = maxsize + self._init(maxsize) + # mutex must be held whenever the queue is mutating. All methods + # that acquire mutex must release it before returning. mutex + # is shared between the three conditions, so acquiring and + # releasing the conditions also acquires and releases mutex. + self.mutex = Lock() + # Notify not_empty whenever an item is added to the queue; a + # thread waiting to get is notified then. + self.not_empty = Condition(self.mutex) + # Notify not_full whenever an item is removed from the queue; + # a thread waiting to put is notified then. + self.not_full = Condition(self.mutex) + # Notify all_tasks_done whenever the number of unfinished tasks + # drops to zero; thread waiting to join() is notified to resume + self.all_tasks_done = Condition(self.mutex) + self.unfinished_tasks = 0 + + def task_done(self): + """Indicate that a formerly enqueued task is complete. + + Used by Queue consumer threads. For each get() used to fetch a task, + a subsequent call to task_done() tells the queue that the processing + on the task is complete. + + If a join() is currently blocking, it will resume when all items + have been processed (meaning that a task_done() call was received + for every item that had been put() into the queue). + + Raises a ValueError if called more times than there were items + placed in the queue. + """ + self.all_tasks_done.acquire() + try: + unfinished = self.unfinished_tasks - 1 + if unfinished <= 0: + if unfinished < 0: + raise ValueError('task_done() called too many times') + self.all_tasks_done.notify_all() + self.unfinished_tasks = unfinished + finally: + self.all_tasks_done.release() + + def join(self): + """Blocks until all items in the Queue have been gotten and processed. + + The count of unfinished tasks goes up whenever an item is added to the + queue. The count goes down whenever a consumer thread calls task_done() + to indicate the item was retrieved and all work on it is complete. + + When the count of unfinished tasks drops to zero, join() unblocks. + """ + self.all_tasks_done.acquire() + try: + while self.unfinished_tasks: + self.all_tasks_done.wait() + finally: + self.all_tasks_done.release() + + def qsize(self): + """Return the approximate size of the queue (not reliable!).""" + self.mutex.acquire() + try: + return self._qsize() + finally: + self.mutex.release() + + def empty(self): + """Return True if the queue is empty, False otherwise (not reliable!).""" + self.mutex.acquire() + try: + return not self._qsize() + finally: + self.mutex.release() + + def full(self): + """Return True if the queue is full, False otherwise (not reliable!).""" + self.mutex.acquire() + try: + if self.maxsize <= 0: + return False + if self.maxsize >= self._qsize(): + return True + finally: + self.mutex.release() + + def put(self, item, block=True, timeout=None): + """Put an item into the queue. + + If optional args 'block' is true and 'timeout' is None (the default), + block if necessary until a free slot is available. If 'timeout' is + a positive number, it blocks at most 'timeout' seconds and raises + the Full exception if no free slot was available within that time. + Otherwise ('block' is false), put an item on the queue if a free slot + is immediately available, else raise the Full exception ('timeout' + is ignored in that case). + """ + self.not_full.acquire() + try: + if self.maxsize > 0: + if not block: + if self._qsize() >= self.maxsize: + raise Full + elif timeout is None: + while self._qsize() >= self.maxsize: + self.not_full.wait() + elif timeout < 0: + raise ValueError("'timeout' must be a positive number") + else: + endtime = _time() + timeout + while self._qsize() >= self.maxsize: + remaining = endtime - _time() + if remaining <= 0.0: + raise Full + self.not_full.wait(remaining) + self._put(item) + self.unfinished_tasks += 1 + self.not_empty.notify() + finally: + self.not_full.release() + + def put_nowait(self, item): + """Put an item into the queue without blocking. + + Only enqueue the item if a free slot is immediately available. + Otherwise raise the Full exception. + """ + return self.put(item, False) + + def get(self, block=True, timeout=None): + """Remove and return an item from the queue. + + If optional args 'block' is true and 'timeout' is None (the default), + block if necessary until an item is available. If 'timeout' is + a positive number, it blocks at most 'timeout' seconds and raises + the Empty exception if no item was available within that time. + Otherwise ('block' is false), return an item if one is immediately + available, else raise the Empty exception ('timeout' is ignored + in that case). + """ + self.not_empty.acquire() + try: + if not block: + if not self._qsize(): + raise Empty + elif timeout is None: + while not self._qsize(): + self.not_empty.wait() + elif timeout < 0: + raise ValueError("'timeout' must be a positive number") + else: + endtime = _time() + timeout + while not self._qsize(): + remaining = endtime - _time() + if remaining <= 0.0: + raise Empty + self.not_empty.wait(remaining) + item = self._get() + self.not_full.notify() + return item + finally: + self.not_empty.release() + + def get_nowait(self): + """Remove and return an item from the queue without blocking. + + Only get an item if one is immediately available. Otherwise + raise the Empty exception. + """ + return self.get(False) + + # Override these methods to implement other queue organizations + # (e.g. stack or priority queue). + # These will only be called with appropriate locks held + + # Initialize the queue representation + def _init(self, maxsize): + # pylint:disable=unused-argument + self.queue = deque() + + def _qsize(self, len=len): + return len(self.queue) + + # Put a new item in the queue + def _put(self, item): + self.queue.append(item) + + # Get an item from the queue + def _get(self): + return self.queue.popleft() + + +class PriorityQueue(Queue): + '''Variant of Queue that retrieves open entries in priority order (lowest first). + + Entries are typically tuples of the form: (priority number, data). + ''' + + def _init(self, maxsize): + self.queue = [] + + def _qsize(self, len=len): + return len(self.queue) + + def _put(self, item, heappush=heapq.heappush): + # pylint:disable=arguments-differ + heappush(self.queue, item) + + def _get(self, heappop=heapq.heappop): + # pylint:disable=arguments-differ + return heappop(self.queue) + + +class LifoQueue(Queue): + '''Variant of Queue that retrieves most recently added entries first.''' + + def _init(self, maxsize): + self.queue = [] + + def _qsize(self, len=len): + return len(self.queue) + + def _put(self, item): + self.queue.append(item) + + def _get(self): + return self.queue.pop() diff --git a/python/gevent/_util.py b/python/gevent/_util.py new file mode 100644 index 0000000..4178a84 --- /dev/null +++ b/python/gevent/_util.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +""" +internal gevent utilities, not for external use. +""" + +from __future__ import print_function, absolute_import, division + +from gevent._compat import iteritems + + +class _NONE(object): + """ + A special object you must never pass to any gevent API. + Used as a marker object for keyword arguments that cannot have the + builtin None (because that might be a valid value). + """ + __slots__ = () + + def __repr__(self): + return '<default value>' + +_NONE = _NONE() + +def copy_globals(source, + globs, + only_names=None, + ignore_missing_names=False, + names_to_ignore=(), + dunder_names_to_keep=('__implements__', '__all__', '__imports__'), + cleanup_globs=True): + """ + Copy attributes defined in `source.__dict__` to the dictionary in globs + (which should be the caller's globals()). + + Names that start with `__` are ignored (unless they are in + *dunder_names_to_keep*). Anything found in *names_to_ignore* is + also ignored. + + If *only_names* is given, only those attributes will be considered. + In this case, *ignore_missing_names* says whether or not to raise an AttributeError + if one of those names can't be found. + + If cleanup_globs has a true value, then common things imported but not used + at runtime are removed, including this function. + + Returns a list of the names copied + """ + if only_names: + if ignore_missing_names: + items = ((k, getattr(source, k, _NONE)) for k in only_names) + else: + items = ((k, getattr(source, k)) for k in only_names) + else: + items = iteritems(source.__dict__) + + copied = [] + for key, value in items: + if value is _NONE: + continue + if key in names_to_ignore: + continue + if key.startswith("__") and key not in dunder_names_to_keep: + continue + globs[key] = value + copied.append(key) + + if cleanup_globs: + if 'copy_globals' in globs: + del globs['copy_globals'] + + return copied + +class Lazy(object): + """ + A non-data descriptor used just like @property. The + difference is the function value is assigned to the instance + dict the first time it is accessed and then the function is never + called agoin. + """ + def __init__(self, func): + self.data = (func, func.__name__) + + def __get__(self, inst, class_): + if inst is None: + return self + + func, name = self.data + value = func(inst) + inst.__dict__[name] = value + return value + +class readproperty(object): + """ + A non-data descriptor like @property. The difference is that + when the property is assigned to, it is cached in the instance + and the function is not called on that instance again. + """ + + def __init__(self, func): + self.func = func + + def __get__(self, inst, class_): + if inst is None: + return self + + return self.func(inst) diff --git a/python/gevent/_util_py2.py b/python/gevent/_util_py2.py new file mode 100644 index 0000000..dc74eec --- /dev/null +++ b/python/gevent/_util_py2.py @@ -0,0 +1,7 @@ +# this produces syntax error on Python3 + +__all__ = ['reraise'] + + +def reraise(type, value, tb): + raise type, value, tb diff --git a/python/gevent/ares.pyx b/python/gevent/ares.pyx new file mode 100644 index 0000000..92832cc --- /dev/null +++ b/python/gevent/ares.pyx @@ -0,0 +1,454 @@ +# Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. +cimport cares +import sys +from python cimport * +from _socket import gaierror + + +__all__ = ['channel'] + +cdef object string_types +cdef object text_type + +if sys.version_info[0] >= 3: + string_types = str, + text_type = str +else: + string_types = __builtins__.basestring, + text_type = __builtins__.unicode + +TIMEOUT = 1 + +DEF EV_READ = 1 +DEF EV_WRITE = 2 + + +cdef extern from "dnshelper.c": + int AF_INET + int AF_INET6 + + struct hostent: + char* h_name + int h_addrtype + + struct sockaddr_t "sockaddr": + pass + + struct ares_channeldata: + pass + + object parse_h_name(hostent*) + object parse_h_aliases(hostent*) + object parse_h_addr_list(hostent*) + void* create_object_from_hostent(void*) + + # this imports _socket lazily + object PyUnicode_FromString(char*) + int PyTuple_Check(object) + int PyArg_ParseTuple(object, char*, ...) except 0 + struct sockaddr_in6: + pass + int gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, sockaddr_in6* sa6) + + void* malloc(int) + void free(void*) + void memset(void*, int, int) + + +ARES_SUCCESS = cares.ARES_SUCCESS +ARES_ENODATA = cares.ARES_ENODATA +ARES_EFORMERR = cares.ARES_EFORMERR +ARES_ESERVFAIL = cares.ARES_ESERVFAIL +ARES_ENOTFOUND = cares.ARES_ENOTFOUND +ARES_ENOTIMP = cares.ARES_ENOTIMP +ARES_EREFUSED = cares.ARES_EREFUSED +ARES_EBADQUERY = cares.ARES_EBADQUERY +ARES_EBADNAME = cares.ARES_EBADNAME +ARES_EBADFAMILY = cares.ARES_EBADFAMILY +ARES_EBADRESP = cares.ARES_EBADRESP +ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED +ARES_ETIMEOUT = cares.ARES_ETIMEOUT +ARES_EOF = cares.ARES_EOF +ARES_EFILE = cares.ARES_EFILE +ARES_ENOMEM = cares.ARES_ENOMEM +ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION +ARES_EBADSTR = cares.ARES_EBADSTR +ARES_EBADFLAGS = cares.ARES_EBADFLAGS +ARES_ENONAME = cares.ARES_ENONAME +ARES_EBADHINTS = cares.ARES_EBADHINTS +ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED +ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI +ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS +ARES_ECANCELLED = cares.ARES_ECANCELLED + +ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC +ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY +ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC +ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE +ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN +ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH +ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES +ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP + + +_ares_errors = dict([ + (cares.ARES_SUCCESS, 'ARES_SUCCESS'), + (cares.ARES_ENODATA, 'ARES_ENODATA'), + (cares.ARES_EFORMERR, 'ARES_EFORMERR'), + (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), + (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), + (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), + (cares.ARES_EREFUSED, 'ARES_EREFUSED'), + (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), + (cares.ARES_EBADNAME, 'ARES_EBADNAME'), + (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), + (cares.ARES_EBADRESP, 'ARES_EBADRESP'), + (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), + (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), + (cares.ARES_EOF, 'ARES_EOF'), + (cares.ARES_EFILE, 'ARES_EFILE'), + (cares.ARES_ENOMEM, 'ARES_ENOMEM'), + (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), + (cares.ARES_EBADSTR, 'ARES_EBADSTR'), + (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), + (cares.ARES_ENONAME, 'ARES_ENONAME'), + (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), + (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), + (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), + (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), + (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) + + +# maps c-ares flag to _socket module flag +_cares_flag_map = None + + +cdef _prepare_cares_flag_map(): + global _cares_flag_map + import _socket + _cares_flag_map = [ + (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), + (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), + (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), + (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), + (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] + + +cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): + if _cares_flag_map is None: + _prepare_cares_flag_map() + for socket_flag, cares_flag in _cares_flag_map: + if socket_flag & flags: + default |= cares_flag + flags &= ~socket_flag + if not flags: + return default + raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) + + +cpdef strerror(code): + return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) + + +class InvalidIP(ValueError): + pass + + +cdef void gevent_sock_state_callback(void *data, int s, int read, int write): + if not data: + return + cdef channel ch = <channel>data + ch._sock_state_callback(s, read, write) + + +cdef class result: + cdef public object value + cdef public object exception + + def __init__(self, object value=None, object exception=None): + self.value = value + self.exception = exception + + def __repr__(self): + if self.exception is None: + return '%s(%r)' % (self.__class__.__name__, self.value) + elif self.value is None: + return '%s(exception=%r)' % (self.__class__.__name__, self.exception) + else: + return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) + # add repr_recursive precaution + + def successful(self): + return self.exception is None + + def get(self): + if self.exception is not None: + raise self.exception + return self.value + + +class ares_host_result(tuple): + + def __new__(cls, family, iterable): + cdef object self = tuple.__new__(cls, iterable) + self.family = family + return self + + def __getnewargs__(self): + return (self.family, tuple(self)) + + +cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): + cdef channel channel + cdef object callback + channel, callback = <tuple>arg + Py_DECREF(<PyObjectPtr>arg) + cdef object host_result + try: + if status or not host: + callback(result(None, gaierror(status, strerror(status)))) + else: + try: + host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + except: + callback(result(None, sys.exc_info()[1])) + else: + callback(result(host_result)) + except: + channel.loop.handle_error(callback, *sys.exc_info()) + + +cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): + cdef channel channel + cdef object callback + channel, callback = <tuple>arg + Py_DECREF(<PyObjectPtr>arg) + cdef object node + cdef object service + try: + if status: + callback(result(None, gaierror(status, strerror(status)))) + else: + if c_node: + node = PyUnicode_FromString(c_node) + else: + node = None + if c_service: + service = PyUnicode_FromString(c_service) + else: + service = None + callback(result((node, service))) + except: + channel.loop.handle_error(callback, *sys.exc_info()) + + +cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: + + cdef public object loop + cdef ares_channeldata* channel + cdef public dict _watchers + cdef public object _timer + + def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, + udp_port=None, tcp_port=None, servers=None): + cdef ares_channeldata* channel = NULL + cdef cares.ares_options options + memset(&options, 0, sizeof(cares.ares_options)) + cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB + options.sock_state_cb = <void*>gevent_sock_state_callback + options.sock_state_cb_data = <void*>self + if flags is not None: + options.flags = int(flags) + optmask |= cares.ARES_OPT_FLAGS + if timeout is not None: + options.timeout = int(float(timeout) * 1000) + optmask |= cares.ARES_OPT_TIMEOUTMS + if tries is not None: + options.tries = int(tries) + optmask |= cares.ARES_OPT_TRIES + if ndots is not None: + options.ndots = int(ndots) + optmask |= cares.ARES_OPT_NDOTS + if udp_port is not None: + options.udp_port = int(udp_port) + optmask |= cares.ARES_OPT_UDP_PORT + if tcp_port is not None: + options.tcp_port = int(tcp_port) + optmask |= cares.ARES_OPT_TCP_PORT + cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + if result: + raise gaierror(result, strerror(result)) + result = cares.ares_init_options(&channel, &options, optmask) + if result: + raise gaierror(result, strerror(result)) + self._timer = loop.timer(TIMEOUT, TIMEOUT) + self._watchers = {} + self.channel = channel + try: + if servers is not None: + self.set_servers(servers) + self.loop = loop + except: + self.destroy() + raise + + def __repr__(self): + args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) + return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + + def destroy(self): + if self.channel: + # XXX ares_library_cleanup? + cares.ares_destroy(self.channel) + self.channel = NULL + self._watchers.clear() + self._timer.stop() + self.loop = None + + def __dealloc__(self): + if self.channel: + # XXX ares_library_cleanup? + cares.ares_destroy(self.channel) + self.channel = NULL + + def set_servers(self, servers=None): + if not self.channel: + raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + if not servers: + servers = [] + if isinstance(servers, string_types): + servers = servers.split(',') + cdef int length = len(servers) + cdef int result, index + cdef char* string + cdef cares.ares_addr_node* c_servers + if length <= 0: + result = cares.ares_set_servers(self.channel, NULL) + else: + c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) + if not c_servers: + raise MemoryError + try: + index = 0 + for server in servers: + if isinstance(server, unicode): + server = server.encode('ascii') + string = <char*?>server + if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + c_servers[index].family = AF_INET + elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: + c_servers[index].family = AF_INET6 + else: + raise InvalidIP(repr(string)) + c_servers[index].next = &c_servers[index] + 1 + index += 1 + if index >= length: + break + c_servers[length - 1].next = NULL + index = cares.ares_set_servers(self.channel, c_servers) + if index: + raise ValueError(strerror(index)) + finally: + free(c_servers) + + # this crashes c-ares + #def cancel(self): + # cares.ares_cancel(self.channel) + + cdef _sock_state_callback(self, int socket, int read, int write): + if not self.channel: + return + cdef object watcher = self._watchers.get(socket) + cdef int events = 0 + if read: + events |= EV_READ + if write: + events |= EV_WRITE + if watcher is None: + if not events: + return + watcher = self.loop.io(socket, events) + self._watchers[socket] = watcher + elif events: + if watcher.events == events: + return + watcher.stop() + watcher.events = events + else: + watcher.stop() + self._watchers.pop(socket, None) + if not self._watchers: + self._timer.stop() + return + watcher.start(self._process_fd, watcher, pass_events=True) + self._timer.again(self._on_timer) + + def _on_timer(self): + cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) + + def _process_fd(self, int events, object watcher): + if not self.channel: + return + cdef int read_fd = watcher.fd + cdef int write_fd = read_fd + if not (events & EV_READ): + read_fd = cares.ARES_SOCKET_BAD + if not (events & EV_WRITE): + write_fd = cares.ARES_SOCKET_BAD + cares.ares_process_fd(self.channel, read_fd, write_fd) + + def gethostbyname(self, object callback, char* name, int family=AF_INET): + if not self.channel: + raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + # note that for file lookups still AF_INET can be returned for AF_INET6 request + cdef object arg = (self, callback) + Py_INCREF(<PyObjectPtr>arg) + cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) + + def gethostbyaddr(self, object callback, char* addr): + if not self.channel: + raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + # will guess the family + cdef char addr_packed[16] + cdef int family + cdef int length + if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: + family = AF_INET + length = 4 + elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: + family = AF_INET6 + length = 16 + else: + raise InvalidIP(repr(addr)) + cdef object arg = (self, callback) + Py_INCREF(<PyObjectPtr>arg) + cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) + + cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): + if not self.channel: + raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + cdef char* hostp = NULL + cdef int port = 0 + cdef int flowinfo = 0 + cdef int scope_id = 0 + cdef sockaddr_in6 sa6 + if not PyTuple_Check(sockaddr): + raise TypeError('expected a tuple, got %r' % (sockaddr, )) + PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + if port < 0 or port > 65535: + raise gaierror(-8, 'Invalid value for port: %r' % port) + cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + if length <= 0: + raise InvalidIP(repr(hostp)) + cdef object arg = (self, callback) + Py_INCREF(<PyObjectPtr>arg) + cdef sockaddr_t* x = <sockaddr_t*>&sa6 + cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) + + def getnameinfo(self, object callback, tuple sockaddr, int flags): + try: + flags = _convert_cares_flags(flags) + except gaierror: + # The stdlib just ignores bad flags + flags = 0 + return self._getnameinfo(callback, sockaddr, flags) diff --git a/python/gevent/backdoor.py b/python/gevent/backdoor.py new file mode 100644 index 0000000..ff45166 --- /dev/null +++ b/python/gevent/backdoor.py @@ -0,0 +1,206 @@ +# Copyright (c) 2009-2014, gevent contributors +# Based on eventlet.backdoor Copyright (c) 2005-2006, Bob Ippolito +""" +Interactive greenlet-based network console that can be used in any process. + +The :class:`BackdoorServer` provides a REPL inside a running process. As +long as the process is monkey-patched, the ``BackdoorServer`` can coexist +with other elements of the process. + +.. seealso:: :class:`code.InteractiveConsole` +""" +from __future__ import print_function, absolute_import +import sys +from code import InteractiveConsole + +from gevent.greenlet import Greenlet +from gevent.hub import getcurrent +from gevent.server import StreamServer +from gevent.pool import Pool + +__all__ = ['BackdoorServer'] + +try: + sys.ps1 +except AttributeError: + sys.ps1 = '>>> ' +try: + sys.ps2 +except AttributeError: + sys.ps2 = '... ' + +class _Greenlet_stdreplace(Greenlet): + # A greenlet that replaces sys.std[in/out/err] while running. + _fileobj = None + saved = None + + def switch(self, *args, **kw): + if self._fileobj is not None: + self.switch_in() + Greenlet.switch(self, *args, **kw) + + def switch_in(self): + self.saved = sys.stdin, sys.stderr, sys.stdout + sys.stdin = sys.stdout = sys.stderr = self._fileobj + + def switch_out(self): + sys.stdin, sys.stderr, sys.stdout = self.saved + self.saved = None + + def throw(self, *args, **kwargs): + # pylint:disable=arguments-differ + if self.saved is None and self._fileobj is not None: + self.switch_in() + Greenlet.throw(self, *args, **kwargs) + + def run(self): + try: + return Greenlet.run(self) + finally: + # Make sure to restore the originals. + self.switch_out() + + +class BackdoorServer(StreamServer): + """ + Provide a backdoor to a program for debugging purposes. + + .. warning:: This backdoor provides no authentication and makes no + attempt to limit what remote users can do. Anyone that + can access the server can take any action that the running + python process can. Thus, while you may bind to any interface, for + security purposes it is recommended that you bind to one + only accessible to the local machine, e.g., + 127.0.0.1/localhost. + + Basic usage:: + + from gevent.backdoor import BackdoorServer + server = BackdoorServer(('127.0.0.1', 5001), + banner="Hello from gevent backdoor!", + locals={'foo': "From defined scope!"}) + server.serve_forever() + + In a another terminal, connect with...:: + + $ telnet 127.0.0.1 5001 + Trying 127.0.0.1... + Connected to 127.0.0.1. + Escape character is '^]'. + Hello from gevent backdoor! + >> print(foo) + From defined scope! + + .. versionchanged:: 1.2a1 + Spawned greenlets are now tracked in a pool and killed when the server + is stopped. + """ + + def __init__(self, listener, locals=None, banner=None, **server_args): + """ + :keyword locals: If given, a dictionary of "builtin" values that will be available + at the top-level. + :keyword banner: If geven, a string that will be printed to each connecting user. + """ + group = Pool(greenlet_class=_Greenlet_stdreplace) # no limit on number + StreamServer.__init__(self, listener, spawn=group, **server_args) + _locals = {'__doc__': None, '__name__': '__console__'} + if locals: + _locals.update(locals) + self.locals = _locals + + self.banner = banner + self.stderr = sys.stderr + + def _create_interactive_locals(self): + # Create and return a *new* locals dictionary based on self.locals, + # and set any new entries in it. (InteractiveConsole does not + # copy its locals value) + _locals = self.locals.copy() + # __builtins__ may either be the __builtin__ module or + # __builtin__.__dict__; in the latter case typing + # locals() at the backdoor prompt spews out lots of + # useless stuff + try: + import __builtin__ + _locals["__builtins__"] = __builtin__ + except ImportError: + import builtins # pylint:disable=import-error + _locals["builtins"] = builtins + _locals['__builtins__'] = builtins + return _locals + + def handle(self, conn, _address): # pylint: disable=method-hidden + """ + Interact with one remote user. + + .. versionchanged:: 1.1b2 Each connection gets its own + ``locals`` dictionary. Previously they were shared in a + potentially unsafe manner. + """ + fobj = conn.makefile(mode="rw") + fobj = _fileobject(conn, fobj, self.stderr) + getcurrent()._fileobj = fobj + + getcurrent().switch_in() + try: + console = InteractiveConsole(self._create_interactive_locals()) + if sys.version_info[:3] >= (3, 6, 0): + # Beginning in 3.6, the console likes to print "now exiting <class>" + # but probably our socket is already closed, so this just causes problems. + console.interact(banner=self.banner, exitmsg='') # pylint:disable=unexpected-keyword-arg + else: + console.interact(banner=self.banner) + except SystemExit: # raised by quit() + if hasattr(sys, 'exc_clear'): # py2 + sys.exc_clear() + finally: + conn.close() + fobj.close() + + +class _fileobject(object): + """ + A file-like object that wraps the result of socket.makefile (composition + instead of inheritance lets us work identically under CPython and PyPy). + + We write directly to the socket, avoiding the buffering that the text-oriented + makefile would want to do (otherwise we'd be at the mercy of waiting on a + flush() to get called for the remote user to see data); this beats putting + the file in binary mode and translating everywhere with a non-default + encoding. + """ + def __init__(self, sock, fobj, stderr): + self._sock = sock + self._fobj = fobj + self.stderr = stderr + + def __getattr__(self, name): + return getattr(self._fobj, name) + + def write(self, data): + if not isinstance(data, bytes): + data = data.encode('utf-8') + self._sock.sendall(data) + + def isatty(self): + return True + + def flush(self): + pass + + def readline(self, *a): + try: + return self._fobj.readline(*a).replace("\r\n", "\n") + except UnicodeError: + # Typically, under python 3, a ^C on the other end + return '' + + +if __name__ == '__main__': + if not sys.argv[1:]: + print('USAGE: %s PORT [banner]' % sys.argv[0]) + else: + BackdoorServer(('127.0.0.1', int(sys.argv[1])), + banner=(sys.argv[2] if len(sys.argv) > 2 else None), + locals={'hello': 'world'}).serve_forever() diff --git a/python/gevent/baseserver.py b/python/gevent/baseserver.py new file mode 100644 index 0000000..5b8bce5 --- /dev/null +++ b/python/gevent/baseserver.py @@ -0,0 +1,402 @@ +"""Base class for implementing servers""" +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +import sys +import _socket +import errno +from gevent.greenlet import Greenlet +from gevent.event import Event +from gevent.hub import get_hub +from gevent._compat import string_types, integer_types, xrange + + +__all__ = ['BaseServer'] + + +# We define a helper function to handle closing the socket in +# do_handle; We'd like to bind it to a kwarg to avoid *any* lookups at +# all, but that's incompatible with the calling convention of +# do_handle. On CPython, this is ~20% faster than creating and calling +# a closure and ~10% faster than using a @staticmethod. (In theory, we +# could create a closure only once in set_handle, to wrap self._handle, +# but this is safer from a backwards compat standpoint.) +# we also avoid unpacking the *args tuple when calling/spawning this object +# for a tiny improvement (benchmark shows a wash) +def _handle_and_close_when_done(handle, close, args_tuple): + try: + return handle(*args_tuple) + finally: + close(*args_tuple) + + +class BaseServer(object): + """ + An abstract base class that implements some common functionality for the servers in gevent. + + :param listener: Either be an address that the server should bind + on or a :class:`gevent.socket.socket` instance that is already + bound (and put into listening mode in case of TCP socket). + + :keyword handle: If given, the request handler. The request + handler can be defined in a few ways. Most commonly, + subclasses will implement a ``handle`` method as an + instance method. Alternatively, a function can be passed + as the ``handle`` argument to the constructor. In either + case, the handler can later be changed by calling + :meth:`set_handle`. + + When the request handler returns, the socket used for the + request will be closed. Therefore, the handler must not return if + the socket is still in use (for example, by manually spawned greenlets). + + :keyword spawn: If provided, is called to create a new + greenlet to run the handler. By default, + :func:`gevent.spawn` is used (meaning there is no + artificial limit on the number of concurrent requests). Possible values for *spawn*: + + - a :class:`gevent.pool.Pool` instance -- ``handle`` will be executed + using :meth:`gevent.pool.Pool.spawn` only if the pool is not full. + While it is full, no new connections are accepted; + - :func:`gevent.spawn_raw` -- ``handle`` will be executed in a raw + greenlet which has a little less overhead then :class:`gevent.Greenlet` instances spawned by default; + - ``None`` -- ``handle`` will be executed right away, in the :class:`Hub` greenlet. + ``handle`` cannot use any blocking functions as it would mean switching to the :class:`Hub`. + - an integer -- a shortcut for ``gevent.pool.Pool(integer)`` + + .. versionchanged:: 1.1a1 + When the *handle* function returns from processing a connection, + the client socket will be closed. This resolves the non-deterministic + closing of the socket, fixing ResourceWarnings under Python 3 and PyPy. + + """ + # pylint: disable=too-many-instance-attributes,bare-except,broad-except + + #: the number of seconds to sleep in case there was an error in accept() call + #: for consecutive errors the delay will double until it reaches max_delay + #: when accept() finally succeeds the delay will be reset to min_delay again + min_delay = 0.01 + max_delay = 1 + + #: Sets the maximum number of consecutive accepts that a process may perform on + #: a single wake up. High values give higher priority to high connection rates, + #: while lower values give higher priority to already established connections. + #: Default is 100. Note, that in case of multiple working processes on the same + #: listening value, it should be set to a lower value. (pywsgi.WSGIServer sets it + #: to 1 when environ["wsgi.multiprocess"] is true) + max_accept = 100 + + _spawn = Greenlet.spawn + + #: the default timeout that we wait for the client connections to close in stop() + stop_timeout = 1 + + fatal_errors = (errno.EBADF, errno.EINVAL, errno.ENOTSOCK) + + def __init__(self, listener, handle=None, spawn='default'): + self._stop_event = Event() + self._stop_event.set() + self._watcher = None + self._timer = None + self._handle = None + # XXX: FIXME: Subclasses rely on the presence or absence of the + # `socket` attribute to determine whether we are open/should be opened. + # Instead, have it be None. + self.pool = None + try: + self.set_listener(listener) + self.set_spawn(spawn) + self.set_handle(handle) + self.delay = self.min_delay + self.loop = get_hub().loop + if self.max_accept < 1: + raise ValueError('max_accept must be positive int: %r' % (self.max_accept, )) + except: + self.close() + raise + + def set_listener(self, listener): + if hasattr(listener, 'accept'): + if hasattr(listener, 'do_handshake'): + raise TypeError('Expected a regular socket, not SSLSocket: %r' % (listener, )) + self.family = listener.family + self.address = listener.getsockname() + self.socket = listener + else: + self.family, self.address = parse_address(listener) + + def set_spawn(self, spawn): + if spawn == 'default': + self.pool = None + self._spawn = self._spawn + elif hasattr(spawn, 'spawn'): + self.pool = spawn + self._spawn = spawn.spawn + elif isinstance(spawn, integer_types): + from gevent.pool import Pool + self.pool = Pool(spawn) + self._spawn = self.pool.spawn + else: + self.pool = None + self._spawn = spawn + if hasattr(self.pool, 'full'): + self.full = self.pool.full + if self.pool is not None: + self.pool._semaphore.rawlink(self._start_accepting_if_started) + + def set_handle(self, handle): + if handle is not None: + self.handle = handle + if hasattr(self, 'handle'): + self._handle = self.handle + else: + raise TypeError("'handle' must be provided") + + def _start_accepting_if_started(self, _event=None): + if self.started: + self.start_accepting() + + def start_accepting(self): + if self._watcher is None: + # just stop watcher without creating a new one? + self._watcher = self.loop.io(self.socket.fileno(), 1) + self._watcher.start(self._do_read) + + def stop_accepting(self): + if self._watcher is not None: + self._watcher.stop() + self._watcher = None + if self._timer is not None: + self._timer.stop() + self._timer = None + + def do_handle(self, *args): + spawn = self._spawn + handle = self._handle + close = self.do_close + + try: + if spawn is None: + _handle_and_close_when_done(handle, close, args) + else: + spawn(_handle_and_close_when_done, handle, close, args) + except: + close(*args) + raise + + def do_close(self, *args): + pass + + def do_read(self): + raise NotImplementedError() + + def _do_read(self): + for _ in xrange(self.max_accept): + if self.full(): + self.stop_accepting() + return + try: + args = self.do_read() + self.delay = self.min_delay + if not args: + return + except: + self.loop.handle_error(self, *sys.exc_info()) + ex = sys.exc_info()[1] + if self.is_fatal_error(ex): + self.close() + sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex))) + return + if self.delay >= 0: + self.stop_accepting() + self._timer = self.loop.timer(self.delay) + self._timer.start(self._start_accepting_if_started) + self.delay = min(self.max_delay, self.delay * 2) + break + else: + try: + self.do_handle(*args) + except: + self.loop.handle_error((args[1:], self), *sys.exc_info()) + if self.delay >= 0: + self.stop_accepting() + self._timer = self.loop.timer(self.delay) + self._timer.start(self._start_accepting_if_started) + self.delay = min(self.max_delay, self.delay * 2) + break + + def full(self): + # copied from self.pool + # pylint: disable=method-hidden + return False + + def __repr__(self): + return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._formatinfo()) + + def __str__(self): + return '<%s %s>' % (type(self).__name__, self._formatinfo()) + + def _formatinfo(self): + if hasattr(self, 'socket'): + try: + fileno = self.socket.fileno() + except Exception as ex: + fileno = str(ex) + result = 'fileno=%s ' % fileno + else: + result = '' + try: + if isinstance(self.address, tuple) and len(self.address) == 2: + result += 'address=%s:%s' % self.address + else: + result += 'address=%s' % (self.address, ) + except Exception as ex: + result += str(ex) or '<error>' + + handle = self.__dict__.get('handle') + if handle is not None: + fself = getattr(handle, '__self__', None) + try: + if fself is self: + # Checks the __self__ of the handle in case it is a bound + # method of self to prevent recursivly defined reprs. + handle_repr = '<bound method %s.%s of self>' % ( + self.__class__.__name__, + handle.__name__, + ) + else: + handle_repr = repr(handle) + + result += ' handle=' + handle_repr + except Exception as ex: + result += str(ex) or '<error>' + + return result + + @property + def server_host(self): + """IP address that the server is bound to (string).""" + if isinstance(self.address, tuple): + return self.address[0] + + @property + def server_port(self): + """Port that the server is bound to (an integer).""" + if isinstance(self.address, tuple): + return self.address[1] + + def init_socket(self): + """If the user initialized the server with an address rather than socket, + then this function will create a socket, bind it and put it into listening mode. + + It is not supposed to be called by the user, it is called by :meth:`start` before starting + the accept loop.""" + pass + + @property + def started(self): + return not self._stop_event.is_set() + + def start(self): + """Start accepting the connections. + + If an address was provided in the constructor, then also create a socket, + bind it and put it into the listening mode. + """ + self.init_socket() + self._stop_event.clear() + try: + self.start_accepting() + except: + self.close() + raise + + def close(self): + """Close the listener socket and stop accepting.""" + self._stop_event.set() + try: + self.stop_accepting() + finally: + try: + self.socket.close() + except Exception: + pass + finally: + self.__dict__.pop('socket', None) + self.__dict__.pop('handle', None) + self.__dict__.pop('_handle', None) + self.__dict__.pop('_spawn', None) + self.__dict__.pop('full', None) + if self.pool is not None: + self.pool._semaphore.unlink(self._start_accepting_if_started) + + @property + def closed(self): + return not hasattr(self, 'socket') + + def stop(self, timeout=None): + """ + Stop accepting the connections and close the listening socket. + + If the server uses a pool to spawn the requests, then + :meth:`stop` also waits for all the handlers to exit. If there + are still handlers executing after *timeout* has expired + (default 1 second, :attr:`stop_timeout`), then the currently + running handlers in the pool are killed. + + If the server does not use a pool, then this merely stops accepting connections; + any spawned greenlets that are handling requests continue running until + they naturally complete. + """ + self.close() + if timeout is None: + timeout = self.stop_timeout + if self.pool: + self.pool.join(timeout=timeout) + self.pool.kill(block=True, timeout=1) + + def serve_forever(self, stop_timeout=None): + """Start the server if it hasn't been already started and wait until it's stopped.""" + # add test that serve_forever exists on stop() + if not self.started: + self.start() + try: + self._stop_event.wait() + finally: + Greenlet.spawn(self.stop, timeout=stop_timeout).join() + + def is_fatal_error(self, ex): + return isinstance(ex, _socket.error) and ex.args[0] in self.fatal_errors + + +def _extract_family(host): + if host.startswith('[') and host.endswith(']'): + host = host[1:-1] + return _socket.AF_INET6, host + return _socket.AF_INET, host + + +def _parse_address(address): + if isinstance(address, tuple): + if not address[0] or ':' in address[0]: + return _socket.AF_INET6, address + return _socket.AF_INET, address + + if ((isinstance(address, string_types) and ':' not in address) + or isinstance(address, integer_types)): # noqa (pep8 E129) + # Just a port + return _socket.AF_INET6, ('', int(address)) + + if not isinstance(address, string_types): + raise TypeError('Expected tuple or string, got %s' % type(address)) + + host, port = address.rsplit(':', 1) + family, host = _extract_family(host) + if host == '*': + host = '' + return family, (host, int(port)) + + +def parse_address(address): + try: + return _parse_address(address) + except ValueError as ex: + raise ValueError('Failed to parse address %r: %s' % (address, ex)) diff --git a/python/gevent/builtins.py b/python/gevent/builtins.py new file mode 100644 index 0000000..eab2099 --- /dev/null +++ b/python/gevent/builtins.py @@ -0,0 +1,125 @@ +# Copyright (c) 2015 gevent contributors. See LICENSE for details. +"""gevent friendly implementations of builtin functions.""" +from __future__ import absolute_import + +import imp # deprecated since 3.4; issues PendingDeprecationWarning in 3.5 +import sys +import weakref +from gevent.lock import RLock + +# Normally we'd have the "expected" case inside the try +# (Python 3, because Python 3 is the way forward). But +# under Python 2, the popular `future` library *also* provides +# a `builtins` module---which lacks the __import__ attribute. +# So we test for the old, deprecated version first + +try: # Py2 + import __builtin__ as builtins + _allowed_module_name_types = (basestring,) # pylint:disable=undefined-variable + __target__ = '__builtin__' +except ImportError: + import builtins # pylint: disable=import-error + _allowed_module_name_types = (str,) + __target__ = 'builtins' + +_import = builtins.__import__ + +# We need to protect imports both across threads and across greenlets. +# And the order matters. Note that under 3.4, the global import lock +# and imp module are deprecated. It seems that in all Py3 versions, a +# module lock is used such that this fix is not necessary. + +# We emulate the per-module locking system under Python 2 in order to +# avoid issues acquiring locks in multiple-level-deep imports +# that attempt to use the gevent blocking API at runtime; using one lock +# could lead to a LoopExit error as a greenlet attempts to block on it while +# it's already held by the main greenlet (issue #798). + +# We base this approach on a simplification of what `importlib._bootstrap` +# does; notably, we don't check for deadlocks + +_g_import_locks = {} # name -> wref of RLock + +__lock_imports = True + + +def __module_lock(name): + # Return the lock for the given module, creating it if necessary. + # It will be removed when no longer needed. + # Nothing in this function yields, so we're multi-greenlet safe + # (But not multi-threading safe.) + # XXX: What about on PyPy, where the GC is asynchronous (not ref-counting)? + # (Does it stop-the-world first?) + lock = None + try: + lock = _g_import_locks[name]() + except KeyError: + pass + + if lock is None: + lock = RLock() + + def cb(_): + # We've seen a KeyError on PyPy on RPi2 + _g_import_locks.pop(name, None) + _g_import_locks[name] = weakref.ref(lock, cb) + return lock + + +def __import__(*args, **kwargs): + """ + __import__(name, globals=None, locals=None, fromlist=(), level=0) -> object + + Normally python protects imports against concurrency by doing some locking + at the C level (at least, it does that in CPython). This function just + wraps the normal __import__ functionality in a recursive lock, ensuring that + we're protected against greenlet import concurrency as well. + """ + if args and not issubclass(type(args[0]), _allowed_module_name_types): + # if a builtin has been acquired as a bound instance method, + # python knows not to pass 'self' when the method is called. + # No such protection exists for monkey-patched builtins, + # however, so this is necessary. + args = args[1:] + + if not __lock_imports: + return _import(*args, **kwargs) + + module_lock = __module_lock(args[0]) # Get a lock for the module name + imp.acquire_lock() + try: + module_lock.acquire() + try: + result = _import(*args, **kwargs) + finally: + module_lock.release() + finally: + imp.release_lock() + return result + + +def _unlock_imports(): + """ + Internal function, called when gevent needs to perform imports + lazily, but does not know the state of the system. It may be impossible + to take the import lock because there are no other running greenlets, for + example. This causes a monkey-patched __import__ to avoid taking any locks. + until the corresponding call to lock_imports. This should only be done for limited + amounts of time and when the set of imports is statically known to be "safe". + """ + global __lock_imports + # This could easily become a list that we push/pop from or an integer + # we increment if we need to do this recursively, but we shouldn't get + # that complex. + __lock_imports = False + + +def _lock_imports(): + global __lock_imports + __lock_imports = True + +if sys.version_info[:2] >= (3, 3): + __implements__ = [] +else: + __implements__ = ['__import__'] +__all__ = __implements__ diff --git a/python/gevent/cares.pxd b/python/gevent/cares.pxd new file mode 100644 index 0000000..7b551a7 --- /dev/null +++ b/python/gevent/cares.pxd @@ -0,0 +1,109 @@ +cdef extern from "ares.h": + struct ares_options: + int flags + void* sock_state_cb + void* sock_state_cb_data + int timeout + int tries + int ndots + unsigned short udp_port + unsigned short tcp_port + char **domains + int ndomains + char* lookups + + int ARES_OPT_FLAGS + int ARES_OPT_SOCK_STATE_CB + int ARES_OPT_TIMEOUTMS + int ARES_OPT_TRIES + int ARES_OPT_NDOTS + int ARES_OPT_TCP_PORT + int ARES_OPT_UDP_PORT + int ARES_OPT_SERVERS + int ARES_OPT_DOMAINS + int ARES_OPT_LOOKUPS + + int ARES_FLAG_USEVC + int ARES_FLAG_PRIMARY + int ARES_FLAG_IGNTC + int ARES_FLAG_NORECURSE + int ARES_FLAG_STAYOPEN + int ARES_FLAG_NOSEARCH + int ARES_FLAG_NOALIASES + int ARES_FLAG_NOCHECKRESP + + int ARES_LIB_INIT_ALL + int ARES_SOCKET_BAD + + int ARES_SUCCESS + int ARES_ENODATA + int ARES_EFORMERR + int ARES_ESERVFAIL + int ARES_ENOTFOUND + int ARES_ENOTIMP + int ARES_EREFUSED + int ARES_EBADQUERY + int ARES_EBADNAME + int ARES_EBADFAMILY + int ARES_EBADRESP + int ARES_ECONNREFUSED + int ARES_ETIMEOUT + int ARES_EOF + int ARES_EFILE + int ARES_ENOMEM + int ARES_EDESTRUCTION + int ARES_EBADSTR + int ARES_EBADFLAGS + int ARES_ENONAME + int ARES_EBADHINTS + int ARES_ENOTINITIALIZED + int ARES_ELOADIPHLPAPI + int ARES_EADDRGETNETWORKPARAMS + int ARES_ECANCELLED + + int ARES_NI_NOFQDN + int ARES_NI_NUMERICHOST + int ARES_NI_NAMEREQD + int ARES_NI_NUMERICSERV + int ARES_NI_DGRAM + int ARES_NI_TCP + int ARES_NI_UDP + int ARES_NI_SCTP + int ARES_NI_DCCP + int ARES_NI_NUMERICSCOPE + int ARES_NI_LOOKUPHOST + int ARES_NI_LOOKUPSERVICE + + + int ares_library_init(int flags) + void ares_library_cleanup() + int ares_init_options(void *channelptr, ares_options *options, int) + int ares_init(void *channelptr) + void ares_destroy(void *channelptr) + void ares_gethostbyname(void* channel, char *name, int family, void* callback, void *arg) + void ares_gethostbyaddr(void* channel, void *addr, int addrlen, int family, void* callback, void *arg) + void ares_process_fd(void* channel, int read_fd, int write_fd) + char* ares_strerror(int code) + void ares_cancel(void* channel) + void ares_getnameinfo(void* channel, void* sa, int salen, int flags, void* callback, void *arg) + + struct in_addr: + pass + + struct ares_in6_addr: + pass + + struct addr_union: + in_addr addr4 + ares_in6_addr addr6 + + struct ares_addr_node: + ares_addr_node *next + int family + addr_union addr + + int ares_set_servers(void* channel, ares_addr_node *servers) + + +cdef extern from "cares_pton.h": + int ares_inet_pton(int af, char *src, void *dst) diff --git a/python/gevent/cares_ntop.h b/python/gevent/cares_ntop.h new file mode 100644 index 0000000..9ffc9dd --- /dev/null +++ b/python/gevent/cares_ntop.h @@ -0,0 +1,7 @@ +#ifdef CARES_EMBED +#include "ares_setup.h" +#include "ares.h" +#else +#include <arpa/inet.h> +#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z) +#endif diff --git a/python/gevent/cares_pton.h b/python/gevent/cares_pton.h new file mode 100644 index 0000000..85af403 --- /dev/null +++ b/python/gevent/cares_pton.h @@ -0,0 +1,8 @@ +#ifdef CARES_EMBED +#include "ares_setup.h" +#include "ares_inet_net_pton.h" +#else +#include <arpa/inet.h> +#define ares_inet_pton(x,y,z) inet_pton(x,y,z) +#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z) +#endif diff --git a/python/gevent/core.py b/python/gevent/core.py new file mode 100644 index 0000000..8944f12 --- /dev/null +++ b/python/gevent/core.py @@ -0,0 +1,22 @@ +# Copyright (c) 2009-2015 Denis Bilenko and gevent contributors. See LICENSE for details. +from __future__ import absolute_import + +import os + +from gevent._util import copy_globals + +try: + if os.environ.get('GEVENT_CORE_CFFI_ONLY'): + raise ImportError("Not attempting corecext") + + from gevent.libev import corecext as _core +except ImportError: + if os.environ.get('GEVENT_CORE_CEXT_ONLY'): + raise + + # CFFI/PyPy + from gevent.libev import corecffi as _core + +copy_globals(_core, globals()) + +__all__ = _core.__all__ # pylint:disable=no-member diff --git a/python/gevent/dnshelper.c b/python/gevent/dnshelper.c new file mode 100644 index 0000000..3befb69 --- /dev/null +++ b/python/gevent/dnshelper.c @@ -0,0 +1,159 @@ +/* Copyright (c) 2011 Denis Bilenko. See LICENSE for details. */ +#include "Python.h" +#ifdef CARES_EMBED +#include "ares_setup.h" +#endif + +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif + +#include "ares.h" + +#include "cares_ntop.h" +#include "cares_pton.h" + +#if PY_VERSION_HEX < 0x02060000 + #define PyUnicode_FromString PyString_FromString +#elif PY_MAJOR_VERSION < 3 + #define PyUnicode_FromString PyBytes_FromString +#endif + + +static PyObject* _socket_error = 0; + +static PyObject* +get_socket_object(PyObject** pobject, const char* name) +{ + if (!*pobject) { + PyObject* _socket; + _socket = PyImport_ImportModule("_socket"); + if (_socket) { + *pobject = PyObject_GetAttrString(_socket, name); + if (!*pobject) { + PyErr_WriteUnraisable(Py_None); + } + Py_DECREF(_socket); + } + else { + PyErr_WriteUnraisable(Py_None); + } + if (!*pobject) { + *pobject = PyExc_IOError; + } + } + return *pobject; +} + + +static int +gevent_append_addr(PyObject* list, int family, void* src, char* tmpbuf, size_t tmpsize) { + int status = -1; + PyObject* tmp; + if (ares_inet_ntop(family, src, tmpbuf, tmpsize)) { + tmp = PyUnicode_FromString(tmpbuf); + if (tmp) { + status = PyList_Append(list, tmp); + Py_DECREF(tmp); + } + } + return status; +} + + +static PyObject* +parse_h_name(struct hostent *h) +{ + return PyUnicode_FromString(h->h_name); +} + + +static PyObject* +parse_h_aliases(struct hostent *h) +{ + char **pch; + PyObject *result = NULL; + PyObject *tmp; + + result = PyList_New(0); + + if (result && h->h_aliases) { + for (pch = h->h_aliases; *pch != NULL; pch++) { + if (*pch != h->h_name && strcmp(*pch, h->h_name)) { + int status; + tmp = PyUnicode_FromString(*pch); + if (tmp == NULL) { + break; + } + + status = PyList_Append(result, tmp); + Py_DECREF(tmp); + + if (status) { + break; + } + } + } + } + + return result; +} + + +static PyObject * +parse_h_addr_list(struct hostent *h) +{ + char **pch; + PyObject *result = NULL; + + result = PyList_New(0); + + if (result) { + switch (h->h_addrtype) { + case AF_INET: + { + char tmpbuf[sizeof "255.255.255.255"]; + for (pch = h->h_addr_list; *pch != NULL; pch++) { + if (gevent_append_addr(result, AF_INET, *pch, tmpbuf, sizeof(tmpbuf))) { + break; + } + } + break; + } + case AF_INET6: + { + char tmpbuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; + for (pch = h->h_addr_list; *pch != NULL; pch++) { + if (gevent_append_addr(result, AF_INET6, *pch, tmpbuf, sizeof(tmpbuf))) { + break; + } + } + break; + } + default: + PyErr_SetString(get_socket_object(&_socket_error, "error"), "unsupported address family"); + Py_DECREF(result); + result = NULL; + } + } + + return result; +} + + +static int +gevent_make_sockaddr(char* hostp, int port, int flowinfo, int scope_id, struct sockaddr_in6* sa6) { + if ( ares_inet_pton(AF_INET, hostp, &((struct sockaddr_in*)sa6)->sin_addr.s_addr) > 0 ) { + ((struct sockaddr_in*)sa6)->sin_family = AF_INET; + ((struct sockaddr_in*)sa6)->sin_port = htons(port); + return sizeof(struct sockaddr_in); + } + else if ( ares_inet_pton(AF_INET6, hostp, &sa6->sin6_addr.s6_addr) > 0 ) { + sa6->sin6_family = AF_INET6; + sa6->sin6_port = htons(port); + sa6->sin6_flowinfo = flowinfo; + sa6->sin6_scope_id = scope_id; + return sizeof(struct sockaddr_in6); + } + return -1; +} diff --git a/python/gevent/event.py b/python/gevent/event.py new file mode 100644 index 0000000..f888b6e --- /dev/null +++ b/python/gevent/event.py @@ -0,0 +1,448 @@ +# Copyright (c) 2009-2016 Denis Bilenko, gevent contributors. See LICENSE for details. +"""Basic synchronization primitives: Event and AsyncResult""" +from __future__ import print_function +import sys +from gevent.hub import get_hub, getcurrent, _NONE +from gevent._compat import reraise +from gevent.hub import InvalidSwitchError +from gevent.timeout import Timeout +from gevent._tblib import dump_traceback, load_traceback + +__all__ = ['Event', 'AsyncResult'] + + +class _AbstractLinkable(object): + # Encapsulates the standard parts of the linking and notifying protocol + # common to both repeatable events and one-time events (AsyncResult). + + _notifier = None + + def __init__(self): + # Also previously, AsyncResult maintained the order of notifications, but Event + # did not; this implementation does not. (Event also only call callbacks one + # time (set), but AsyncResult permitted duplicates.) + + # HOWEVER, gevent.queue.Queue does guarantee the order of getters relative + # to putters. Some existing documentation out on the net likes to refer to + # gevent as "deterministic", such that running the same program twice will + # produce results in the same order (so long as I/O isn't involved). This could + # be an argument to maintain order. (One easy way to do that while guaranteeing + # uniqueness would be with a 2.7+ OrderedDict.) + self._links = set() + self.hub = get_hub() + + def ready(self): + # Instances must define this + raise NotImplementedError() + + def _check_and_notify(self): + # If this object is ready to be notified, begin the process. + if self.ready(): + if self._links and not self._notifier: + self._notifier = self.hub.loop.run_callback(self._notify_links) + + def rawlink(self, callback): + """ + Register a callback to call when this object is ready. + + *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API. + *callback* will be passed one argument: this instance. + """ + if not callable(callback): + raise TypeError('Expected callable: %r' % (callback, )) + self._links.add(callback) + self._check_and_notify() + + def unlink(self, callback): + """Remove the callback set by :meth:`rawlink`""" + try: + self._links.remove(callback) + except KeyError: + pass + + def _notify_links(self): + # Actually call the notification callbacks. Those callbacks in todo that are + # still in _links are called. This method is careful to avoid iterating + # over self._links, because links could be added or removed while this + # method runs. Only links present when this method begins running + # will be called; if a callback adds a new link, it will not run + # until the next time notify_links is activated + + # We don't need to capture self._links as todo when establishing + # this callback; any links removed between now and then are handled + # by the `if` below; any links added are also grabbed + todo = set(self._links) + for link in todo: + # check that link was not notified yet and was not removed by the client + # We have to do this here, and not as part of the 'for' statement because + # a previous link(self) call might have altered self._links + if link in self._links: + try: + link(self) + except: # pylint:disable=bare-except + self.hub.handle_error((link, self), *sys.exc_info()) + if getattr(link, 'auto_unlink', None): + # This attribute can avoid having to keep a reference to the function + # *in* the function, which is a cycle + self.unlink(link) + + # save a tiny bit of memory by letting _notifier be collected + # bool(self._notifier) would turn to False as soon as we exit this + # method anyway. + del todo + del self._notifier + + def _wait_core(self, timeout, catch=Timeout): + # The core of the wait implementation, handling + # switching and linking. If *catch* is set to (), + # a timeout that elapses will be allowed to be raised. + # Returns a true value if the wait succeeded without timing out. + switch = getcurrent().switch + self.rawlink(switch) + try: + timer = Timeout._start_new_or_dummy(timeout) + try: + try: + result = self.hub.switch() + if result is not self: # pragma: no cover + raise InvalidSwitchError('Invalid switch into Event.wait(): %r' % (result, )) + return True + except catch as ex: + if ex is not timer: + raise + # test_set_and_clear and test_timeout in test_threading + # rely on the exact return values, not just truthish-ness + return False + finally: + timer.cancel() + finally: + self.unlink(switch) + + def _wait_return_value(self, waited, wait_success): + # pylint:disable=unused-argument + return None + + def _wait(self, timeout=None): + if self.ready(): + return self._wait_return_value(False, False) + + gotit = self._wait_core(timeout) + return self._wait_return_value(True, gotit) + + +class Event(_AbstractLinkable): + """A synchronization primitive that allows one greenlet to wake up one or more others. + It has the same interface as :class:`threading.Event` but works across greenlets. + + An event object manages an internal flag that can be set to true with the + :meth:`set` method and reset to false with the :meth:`clear` method. The :meth:`wait` method + blocks until the flag is true. + + .. note:: + The order and timing in which waiting greenlets are awakened is not determined. + As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a + undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets + (those not waiting to be awakened) may run between the current greenlet yielding and + the waiting greenlets being awakened. These details may change in the future. + """ + + _flag = False + + def __str__(self): + return '<%s %s _links[%s]>' % (self.__class__.__name__, (self._flag and 'set') or 'clear', len(self._links)) + + def is_set(self): + """Return true if and only if the internal flag is true.""" + return self._flag + + isSet = is_set # makes it a better drop-in replacement for threading.Event + ready = is_set # makes it compatible with AsyncResult and Greenlet (for example in wait()) + + def set(self): + """ + Set the internal flag to true. + + All greenlets waiting for it to become true are awakened in + some order at some time in the future. Greenlets that call + :meth:`wait` once the flag is true will not block at all + (until :meth:`clear` is called). + """ + self._flag = True + self._check_and_notify() + + def clear(self): + """ + Reset the internal flag to false. + + Subsequently, threads calling :meth:`wait` will block until + :meth:`set` is called to set the internal flag to true again. + """ + self._flag = False + + def _wait_return_value(self, waited, wait_success): + # To avoid the race condition outlined in http://bugs.python.org/issue13502, + # if we had to wait, then we need to return whether or not + # the condition got changed. Otherwise we simply echo + # the current state of the flag (which should be true) + if not waited: + flag = self._flag + assert flag, "if we didn't wait we should already be set" + return flag + + return wait_success + + def wait(self, timeout=None): + """ + Block until the internal flag is true. + + If the internal flag is true on entry, return immediately. Otherwise, + block until another thread (greenlet) calls :meth:`set` to set the flag to true, + or until the optional timeout occurs. + + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). + + :return: This method returns true if and only if the internal flag has been set to + true, either before the wait call or after the wait starts, so it will + always return ``True`` except if a timeout is given and the operation + times out. + + .. versionchanged:: 1.1 + The return value represents the flag during the elapsed wait, not + just after it elapses. This solves a race condition if one greenlet + sets and then clears the flag without switching, while other greenlets + are waiting. When the waiters wake up, this will return True; previously, + they would still wake up, but the return value would be False. This is most + noticeable when the *timeout* is present. + """ + return self._wait(timeout) + + def _reset_internal_locks(self): # pragma: no cover + # for compatibility with threading.Event (only in case of patch_all(Event=True), by default Event is not patched) + # Exception AttributeError: AttributeError("'Event' object has no attribute '_reset_internal_locks'",) + # in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored + pass + + +class AsyncResult(_AbstractLinkable): + """A one-time event that stores a value or an exception. + + Like :class:`Event` it wakes up all the waiters when :meth:`set` or :meth:`set_exception` + is called. Waiters may receive the passed value or exception by calling :meth:`get` + instead of :meth:`wait`. An :class:`AsyncResult` instance cannot be reset. + + To pass a value call :meth:`set`. Calls to :meth:`get` (those that are currently blocking as well as + those made in the future) will return the value: + + >>> result = AsyncResult() + >>> result.set(100) + >>> result.get() + 100 + + To pass an exception call :meth:`set_exception`. This will cause :meth:`get` to raise that exception: + + >>> result = AsyncResult() + >>> result.set_exception(RuntimeError('failure')) + >>> result.get() + Traceback (most recent call last): + ... + RuntimeError: failure + + :class:`AsyncResult` implements :meth:`__call__` and thus can be used as :meth:`link` target: + + >>> import gevent + >>> result = AsyncResult() + >>> gevent.spawn(lambda : 1/0).link(result) + >>> try: + ... result.get() + ... except ZeroDivisionError: + ... print('ZeroDivisionError') + ZeroDivisionError + + .. note:: + The order and timing in which waiting greenlets are awakened is not determined. + As an implementation note, in gevent 1.1 and 1.0, waiting greenlets are awakened in a + undetermined order sometime *after* the current greenlet yields to the event loop. Other greenlets + (those not waiting to be awakened) may run between the current greenlet yielding and + the waiting greenlets being awakened. These details may change in the future. + + .. versionchanged:: 1.1 + The exact order in which waiting greenlets are awakened is not the same + as in 1.0. + .. versionchanged:: 1.1 + Callbacks :meth:`linked <rawlink>` to this object are required to be hashable, and duplicates are + merged. + """ + + _value = _NONE + _exc_info = () + _notifier = None + + @property + def _exception(self): + return self._exc_info[1] if self._exc_info else _NONE + + @property + def value(self): + """ + Holds the value passed to :meth:`set` if :meth:`set` was called. Otherwise, + ``None`` + """ + return self._value if self._value is not _NONE else None + + @property + def exc_info(self): + """ + The three-tuple of exception information if :meth:`set_exception` was called. + """ + if self._exc_info: + return (self._exc_info[0], self._exc_info[1], load_traceback(self._exc_info[2])) + return () + + def __str__(self): + result = '<%s ' % (self.__class__.__name__, ) + if self.value is not None or self._exception is not _NONE: + result += 'value=%r ' % self.value + if self._exception is not None and self._exception is not _NONE: + result += 'exception=%r ' % self._exception + if self._exception is _NONE: + result += 'unset ' + return result + ' _links[%s]>' % len(self._links) + + def ready(self): + """Return true if and only if it holds a value or an exception""" + return self._exc_info or self._value is not _NONE + + def successful(self): + """Return true if and only if it is ready and holds a value""" + return self._value is not _NONE + + @property + def exception(self): + """Holds the exception instance passed to :meth:`set_exception` if :meth:`set_exception` was called. + Otherwise ``None``.""" + if self._exc_info: + return self._exc_info[1] + + def set(self, value=None): + """Store the value and wake up any waiters. + + All greenlets blocking on :meth:`get` or :meth:`wait` are awakened. + Subsequent calls to :meth:`wait` and :meth:`get` will not block at all. + """ + self._value = value + self._check_and_notify() + + def set_exception(self, exception, exc_info=None): + """Store the exception and wake up any waiters. + + All greenlets blocking on :meth:`get` or :meth:`wait` are awakened. + Subsequent calls to :meth:`wait` and :meth:`get` will not block at all. + + :keyword tuple exc_info: If given, a standard three-tuple of type, value, :class:`traceback` + as returned by :func:`sys.exc_info`. This will be used when the exception + is re-raised to propagate the correct traceback. + """ + if exc_info: + self._exc_info = (exc_info[0], exc_info[1], dump_traceback(exc_info[2])) + else: + self._exc_info = (type(exception), exception, dump_traceback(None)) + + self._check_and_notify() + + def _raise_exception(self): + reraise(*self.exc_info) + + def get(self, block=True, timeout=None): + """Return the stored value or raise the exception. + + If this instance already holds a value or an exception, return or raise it immediatelly. + Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` or + until the optional timeout occurs. + + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). If the *timeout* elapses, the *Timeout* exception will + be raised. + + :keyword bool block: If set to ``False`` and this instance is not ready, + immediately raise a :class:`Timeout` exception. + """ + if self._value is not _NONE: + return self._value + if self._exc_info: + return self._raise_exception() + + if not block: + # Not ready and not blocking, so immediately timeout + raise Timeout() + + # Wait, raising a timeout that elapses + self._wait_core(timeout, ()) + + # by definition we are now ready + return self.get(block=False) + + def get_nowait(self): + """ + Return the value or raise the exception without blocking. + + If this object is not yet :meth:`ready <ready>`, raise + :class:`gevent.Timeout` immediately. + """ + return self.get(block=False) + + def _wait_return_value(self, waited, wait_success): + # pylint:disable=unused-argument + # Always return the value. Since this is a one-shot event, + # no race condition should reset it. + return self.value + + def wait(self, timeout=None): + """Block until the instance is ready. + + If this instance already holds a value, it is returned immediately. If this + instance already holds an exception, ``None`` is returned immediately. + + Otherwise, block until another greenlet calls :meth:`set` or :meth:`set_exception` + (at which point either the value or ``None`` will be returned, respectively), + or until the optional timeout expires (at which point ``None`` will also be + returned). + + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds + (or fractions thereof). + + .. note:: If a timeout is given and expires, ``None`` will be returned + (no timeout exception will be raised). + + """ + return self._wait(timeout) + + # link protocol + def __call__(self, source): + if source.successful(): + self.set(source.value) + else: + self.set_exception(source.exception, getattr(source, 'exc_info', None)) + + # Methods to make us more like concurrent.futures.Future + + def result(self, timeout=None): + return self.get(timeout=timeout) + + set_result = set + + def done(self): + return self.ready() + + # we don't support cancelling + + def cancel(self): + return False + + def cancelled(self): + return False + + # exception is a method, we use it as a property diff --git a/python/gevent/fileobject.py b/python/gevent/fileobject.py new file mode 100644 index 0000000..6ed31f0 --- /dev/null +++ b/python/gevent/fileobject.py @@ -0,0 +1,219 @@ +""" +Wrappers to make file-like objects cooperative. + +.. class:: FileObject + + The main entry point to the file-like gevent-compatible behaviour. It will be defined + to be the best available implementation. + +There are two main implementations of ``FileObject``. On all systems, +there is :class:`FileObjectThread` which uses the built-in native +threadpool to avoid blocking the entire interpreter. On UNIX systems +(those that support the :mod:`fcntl` module), there is also +:class:`FileObjectPosix` which uses native non-blocking semantics. + +A third class, :class:`FileObjectBlock`, is simply a wrapper that executes everything +synchronously (and so is not gevent-compatible). It is provided for testing and debugging +purposes. + +Configuration +============= + +You may change the default value for ``FileObject`` using the +``GEVENT_FILE`` environment variable. Set it to ``posix``, ``thread``, +or ``block`` to choose from :class:`FileObjectPosix`, +:class:`FileObjectThread` and :class:`FileObjectBlock`, respectively. +You may also set it to the fully qualified class name of another +object that implements the file interface to use one of your own +objects. + +.. note:: The environment variable must be set at the time this module + is first imported. + +Classes +======= +""" +from __future__ import absolute_import + +import functools +import sys +import os + +from gevent._fileobjectcommon import FileObjectClosed +from gevent._fileobjectcommon import FileObjectBase +from gevent.hub import get_hub +from gevent._compat import integer_types +from gevent._compat import reraise +from gevent.lock import Semaphore, DummySemaphore + + +PYPY = hasattr(sys, 'pypy_version_info') + +if hasattr(sys, 'exc_clear'): + def _exc_clear(): + sys.exc_clear() +else: + def _exc_clear(): + return + + +__all__ = [ + 'FileObjectPosix', + 'FileObjectThread', + 'FileObject', +] + +try: + from fcntl import fcntl +except ImportError: + __all__.remove("FileObjectPosix") +else: + del fcntl + from gevent._fileobjectposix import FileObjectPosix + + +class FileObjectThread(FileObjectBase): + """ + A file-like object wrapping another file-like object, performing all blocking + operations on that object in a background thread. + + .. caution:: + Attempting to change the threadpool or lock of an existing FileObjectThread + has undefined consequences. + + .. versionchanged:: 1.1b1 + The file object is closed using the threadpool. Note that whether or + not this action is synchronous or asynchronous is not documented. + + """ + + def __init__(self, fobj, mode=None, bufsize=-1, close=True, threadpool=None, lock=True): + """ + :param fobj: The underlying file-like object to wrap, or an integer fileno + that will be pass to :func:`os.fdopen` along with *mode* and *bufsize*. + :keyword bool lock: If True (the default) then all operations will + be performed one-by-one. Note that this does not guarantee that, if using + this file object from multiple threads/greenlets, operations will be performed + in any particular order, only that no two operations will be attempted at the + same time. You can also pass your own :class:`gevent.lock.Semaphore` to synchronize + file operations with an external resource. + :keyword bool close: If True (the default) then when this object is closed, + the underlying object is closed as well. + """ + closefd = close + self.threadpool = threadpool or get_hub().threadpool + self.lock = lock + if self.lock is True: + self.lock = Semaphore() + elif not self.lock: + self.lock = DummySemaphore() + if not hasattr(self.lock, '__enter__'): + raise TypeError('Expected a Semaphore or boolean, got %r' % type(self.lock)) + if isinstance(fobj, integer_types): + if not closefd: + # we cannot do this, since fdopen object will close the descriptor + raise TypeError('FileObjectThread does not support close=False on an fd.') + if mode is None: + assert bufsize == -1, "If you use the default mode, you can't choose a bufsize" + fobj = os.fdopen(fobj) + else: + fobj = os.fdopen(fobj, mode, bufsize) + + self.__io_holder = [fobj] # signal for _wrap_method + super(FileObjectThread, self).__init__(fobj, closefd) + + def _do_close(self, fobj, closefd): + self.__io_holder[0] = None # for _wrap_method + try: + with self.lock: + self.threadpool.apply(fobj.flush) + finally: + if closefd: + # Note that we're not taking the lock; older code + # did fobj.close() without going through the threadpool at all, + # so acquiring the lock could potentially introduce deadlocks + # that weren't present before. Avoiding the lock doesn't make + # the existing race condition any worse. + # We wrap the close in an exception handler and re-raise directly + # to avoid the (common, expected) IOError from being logged by the pool + def close(): + try: + fobj.close() + except: # pylint:disable=bare-except + return sys.exc_info() + exc_info = self.threadpool.apply(close) + if exc_info: + reraise(*exc_info) + + def _do_delegate_methods(self): + super(FileObjectThread, self)._do_delegate_methods() + if not hasattr(self, 'read1') and 'r' in getattr(self._io, 'mode', ''): + self.read1 = self.read + self.__io_holder[0] = self._io + + def _extra_repr(self): + return ' threadpool=%r' % (self.threadpool,) + + def __iter__(self): + return self + + def next(self): + line = self.readline() + if line: + return line + raise StopIteration + __next__ = next + + def _wrap_method(self, method): + # NOTE: We are careful to avoid introducing a refcycle + # within self. Our wrapper cannot refer to self. + io_holder = self.__io_holder + lock = self.lock + threadpool = self.threadpool + + @functools.wraps(method) + def thread_method(*args, **kwargs): + if io_holder[0] is None: + # This is different than FileObjectPosix, etc, + # because we want to save the expensive trip through + # the threadpool. + raise FileObjectClosed() + with lock: + return threadpool.apply(method, args, kwargs) + + return thread_method + + +try: + FileObject = FileObjectPosix +except NameError: + FileObject = FileObjectThread + + +class FileObjectBlock(FileObjectBase): + + def __init__(self, fobj, *args, **kwargs): + closefd = kwargs.pop('close', True) + if kwargs: + raise TypeError('Unexpected arguments: %r' % kwargs.keys()) + if isinstance(fobj, integer_types): + if not closefd: + # we cannot do this, since fdopen object will close the descriptor + raise TypeError('FileObjectBlock does not support close=False on an fd.') + fobj = os.fdopen(fobj, *args) + super(FileObjectBlock, self).__init__(fobj, closefd) + + def _do_close(self, fobj, closefd): + fobj.close() + +config = os.environ.get('GEVENT_FILE') +if config: + klass = {'thread': 'gevent.fileobject.FileObjectThread', + 'posix': 'gevent.fileobject.FileObjectPosix', + 'block': 'gevent.fileobject.FileObjectBlock'}.get(config, config) + if klass.startswith('gevent.fileobject.'): + FileObject = globals()[klass.split('.', 2)[-1]] + else: + from gevent.hub import _import + FileObject = _import(klass) + del klass diff --git a/python/gevent/gevent._semaphore.c b/python/gevent/gevent._semaphore.c new file mode 100644 index 0000000..200c80d --- /dev/null +++ b/python/gevent/gevent._semaphore.c @@ -0,0 +1,8807 @@ +/* Generated by Cython 0.25.2 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. +#else +#define CYTHON_ABI "0_25_2" +#include <stddef.h> +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include <math.h> +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__gevent___semaphore +#define __PYX_HAVE_API__gevent___semaphore +#ifdef _OPENMP +#include <omp.h> +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include <cstdlib> + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) && defined (_M_X64) + #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + + +static const char *__pyx_f[] = { + "src\\gevent\\_semaphore.py", + "src\\gevent\\_semaphore.pxd", +}; + +/*--- Type declarations ---*/ +struct __pyx_obj_6gevent_10_semaphore_Semaphore; +struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore; +struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait; +struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire; + +/* "gevent/_semaphore.pxd":15 + * cpdef _notify_links(self) + * cdef _do_wait(self, object timeout) + * cpdef int wait(self, object timeout=*) except -1000 # <<<<<<<<<<<<<< + * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 + * cpdef __enter__(self) + */ +struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait { + int __pyx_n; + PyObject *timeout; +}; + +/* "gevent/_semaphore.pxd":16 + * cdef _do_wait(self, object timeout) + * cpdef int wait(self, object timeout=*) except -1000 + * cpdef bint acquire(self, int blocking=*, object timeout=*) except -1000 # <<<<<<<<<<<<<< + * cpdef __enter__(self) + * cpdef __exit__(self, object t, object v, object tb) + */ +struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire { + int __pyx_n; + int blocking; + PyObject *timeout; +}; + +/* "gevent/_semaphore.pxd":1 + * cdef class Semaphore: # <<<<<<<<<<<<<< + * cdef public int counter + * cdef readonly object _links + */ +struct __pyx_obj_6gevent_10_semaphore_Semaphore { + PyObject_HEAD + struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *__pyx_vtab; + int counter; + PyObject *_links; + PyObject *_notifier; + int _dirty; + PyObject *__weakref__; +}; + + +/* "gevent/_semaphore.pxd":20 + * cpdef __exit__(self, object t, object v, object tb) + * + * cdef class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<< + * cdef readonly int _initial_value + * + */ +struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore { + struct __pyx_obj_6gevent_10_semaphore_Semaphore __pyx_base; + int _initial_value; +}; + + + +/* "gevent/_semaphore.py":9 + * + * + * class Semaphore(object): # <<<<<<<<<<<<<< + * """ + * Semaphore(value=1) -> Semaphore + */ + +struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore { + int (*locked)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); + int (*release)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); + PyObject *(*rawlink)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch); + PyObject *(*unlink)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch); + PyObject *(*_start_notify)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); + PyObject *(*_notify_links)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); + PyObject *(*_do_wait)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *); + int (*wait)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args); + int (*acquire)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args); + PyObject *(*__pyx___enter__)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch); + PyObject *(*__pyx___exit__)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *__pyx_vtabptr_6gevent_10_semaphore_Semaphore; + + +/* "gevent/_semaphore.py":246 + * + * + * class BoundedSemaphore(Semaphore): # <<<<<<<<<<<<<< + * """ + * BoundedSemaphore(value=1) -> BoundedSemaphore + */ + +struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore { + struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore __pyx_base; +}; +static struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore *__pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* CallableCheck.proto */ +#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) +#else +#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) +#endif + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* PyObjectCallMethod1.proto */ +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); + +/* append.proto */ +static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* KeywordStringCheck.proto */ +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* FetchCommonType.proto */ +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/* CythonFunction.proto */ +#define __Pyx_CyFunction_USED 1 +#include <structmember.h> +#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 +#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 +#define __Pyx_CYFUNCTION_CCLASS 0x04 +#define __Pyx_CyFunction_GetClosure(f)\ + (((__pyx_CyFunctionObject *) (f))->func_closure) +#define __Pyx_CyFunction_GetClassObj(f)\ + (((__pyx_CyFunctionObject *) (f))->func_classobj) +#define __Pyx_CyFunction_Defaults(type, f)\ + ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) +#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ + ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) +typedef struct { + PyCFunctionObject func; +#if PY_VERSION_HEX < 0x030500A0 + PyObject *func_weakreflist; +#endif + PyObject *func_dict; + PyObject *func_name; + PyObject *func_qualname; + PyObject *func_doc; + PyObject *func_globals; + PyObject *func_code; + PyObject *func_closure; + PyObject *func_classobj; + void *defaults; + int defaults_pyobjects; + int flags; + PyObject *defaults_tuple; + PyObject *defaults_kwdict; + PyObject *(*defaults_getter)(PyObject *); + PyObject *func_annotations; +} __pyx_CyFunctionObject; +static PyTypeObject *__pyx_CyFunctionType = 0; +#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ + __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) +static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *self, + PyObject *module, PyObject *globals, + PyObject* code); +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, + size_t size, + int pyobjects); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, + PyObject *tuple); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, + PyObject *dict); +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, + PyObject *dict); +static int __pyx_CyFunction_init(void); + +/* GetNameInClass.proto */ +static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static int __pyx_f_6gevent_10_semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args); /* proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_10_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); /* proto*/ +static int __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ + +/* Module declarations from 'gevent._semaphore' */ +static PyTypeObject *__pyx_ptype_6gevent_10_semaphore_Semaphore = 0; +static PyTypeObject *__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore = 0; +#define __Pyx_MODULE_NAME "gevent._semaphore" +int __pyx_module_is_main_gevent___semaphore = 0; + +/* Implementation of 'gevent._semaphore' */ +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_AttributeError; +static const char __pyx_k_t[] = "t"; +static const char __pyx_k_v[] = "v"; +static const char __pyx_k_tb[] = "tb"; +static const char __pyx_k_all[] = "__all__"; +static const char __pyx_k_sys[] = "sys"; +static const char __pyx_k_exit[] = "__exit__"; +static const char __pyx_k_init[] = "__init__"; +static const char __pyx_k_loop[] = "loop"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_self[] = "self"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_wait[] = "wait"; +static const char __pyx_k_class[] = "__class__"; +static const char __pyx_k_enter[] = "__enter__"; +static const char __pyx_k_value[] = "value"; +static const char __pyx_k_append[] = "append"; +static const char __pyx_k_cancel[] = "cancel"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_locked[] = "locked"; +static const char __pyx_k_remove[] = "remove"; +static const char __pyx_k_switch[] = "switch"; +static const char __pyx_k_unlink[] = "unlink"; +static const char __pyx_k_Timeout[] = "Timeout"; +static const char __pyx_k_acquire[] = "acquire"; +static const char __pyx_k_get_hub[] = "get_hub"; +static const char __pyx_k_rawlink[] = "rawlink"; +static const char __pyx_k_release[] = "release"; +static const char __pyx_k_timeout[] = "timeout"; +static const char __pyx_k_blocking[] = "blocking"; +static const char __pyx_k_callback[] = "callback"; +static const char __pyx_k_exc_info[] = "exc_info"; +static const char __pyx_k_Semaphore[] = "Semaphore"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_getcurrent[] = "getcurrent"; +static const char __pyx_k_gevent_hub[] = "gevent.hub"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_handle_error[] = "handle_error"; +static const char __pyx_k_notify_links[] = "_notify_links"; +static const char __pyx_k_py3k_acquire[] = "_py3k_acquire"; +static const char __pyx_k_run_callback[] = "run_callback"; +static const char __pyx_k_start_notify[] = "_start_notify"; +static const char __pyx_k_AttributeError[] = "AttributeError"; +static const char __pyx_k_Semaphore_wait[] = "Semaphore.wait"; +static const char __pyx_k_gevent_timeout[] = "gevent.timeout"; +static const char __pyx_k_BoundedSemaphore[] = "BoundedSemaphore"; +static const char __pyx_k_Semaphore___exit[] = "Semaphore.__exit__"; +static const char __pyx_k_Semaphore_locked[] = "Semaphore.locked"; +static const char __pyx_k_Semaphore_unlink[] = "Semaphore.unlink"; +static const char __pyx_k_Expected_callable[] = "Expected callable:"; +static const char __pyx_k_Semaphore___enter[] = "Semaphore.__enter__"; +static const char __pyx_k_Semaphore_acquire[] = "Semaphore.acquire"; +static const char __pyx_k_Semaphore_rawlink[] = "Semaphore.rawlink"; +static const char __pyx_k_Semaphore_release[] = "Semaphore.release"; +static const char __pyx_k_gevent__semaphore[] = "gevent._semaphore"; +static const char __pyx_k_OVER_RELEASE_ERROR[] = "_OVER_RELEASE_ERROR"; +static const char __pyx_k_start_new_or_dummy[] = "_start_new_or_dummy"; +static const char __pyx_k_s_counter_s__links_s[] = "<%s counter=%s _links[%s]>"; +static const char __pyx_k_Semaphore__notify_links[] = "Semaphore._notify_links"; +static const char __pyx_k_Semaphore__start_notify[] = "Semaphore._start_notify"; +static const char __pyx_k_BoundedSemaphore_release[] = "BoundedSemaphore.release"; +static const char __pyx_k_semaphore_initial_value_must_be[] = "semaphore initial value must be >= 0"; +static const char __pyx_k_C_projects_gevent_src_gevent__se[] = "C:\\projects\\gevent\\src\\gevent\\_semaphore.py"; +static const char __pyx_k_Invalid_switch_into_Semaphore_wa[] = "Invalid switch into Semaphore.wait/acquire(): %r"; +static const char __pyx_k_Semaphore_released_too_many_time[] = "Semaphore released too many times"; +static PyObject *__pyx_n_s_AttributeError; +static PyObject *__pyx_n_s_BoundedSemaphore; +static PyObject *__pyx_n_s_BoundedSemaphore_release; +static PyObject *__pyx_kp_s_C_projects_gevent_src_gevent__se; +static PyObject *__pyx_kp_s_Expected_callable; +static PyObject *__pyx_kp_s_Invalid_switch_into_Semaphore_wa; +static PyObject *__pyx_n_s_OVER_RELEASE_ERROR; +static PyObject *__pyx_n_s_Semaphore; +static PyObject *__pyx_n_s_Semaphore___enter; +static PyObject *__pyx_n_s_Semaphore___exit; +static PyObject *__pyx_n_s_Semaphore__notify_links; +static PyObject *__pyx_n_s_Semaphore__start_notify; +static PyObject *__pyx_n_s_Semaphore_acquire; +static PyObject *__pyx_n_s_Semaphore_locked; +static PyObject *__pyx_n_s_Semaphore_rawlink; +static PyObject *__pyx_n_s_Semaphore_release; +static PyObject *__pyx_kp_s_Semaphore_released_too_many_time; +static PyObject *__pyx_n_s_Semaphore_unlink; +static PyObject *__pyx_n_s_Semaphore_wait; +static PyObject *__pyx_n_s_Timeout; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_acquire; +static PyObject *__pyx_n_s_all; +static PyObject *__pyx_n_s_append; +static PyObject *__pyx_n_s_blocking; +static PyObject *__pyx_n_s_callback; +static PyObject *__pyx_n_s_cancel; +static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_enter; +static PyObject *__pyx_n_s_exc_info; +static PyObject *__pyx_n_s_exit; +static PyObject *__pyx_n_s_get_hub; +static PyObject *__pyx_n_s_getcurrent; +static PyObject *__pyx_n_s_gevent__semaphore; +static PyObject *__pyx_n_s_gevent_hub; +static PyObject *__pyx_n_s_gevent_timeout; +static PyObject *__pyx_n_s_handle_error; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_init; +static PyObject *__pyx_n_s_locked; +static PyObject *__pyx_n_s_loop; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_notify_links; +static PyObject *__pyx_n_s_py3k_acquire; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_rawlink; +static PyObject *__pyx_n_s_release; +static PyObject *__pyx_n_s_remove; +static PyObject *__pyx_n_s_run_callback; +static PyObject *__pyx_kp_s_s_counter_s__links_s; +static PyObject *__pyx_n_s_self; +static PyObject *__pyx_kp_s_semaphore_initial_value_must_be; +static PyObject *__pyx_n_s_start_new_or_dummy; +static PyObject *__pyx_n_s_start_notify; +static PyObject *__pyx_n_s_switch; +static PyObject *__pyx_n_s_sys; +static PyObject *__pyx_n_s_t; +static PyObject *__pyx_n_s_tb; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_timeout; +static PyObject *__pyx_n_s_unlink; +static PyObject *__pyx_n_s_v; +static PyObject *__pyx_n_s_value; +static PyObject *__pyx_n_s_wait; +static int __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self); /* proto */ +static PyObject *__pyx_tp_new_6gevent_10_semaphore_Semaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__19; +static PyObject *__pyx_tuple__21; +static PyObject *__pyx_tuple__23; +static PyObject *__pyx_codeobj__4; +static PyObject *__pyx_codeobj__6; +static PyObject *__pyx_codeobj__8; +static PyObject *__pyx_codeobj__10; +static PyObject *__pyx_codeobj__12; +static PyObject *__pyx_codeobj__14; +static PyObject *__pyx_codeobj__16; +static PyObject *__pyx_codeobj__18; +static PyObject *__pyx_codeobj__20; +static PyObject *__pyx_codeobj__22; +static PyObject *__pyx_codeobj__24; + +/* "gevent/_semaphore.py":29 + * """ + * + * def __init__(self, value=1): # <<<<<<<<<<<<<< + * if value < 0: + * raise ValueError("semaphore initial value must be >= 0") + */ + +/* Python wrapper */ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_value = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__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 = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 29, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_value = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 29, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_value); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_10_semaphore_9Semaphore___init__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "gevent/_semaphore.py":30 + * + * def __init__(self, value=1): + * if value < 0: # <<<<<<<<<<<<<< + * raise ValueError("semaphore initial value must be >= 0") + * self.counter = value + */ + __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "gevent/_semaphore.py":31 + * def __init__(self, value=1): + * if value < 0: + * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<< + * self.counter = value + * self._dirty = False + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 31, __pyx_L1_error) + + /* "gevent/_semaphore.py":30 + * + * def __init__(self, value=1): + * if value < 0: # <<<<<<<<<<<<<< + * raise ValueError("semaphore initial value must be >= 0") + * self.counter = value + */ + } + + /* "gevent/_semaphore.py":32 + * if value < 0: + * raise ValueError("semaphore initial value must be >= 0") + * self.counter = value # <<<<<<<<<<<<<< + * self._dirty = False + * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef + */ + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 32, __pyx_L1_error) + __pyx_v_self->counter = __pyx_t_3; + + /* "gevent/_semaphore.py":33 + * raise ValueError("semaphore initial value must be >= 0") + * self.counter = value + * self._dirty = False # <<<<<<<<<<<<<< + * # In PyPy 2.6.1 with Cython 0.23, `cdef public` or `cdef + * # readonly` or simply `cdef` attributes of type `object` can appear to leak if + */ + __pyx_v_self->_dirty = 0; + + /* "gevent/_semaphore.py":47 + * # CPython ("No attribute...") + * # See https://github.com/gevent/gevent/issues/660 + * self._links = None # <<<<<<<<<<<<<< + * self._notifier = None + * # we don't want to do get_hub() here to allow defining module-level locks + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_links); + __Pyx_DECREF(__pyx_v_self->_links); + __pyx_v_self->_links = Py_None; + + /* "gevent/_semaphore.py":48 + * # See https://github.com/gevent/gevent/issues/660 + * self._links = None + * self._notifier = None # <<<<<<<<<<<<<< + * # we don't want to do get_hub() here to allow defining module-level locks + * # without initializing the hub + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_notifier); + __Pyx_DECREF(__pyx_v_self->_notifier); + __pyx_v_self->_notifier = Py_None; + + /* "gevent/_semaphore.py":29 + * """ + * + * def __init__(self, value=1): # <<<<<<<<<<<<<< + * if value < 0: + * raise ValueError("semaphore initial value must be >= 0") + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":52 + * # without initializing the hub + * + * def __str__(self): # <<<<<<<<<<<<<< + * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) + * return '<%s counter=%s _links[%s]>' % params + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_2__str__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_v_params = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "gevent/_semaphore.py":53 + * + * def __str__(self): + * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) # <<<<<<<<<<<<<< + * return '<%s counter=%s _links[%s]>' % params + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 53, __pyx_L1_error) + if (__pyx_t_4) { + __pyx_t_5 = __pyx_v_self->_links; + __Pyx_INCREF(__pyx_t_5); + __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __pyx_t_5; + __pyx_t_5 = 0; + } else { + __Pyx_INCREF(__pyx_int_0); + __pyx_t_3 = __pyx_int_0; + } + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_v_params = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + /* "gevent/_semaphore.py":54 + * def __str__(self): + * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) + * return '<%s counter=%s _links[%s]>' % params # <<<<<<<<<<<<<< + * + * def locked(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_counter_s__links_s, __pyx_v_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "gevent/_semaphore.py":52 + * # without initializing the hub + * + * def __str__(self): # <<<<<<<<<<<<<< + * params = (self.__class__.__name__, self.counter, len(self._links) if self._links else 0) + * return '<%s counter=%s _links[%s]>' % params + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_params); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":56 + * return '<%s counter=%s _links[%s]>' % params + * + * def locked(self): # <<<<<<<<<<<<<< + * """Return a boolean indicating whether the semaphore can be acquired. + * Most useful with binary semaphores.""" + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + __Pyx_RefNannySetupContext("locked", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_locked); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_5; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":59 + * """Return a boolean indicating whether the semaphore can be acquired. + * Most useful with binary semaphores.""" + * return self.counter <= 0 # <<<<<<<<<<<<<< + * + * def release(self): + */ + __pyx_r = (__pyx_v_self->counter <= 0); + goto __pyx_L0; + + /* "gevent/_semaphore.py":56 + * return '<%s counter=%s _links[%s]>' % params + * + * def locked(self): # <<<<<<<<<<<<<< + * """Return a boolean indicating whether the semaphore can be acquired. + * Most useful with binary semaphores.""" + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("gevent._semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_4locked[] = "Return a boolean indicating whether the semaphore can be acquired.\n Most useful with binary semaphores."; +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_5locked = {"locked", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked, METH_NOARGS, __pyx_doc_6gevent_10_semaphore_9Semaphore_4locked}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_5locked(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("locked (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_4locked(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("locked", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_6gevent_10_semaphore_9Semaphore_locked(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.locked", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":61 + * return self.counter <= 0 + * + * def release(self): # <<<<<<<<<<<<<< + * """ + * Release the semaphore, notifying any waiters if needed. + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + __Pyx_RefNannySetupContext("release", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_7release)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_5; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":65 + * Release the semaphore, notifying any waiters if needed. + * """ + * self.counter += 1 # <<<<<<<<<<<<<< + * self._start_notify() + * return self.counter + */ + __pyx_v_self->counter = (__pyx_v_self->counter + 1); + + /* "gevent/_semaphore.py":66 + * """ + * self.counter += 1 + * self._start_notify() # <<<<<<<<<<<<<< + * return self.counter + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_start_notify(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":67 + * self.counter += 1 + * self._start_notify() + * return self.counter # <<<<<<<<<<<<<< + * + * def _start_notify(self): + */ + __pyx_r = __pyx_v_self->counter; + goto __pyx_L0; + + /* "gevent/_semaphore.py":61 + * return self.counter <= 0 + * + * def release(self): # <<<<<<<<<<<<<< + * """ + * Release the semaphore, notifying any waiters if needed. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1000; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_6release[] = "\n Release the semaphore, notifying any waiters if needed.\n "; +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_7release = {"release", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_7release, METH_NOARGS, __pyx_doc_6gevent_10_semaphore_9Semaphore_6release}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("release (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6release(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6release(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("release", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == -1000)) __PYX_ERR(0, 61, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":69 + * return self.counter + * + * def _start_notify(self): # <<<<<<<<<<<<<< + * if self._links and self.counter > 0 and not self._notifier: + * # We create a new self._notifier each time through the loop, + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("_start_notify", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_start_notify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":70 + * + * def _start_notify(self): + * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<< + * # We create a new self._notifier each time through the loop, + * # if needed. (it has a __bool__ method that tells whether it has + */ + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 70, __pyx_L1_error) + if (__pyx_t_6) { + } else { + __pyx_t_5 = __pyx_t_6; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_6 = ((__pyx_v_self->counter > 0) != 0); + if (__pyx_t_6) { + } else { + __pyx_t_5 = __pyx_t_6; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->_notifier); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 70, __pyx_L1_error) + __pyx_t_7 = ((!__pyx_t_6) != 0); + __pyx_t_5 = __pyx_t_7; + __pyx_L4_bool_binop_done:; + if (__pyx_t_5) { + + /* "gevent/_semaphore.py":78 + * # with Cython <= 0.23.3. You must use >= 0.23.4. + * # See https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22371546 + * self._notifier = get_hub().loop.run_callback(self._notify_links) # <<<<<<<<<<<<<< + * + * def _notify_links(self): + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_run_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_4) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->_notifier); + __Pyx_DECREF(__pyx_v_self->_notifier); + __pyx_v_self->_notifier = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":70 + * + * def _start_notify(self): + * if self._links and self.counter > 0 and not self._notifier: # <<<<<<<<<<<<<< + * # We create a new self._notifier each time through the loop, + * # if needed. (it has a __bool__ method that tells whether it has + */ + } + + /* "gevent/_semaphore.py":69 + * return self.counter + * + * def _start_notify(self): # <<<<<<<<<<<<<< + * if self._links and self.counter > 0 and not self._notifier: + * # We create a new self._notifier each time through the loop, + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_9_start_notify = {"_start_notify", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_start_notify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_start_notify (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_8_start_notify(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_start_notify", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore__start_notify(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._start_notify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":80 + * self._notifier = get_hub().loop.run_callback(self._notify_links) + * + * def _notify_links(self): # <<<<<<<<<<<<<< + * # Subclasses CANNOT override. This is a cdef method. + * + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_v_notifier = NULL; + PyObject *__pyx_v_link = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + int __pyx_t_17; + int __pyx_t_18; + char const *__pyx_t_19; + PyObject *__pyx_t_20 = NULL; + PyObject *__pyx_t_21 = NULL; + PyObject *__pyx_t_22 = NULL; + __Pyx_RefNannySetupContext("_notify_links", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_notify_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":89 + * # no need to keep it around until that point (making it potentially climb + * # into older GC generations, notably on PyPy) + * notifier = self._notifier # <<<<<<<<<<<<<< + * try: + * while True: + */ + __pyx_t_1 = __pyx_v_self->_notifier; + __Pyx_INCREF(__pyx_t_1); + __pyx_v_notifier = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":90 + * # into older GC generations, notably on PyPy) + * notifier = self._notifier + * try: # <<<<<<<<<<<<<< + * while True: + * self._dirty = False + */ + /*try:*/ { + + /* "gevent/_semaphore.py":91 + * notifier = self._notifier + * try: + * while True: # <<<<<<<<<<<<<< + * self._dirty = False + * if not self._links: + */ + while (1) { + + /* "gevent/_semaphore.py":92 + * try: + * while True: + * self._dirty = False # <<<<<<<<<<<<<< + * if not self._links: + * # In case we were manually unlinked before + */ + __pyx_v_self->_dirty = 0; + + /* "gevent/_semaphore.py":93 + * while True: + * self._dirty = False + * if not self._links: # <<<<<<<<<<<<<< + * # In case we were manually unlinked before + * # the callback. Which shouldn't happen + */ + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 93, __pyx_L4_error) + __pyx_t_6 = ((!__pyx_t_5) != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":96 + * # In case we were manually unlinked before + * # the callback. Which shouldn't happen + * return # <<<<<<<<<<<<<< + * for link in self._links: + * if self.counter <= 0: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L3_return; + + /* "gevent/_semaphore.py":93 + * while True: + * self._dirty = False + * if not self._links: # <<<<<<<<<<<<<< + * # In case we were manually unlinked before + * # the callback. Which shouldn't happen + */ + } + + /* "gevent/_semaphore.py":97 + * # the callback. Which shouldn't happen + * return + * for link in self._links: # <<<<<<<<<<<<<< + * if self.counter <= 0: + * return + */ + if (likely(PyList_CheckExact(__pyx_v_self->_links)) || PyTuple_CheckExact(__pyx_v_self->_links)) { + __pyx_t_1 = __pyx_v_self->_links; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 97, __pyx_L4_error) + } + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 97, __pyx_L4_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } else { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 97, __pyx_L4_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } + } else { + __pyx_t_2 = __pyx_t_8(__pyx_t_1); + if (unlikely(!__pyx_t_2)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 97, __pyx_L4_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF_SET(__pyx_v_link, __pyx_t_2); + __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":98 + * return + * for link in self._links: + * if self.counter <= 0: # <<<<<<<<<<<<<< + * return + * try: + */ + __pyx_t_6 = ((__pyx_v_self->counter <= 0) != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":99 + * for link in self._links: + * if self.counter <= 0: + * return # <<<<<<<<<<<<<< + * try: + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L3_return; + + /* "gevent/_semaphore.py":98 + * return + * for link in self._links: + * if self.counter <= 0: # <<<<<<<<<<<<<< + * return + * try: + */ + } + + /* "gevent/_semaphore.py":100 + * if self.counter <= 0: + * return + * try: # <<<<<<<<<<<<<< + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + * except: # pylint:disable=bare-except + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + /*try:*/ { + + /* "gevent/_semaphore.py":101 + * return + * try: + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory # <<<<<<<<<<<<<< + * except: # pylint:disable=bare-except + * getcurrent().handle_error((link, self), *sys.exc_info()) + */ + __Pyx_INCREF(__pyx_v_link); + __pyx_t_3 = __pyx_v_link; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L12_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L12_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_self)}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L12_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 101, __pyx_L12_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_12, 0+1, ((PyObject *)__pyx_v_self)); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L12_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":100 + * if self.counter <= 0: + * return + * try: # <<<<<<<<<<<<<< + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + * except: # pylint:disable=bare-except + */ + } + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + goto __pyx_L19_try_end; + __pyx_L12_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":102 + * try: + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + * except: # pylint:disable=bare-except # <<<<<<<<<<<<<< + * getcurrent().handle_error((link, self), *sys.exc_info()) + * if self._dirty: + */ + /*except:*/ { + __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_12) < 0) __PYX_ERR(0, 102, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_12); + + /* "gevent/_semaphore.py":103 + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + * except: # pylint:disable=bare-except + * getcurrent().handle_error((link, self), *sys.exc_info()) # <<<<<<<<<<<<<< + * if self._dirty: + * # We mutated self._links so we need to start over + */ + __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_14 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { + __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13); + if (likely(__pyx_t_14)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_13, function); + } + } + if (__pyx_t_14) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + } else { + __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + } + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_link); + __Pyx_GIVEREF(__pyx_v_link); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_link); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self)); + __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { + __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16); + if (likely(__pyx_t_15)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); + __Pyx_INCREF(__pyx_t_15); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_16, function); + } + } + if (__pyx_t_15) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } else { + __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + } + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __pyx_t_16 = PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_14, __pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 103, __pyx_L14_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + goto __pyx_L13_exception_handled; + } + __pyx_L14_except_error:; + + /* "gevent/_semaphore.py":100 + * if self.counter <= 0: + * return + * try: # <<<<<<<<<<<<<< + * link(self) # Must use Cython >= 0.23.4 on PyPy else this leaks memory + * except: # pylint:disable=bare-except + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); + goto __pyx_L4_error; + __pyx_L13_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); + __pyx_L19_try_end:; + } + + /* "gevent/_semaphore.py":104 + * except: # pylint:disable=bare-except + * getcurrent().handle_error((link, self), *sys.exc_info()) + * if self._dirty: # <<<<<<<<<<<<<< + * # We mutated self._links so we need to start over + * break + */ + __pyx_t_6 = (__pyx_v_self->_dirty != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":106 + * if self._dirty: + * # We mutated self._links so we need to start over + * break # <<<<<<<<<<<<<< + * if not self._dirty: + * return + */ + goto __pyx_L10_break; + + /* "gevent/_semaphore.py":104 + * except: # pylint:disable=bare-except + * getcurrent().handle_error((link, self), *sys.exc_info()) + * if self._dirty: # <<<<<<<<<<<<<< + * # We mutated self._links so we need to start over + * break + */ + } + + /* "gevent/_semaphore.py":97 + * # the callback. Which shouldn't happen + * return + * for link in self._links: # <<<<<<<<<<<<<< + * if self.counter <= 0: + * return + */ + } + __pyx_L10_break:; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":107 + * # We mutated self._links so we need to start over + * break + * if not self._dirty: # <<<<<<<<<<<<<< + * return + * finally: + */ + __pyx_t_6 = ((!(__pyx_v_self->_dirty != 0)) != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":108 + * break + * if not self._dirty: + * return # <<<<<<<<<<<<<< + * finally: + * # We should not have created a new notifier even if callbacks + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L3_return; + + /* "gevent/_semaphore.py":107 + * # We mutated self._links so we need to start over + * break + * if not self._dirty: # <<<<<<<<<<<<<< + * return + * finally: + */ + } + } + } + + /* "gevent/_semaphore.py":113 + * # released us because we loop through *all* of our links on the + * # same callback while self._notifier is still true. + * assert self._notifier is notifier # <<<<<<<<<<<<<< + * self._notifier = None + * + */ + /*finally:*/ { + /*normal exit:*/{ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); + if (unlikely(!(__pyx_t_6 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 113, __pyx_L1_error) + } + } + #endif + + /* "gevent/_semaphore.py":114 + * # same callback while self._notifier is still true. + * assert self._notifier is notifier + * self._notifier = None # <<<<<<<<<<<<<< + * + * def rawlink(self, callback): + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_notifier); + __Pyx_DECREF(__pyx_v_self->_notifier); + __pyx_v_self->_notifier = Py_None; + goto __pyx_L5; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L4_error:; + __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_20); + __Pyx_XGOTREF(__pyx_t_21); + __Pyx_XGOTREF(__pyx_t_22); + __pyx_t_17 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename; + { + + /* "gevent/_semaphore.py":113 + * # released us because we loop through *all* of our links on the + * # same callback while self._notifier is still true. + * assert self._notifier is notifier # <<<<<<<<<<<<<< + * self._notifier = None + * + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); + if (unlikely(!(__pyx_t_6 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 113, __pyx_L25_error) + } + } + #endif + + /* "gevent/_semaphore.py":114 + * # same callback while self._notifier is still true. + * assert self._notifier is notifier + * self._notifier = None # <<<<<<<<<<<<<< + * + * def rawlink(self, callback): + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_notifier); + __Pyx_DECREF(__pyx_v_self->_notifier); + __pyx_v_self->_notifier = Py_None; + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_20); + __Pyx_XGIVEREF(__pyx_t_21); + __Pyx_XGIVEREF(__pyx_t_22); + __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); + } + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_ErrRestore(__pyx_t_11, __pyx_t_10, __pyx_t_9); + __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; + __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19; + goto __pyx_L1_error; + __pyx_L25_error:; + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_20); + __Pyx_XGIVEREF(__pyx_t_21); + __Pyx_XGIVEREF(__pyx_t_22); + __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); + } + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; + goto __pyx_L1_error; + } + __pyx_L3_return: { + __pyx_t_22 = __pyx_r; + __pyx_r = 0; + + /* "gevent/_semaphore.py":113 + * # released us because we loop through *all* of our links on the + * # same callback while self._notifier is still true. + * assert self._notifier is notifier # <<<<<<<<<<<<<< + * self._notifier = None + * + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_6 = (__pyx_v_self->_notifier == __pyx_v_notifier); + if (unlikely(!(__pyx_t_6 != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 113, __pyx_L1_error) + } + } + #endif + + /* "gevent/_semaphore.py":114 + * # same callback while self._notifier is still true. + * assert self._notifier is notifier + * self._notifier = None # <<<<<<<<<<<<<< + * + * def rawlink(self, callback): + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_notifier); + __Pyx_DECREF(__pyx_v_self->_notifier); + __pyx_v_self->_notifier = Py_None; + __pyx_r = __pyx_t_22; + __pyx_t_22 = 0; + goto __pyx_L0; + } + __pyx_L5:; + } + + /* "gevent/_semaphore.py":80 + * self._notifier = get_hub().loop.run_callback(self._notify_links) + * + * def _notify_links(self): # <<<<<<<<<<<<<< + * # Subclasses CANNOT override. This is a cdef method. + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_16); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_notifier); + __Pyx_XDECREF(__pyx_v_link); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_11_notify_links = {"_notify_links", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_11_notify_links(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_notify_links (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_10_notify_links(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_notify_links", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore__notify_links(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._notify_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":116 + * self._notifier = None + * + * def rawlink(self, callback): # <<<<<<<<<<<<<< + * """ + * rawlink(callback) -> None + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + __Pyx_RefNannySetupContext("rawlink", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rawlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":128 + * will not need to use it. + * """ + * if not callable(callback): # <<<<<<<<<<<<<< + * raise TypeError('Expected callable:', callback) + * if self._links is None: + */ + __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0); + if (__pyx_t_7) { + + /* "gevent/_semaphore.py":129 + * """ + * if not callable(callback): + * raise TypeError('Expected callable:', callback) # <<<<<<<<<<<<<< + * if self._links is None: + * self._links = [callback] + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_kp_s_Expected_callable); + __Pyx_GIVEREF(__pyx_kp_s_Expected_callable); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_Expected_callable); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_callback); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 129, __pyx_L1_error) + + /* "gevent/_semaphore.py":128 + * will not need to use it. + * """ + * if not callable(callback): # <<<<<<<<<<<<<< + * raise TypeError('Expected callable:', callback) + * if self._links is None: + */ + } + + /* "gevent/_semaphore.py":130 + * if not callable(callback): + * raise TypeError('Expected callable:', callback) + * if self._links is None: # <<<<<<<<<<<<<< + * self._links = [callback] + * else: + */ + __pyx_t_7 = (__pyx_v_self->_links == Py_None); + __pyx_t_6 = (__pyx_t_7 != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":131 + * raise TypeError('Expected callable:', callback) + * if self._links is None: + * self._links = [callback] # <<<<<<<<<<<<<< + * else: + * self._links.append(callback) + */ + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->_links); + __Pyx_DECREF(__pyx_v_self->_links); + __pyx_v_self->_links = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":130 + * if not callable(callback): + * raise TypeError('Expected callable:', callback) + * if self._links is None: # <<<<<<<<<<<<<< + * self._links = [callback] + * else: + */ + goto __pyx_L4; + } + + /* "gevent/_semaphore.py":133 + * self._links = [callback] + * else: + * self._links.append(callback) # <<<<<<<<<<<<<< + * self._dirty = True + * + */ + /*else*/ { + __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->_links, __pyx_v_callback); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 133, __pyx_L1_error) + } + __pyx_L4:; + + /* "gevent/_semaphore.py":134 + * else: + * self._links.append(callback) + * self._dirty = True # <<<<<<<<<<<<<< + * + * def unlink(self, callback): + */ + __pyx_v_self->_dirty = 1; + + /* "gevent/_semaphore.py":116 + * self._notifier = None + * + * def rawlink(self, callback): # <<<<<<<<<<<<<< + * """ + * rawlink(callback) -> None + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_12rawlink[] = "\n rawlink(callback) -> None\n\n Register a callback to call when a counter is more than zero.\n\n *callback* will be called in the :class:`Hub <gevent.hub.Hub>`, so it must not use blocking gevent API.\n *callback* will be passed one argument: this instance.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most code\n will not need to use it.\n "; +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_13rawlink = {"rawlink", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink, METH_O, __pyx_doc_6gevent_10_semaphore_9Semaphore_12rawlink}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_13rawlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("rawlink (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_12rawlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("rawlink", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_rawlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.rawlink", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":136 + * self._dirty = True + * + * def unlink(self, callback): # <<<<<<<<<<<<<< + * """ + * unlink(callback) -> None + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore_unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + __Pyx_RefNannySetupContext("unlink", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_callback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_callback}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":145 + * code will not need to use it. + * """ + * try: # <<<<<<<<<<<<<< + * self._links.remove(callback) + * self._dirty = True + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + /*try:*/ { + + /* "gevent/_semaphore.py":146 + * """ + * try: + * self._links.remove(callback) # <<<<<<<<<<<<<< + * self._dirty = True + * except (ValueError, AttributeError): + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_links, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_callback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_callback}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_callback); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":147 + * try: + * self._links.remove(callback) + * self._dirty = True # <<<<<<<<<<<<<< + * except (ValueError, AttributeError): + * pass + */ + __pyx_v_self->_dirty = 1; + + /* "gevent/_semaphore.py":145 + * code will not need to use it. + * """ + * try: # <<<<<<<<<<<<<< + * self._links.remove(callback) + * self._dirty = True + */ + } + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":148 + * self._links.remove(callback) + * self._dirty = True + * except (ValueError, AttributeError): # <<<<<<<<<<<<<< + * pass + * if not self._links: + */ + __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); + if (__pyx_t_9) { + __Pyx_ErrRestore(0,0,0); + goto __pyx_L4_exception_handled; + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "gevent/_semaphore.py":145 + * code will not need to use it. + * """ + * try: # <<<<<<<<<<<<<< + * self._links.remove(callback) + * self._dirty = True + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); + __pyx_L10_try_end:; + } + + /* "gevent/_semaphore.py":150 + * except (ValueError, AttributeError): + * pass + * if not self._links: # <<<<<<<<<<<<<< + * self._links = None + * # TODO: Cancel a notifier if there are no links? + */ + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_self->_links); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 150, __pyx_L1_error) + __pyx_t_11 = ((!__pyx_t_10) != 0); + if (__pyx_t_11) { + + /* "gevent/_semaphore.py":151 + * pass + * if not self._links: + * self._links = None # <<<<<<<<<<<<<< + * # TODO: Cancel a notifier if there are no links? + * + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_links); + __Pyx_DECREF(__pyx_v_self->_links); + __pyx_v_self->_links = Py_None; + + /* "gevent/_semaphore.py":150 + * except (ValueError, AttributeError): + * pass + * if not self._links: # <<<<<<<<<<<<<< + * self._links = None + * # TODO: Cancel a notifier if there are no links? + */ + } + + /* "gevent/_semaphore.py":136 + * self._dirty = True + * + * def unlink(self, callback): # <<<<<<<<<<<<<< + * """ + * unlink(callback) -> None + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_14unlink[] = "\n unlink(callback) -> None\n\n Remove the callback set by :meth:`rawlink`.\n\n This method is normally called automatically by :meth:`acquire` and :meth:`wait`; most\n code will not need to use it.\n "; +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_15unlink = {"unlink", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink, METH_O, __pyx_doc_6gevent_10_semaphore_9Semaphore_14unlink}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_15unlink(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("unlink (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_14unlink(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("unlink", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore_unlink(__pyx_v_self, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.unlink", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":154 + * # TODO: Cancel a notifier if there are no links? + * + * def _do_wait(self, timeout): # <<<<<<<<<<<<<< + * """ + * Wait for up to *timeout* seconds to expire. If timeout + */ + +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) { + PyObject *__pyx_v_switch = NULL; + PyObject *__pyx_v_timer = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_ex = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + char const *__pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + char const *__pyx_t_16; + __Pyx_RefNannySetupContext("_do_wait", 0); + + /* "gevent/_semaphore.py":160 + * Raises timeout if a different timer expires. + * """ + * switch = getcurrent().switch # <<<<<<<<<<<<<< + * self.rawlink(switch) + * try: + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_getcurrent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_switch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_switch = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":161 + * """ + * switch = getcurrent().switch + * self.rawlink(switch) # <<<<<<<<<<<<<< + * try: + * timer = Timeout._start_new_or_dummy(timeout) + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->rawlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":162 + * switch = getcurrent().switch + * self.rawlink(switch) + * try: # <<<<<<<<<<<<<< + * timer = Timeout._start_new_or_dummy(timeout) + * try: + */ + /*try:*/ { + + /* "gevent/_semaphore.py":163 + * self.rawlink(switch) + * try: + * timer = Timeout._start_new_or_dummy(timeout) # <<<<<<<<<<<<<< + * try: + * try: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_start_new_or_dummy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL; + __Pyx_INCREF(__pyx_v_timeout); + __Pyx_GIVEREF(__pyx_v_timeout); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_timer = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":164 + * try: + * timer = Timeout._start_new_or_dummy(timeout) + * try: # <<<<<<<<<<<<<< + * try: + * result = get_hub().switch() + */ + /*try:*/ { + + /* "gevent/_semaphore.py":165 + * timer = Timeout._start_new_or_dummy(timeout) + * try: + * try: # <<<<<<<<<<<<<< + * result = get_hub().switch() + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + /*try:*/ { + + /* "gevent/_semaphore.py":166 + * try: + * try: + * result = get_hub().switch() # <<<<<<<<<<<<<< + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + * except Timeout as ex: + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_hub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (__pyx_t_1) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L9_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L9_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_switch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L9_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L9_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":167 + * try: + * result = get_hub().switch() + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) # <<<<<<<<<<<<<< + * except Timeout as ex: + * if ex is not timer: + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + __pyx_t_8 = (__pyx_v_result == ((PyObject *)__pyx_v_self)); + if (unlikely(!(__pyx_t_8 != 0))) { + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_result); + __Pyx_GIVEREF(__pyx_v_result); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_result); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 167, __pyx_L9_error) + } + } + #endif + + /* "gevent/_semaphore.py":165 + * timer = Timeout._start_new_or_dummy(timeout) + * try: + * try: # <<<<<<<<<<<<<< + * result = get_hub().switch() + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + */ + } + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L16_try_end; + __pyx_L9_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "gevent/_semaphore.py":168 + * result = get_hub().switch() + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + * except Timeout as ex: # <<<<<<<<<<<<<< + * if ex is not timer: + * raise + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Timeout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L11_except_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_9) { + __Pyx_AddTraceback("gevent._semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 168, __pyx_L11_except_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __pyx_v_ex = __pyx_t_2; + + /* "gevent/_semaphore.py":169 + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + * except Timeout as ex: + * if ex is not timer: # <<<<<<<<<<<<<< + * raise + * return ex + */ + __pyx_t_8 = (__pyx_v_ex != __pyx_v_timer); + __pyx_t_10 = (__pyx_t_8 != 0); + if (__pyx_t_10) { + + /* "gevent/_semaphore.py":170 + * except Timeout as ex: + * if ex is not timer: + * raise # <<<<<<<<<<<<<< + * return ex + * finally: + */ + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_2, __pyx_t_3); + __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; + __PYX_ERR(0, 170, __pyx_L11_except_error) + + /* "gevent/_semaphore.py":169 + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + * except Timeout as ex: + * if ex is not timer: # <<<<<<<<<<<<<< + * raise + * return ex + */ + } + + /* "gevent/_semaphore.py":171 + * if ex is not timer: + * raise + * return ex # <<<<<<<<<<<<<< + * finally: + * timer.cancel() + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_ex); + __pyx_r = __pyx_v_ex; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L12_except_return; + } + goto __pyx_L11_except_error; + __pyx_L11_except_error:; + + /* "gevent/_semaphore.py":165 + * timer = Timeout._start_new_or_dummy(timeout) + * try: + * try: # <<<<<<<<<<<<<< + * result = get_hub().switch() + * assert result is self, 'Invalid switch into Semaphore.wait/acquire(): %r' % (result, ) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + goto __pyx_L7_error; + __pyx_L12_except_return:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + goto __pyx_L6_return; + __pyx_L16_try_end:; + } + } + + /* "gevent/_semaphore.py":173 + * return ex + * finally: + * timer.cancel() # <<<<<<<<<<<<<< + * finally: + * self.unlink(switch) + */ + /*finally:*/ { + /*normal exit:*/{ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_4) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L4_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L4_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L7_error:; + __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __pyx_t_9 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; + { + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L21_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_4) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L21_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L21_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); + } + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ErrRestore(__pyx_t_7, __pyx_t_6, __pyx_t_5); + __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12; + goto __pyx_L4_error; + __pyx_L21_error:; + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); + } + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + goto __pyx_L4_error; + } + __pyx_L6_return: { + __pyx_t_15 = __pyx_r; + __pyx_r = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_cancel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_4) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L4_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L4_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_15; + __pyx_t_15 = 0; + goto __pyx_L3_return; + } + __pyx_L8:; + } + } + + /* "gevent/_semaphore.py":175 + * timer.cancel() + * finally: + * self.unlink(switch) # <<<<<<<<<<<<<< + * + * def wait(self, timeout=None): + */ + /*finally:*/ { + /*normal exit:*/{ + __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L5; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L4_error:; + __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + __pyx_t_11 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_16 = __pyx_filename; + { + __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L23_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + } + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13); + __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; + __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_16; + goto __pyx_L1_error; + __pyx_L23_error:; + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + } + __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; + goto __pyx_L1_error; + } + __pyx_L3_return: { + __pyx_t_7 = __pyx_r; + __pyx_r = 0; + __pyx_t_3 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->unlink(__pyx_v_self, __pyx_v_switch, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + } + __pyx_L5:; + } + + /* "gevent/_semaphore.py":154 + * # TODO: Cancel a notifier if there are no links? + * + * def _do_wait(self, timeout): # <<<<<<<<<<<<<< + * """ + * Wait for up to *timeout* seconds to expire. If timeout + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._do_wait", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_switch); + __Pyx_XDECREF(__pyx_v_timer); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_ex); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":177 + * self.unlink(switch) + * + * def wait(self, timeout=None): # <<<<<<<<<<<<<< + * """ + * wait(timeout=None) -> int + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args) { + PyObject *__pyx_v_timeout = ((PyObject *)Py_None); + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + __Pyx_RefNannySetupContext("wait", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_timeout = __pyx_optional_args->timeout; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(__pyx_v_timeout); + __Pyx_GIVEREF(__pyx_v_timeout); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_timeout); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_6; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":192 + * before blocking. + * """ + * if self.counter > 0: # <<<<<<<<<<<<<< + * return self.counter + * + */ + __pyx_t_7 = ((__pyx_v_self->counter > 0) != 0); + if (__pyx_t_7) { + + /* "gevent/_semaphore.py":193 + * """ + * if self.counter > 0: + * return self.counter # <<<<<<<<<<<<<< + * + * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout + */ + __pyx_r = __pyx_v_self->counter; + goto __pyx_L0; + + /* "gevent/_semaphore.py":192 + * before blocking. + * """ + * if self.counter > 0: # <<<<<<<<<<<<<< + * return self.counter + * + */ + } + + /* "gevent/_semaphore.py":195 + * return self.counter + * + * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout # <<<<<<<<<<<<<< + * return self.counter + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":196 + * + * self._do_wait(timeout) # return value irrelevant, whether we got it or got a timeout + * return self.counter # <<<<<<<<<<<<<< + * + * def acquire(self, blocking=True, timeout=None): + */ + __pyx_r = __pyx_v_self->counter; + goto __pyx_L0; + + /* "gevent/_semaphore.py":177 + * self.unlink(switch) + * + * def wait(self, timeout=None): # <<<<<<<<<<<<<< + * """ + * wait(timeout=None) -> int + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1000; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_16wait[] = "\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_10_semaphore_9Semaphore_17wait = {"wait", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_10_semaphore_9Semaphore_16wait}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_17wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_timeout = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("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 = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) __PYX_ERR(0, 177, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_timeout = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("wait", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 177, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_timeout); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_16wait(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_timeout) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("wait", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.timeout = __pyx_v_timeout; + __pyx_t_1 = __pyx_vtabptr_6gevent_10_semaphore_Semaphore->wait(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1000)) __PYX_ERR(0, 177, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.wait", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":198 + * return self.counter + * + * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< + * """ + * acquire(blocking=True, timeout=None) -> bool + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6gevent_10_semaphore_9Semaphore_acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args) { + int __pyx_v_blocking = ((int)1); + PyObject *__pyx_v_timeout = ((PyObject *)Py_None); + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + __Pyx_RefNannySetupContext("acquire", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_blocking = __pyx_optional_args->blocking; + if (__pyx_optional_args->__pyx_n > 1) { + __pyx_v_timeout = __pyx_optional_args->timeout; + } + } + } + __Pyx_INCREF(__pyx_v_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)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire)) { + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_blocking); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_timeout}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_INCREF(__pyx_v_timeout); + __Pyx_GIVEREF(__pyx_v_timeout); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_timeout); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_8; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":219 + * raise a ``Timeout`` exception, if some other caller had already started a timer.) + * """ + * if self.counter > 0: # <<<<<<<<<<<<<< + * self.counter -= 1 + * return True + */ + __pyx_t_8 = ((__pyx_v_self->counter > 0) != 0); + if (__pyx_t_8) { + + /* "gevent/_semaphore.py":220 + * """ + * if self.counter > 0: + * self.counter -= 1 # <<<<<<<<<<<<<< + * return True + * + */ + __pyx_v_self->counter = (__pyx_v_self->counter - 1); + + /* "gevent/_semaphore.py":221 + * if self.counter > 0: + * self.counter -= 1 + * return True # <<<<<<<<<<<<<< + * + * if not blocking: + */ + __pyx_r = 1; + goto __pyx_L0; + + /* "gevent/_semaphore.py":219 + * raise a ``Timeout`` exception, if some other caller had already started a timer.) + * """ + * if self.counter > 0: # <<<<<<<<<<<<<< + * self.counter -= 1 + * return True + */ + } + + /* "gevent/_semaphore.py":223 + * return True + * + * if not blocking: # <<<<<<<<<<<<<< + * return False + * + */ + __pyx_t_8 = ((!(__pyx_v_blocking != 0)) != 0); + if (__pyx_t_8) { + + /* "gevent/_semaphore.py":224 + * + * if not blocking: + * return False # <<<<<<<<<<<<<< + * + * timeout = self._do_wait(timeout) + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "gevent/_semaphore.py":223 + * return True + * + * if not blocking: # <<<<<<<<<<<<<< + * return False + * + */ + } + + /* "gevent/_semaphore.py":226 + * return False + * + * timeout = self._do_wait(timeout) # <<<<<<<<<<<<<< + * if timeout is not None: + * # Our timer expired. + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->_do_wait(__pyx_v_self, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_1); + __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":227 + * + * timeout = self._do_wait(timeout) + * if timeout is not None: # <<<<<<<<<<<<<< + * # Our timer expired. + * return False + */ + __pyx_t_8 = (__pyx_v_timeout != Py_None); + __pyx_t_9 = (__pyx_t_8 != 0); + if (__pyx_t_9) { + + /* "gevent/_semaphore.py":229 + * if timeout is not None: + * # Our timer expired. + * return False # <<<<<<<<<<<<<< + * + * # Neither our timer no another one expired, so we blocked until + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "gevent/_semaphore.py":227 + * + * timeout = self._do_wait(timeout) + * if timeout is not None: # <<<<<<<<<<<<<< + * # Our timer expired. + * return False + */ + } + + /* "gevent/_semaphore.py":233 + * # Neither our timer no another one expired, so we blocked until + * # awoke. Therefore, the counter is ours + * self.counter -= 1 # <<<<<<<<<<<<<< + * assert self.counter >= 0 + * return True + */ + __pyx_v_self->counter = (__pyx_v_self->counter - 1); + + /* "gevent/_semaphore.py":234 + * # awoke. Therefore, the counter is ours + * self.counter -= 1 + * assert self.counter >= 0 # <<<<<<<<<<<<<< + * return True + * + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + if (unlikely(!((__pyx_v_self->counter >= 0) != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(0, 234, __pyx_L1_error) + } + } + #endif + + /* "gevent/_semaphore.py":235 + * self.counter -= 1 + * assert self.counter >= 0 + * return True # <<<<<<<<<<<<<< + * + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + */ + __pyx_r = 1; + goto __pyx_L0; + + /* "gevent/_semaphore.py":198 + * return self.counter + * + * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< + * """ + * acquire(blocking=True, timeout=None) -> bool + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1000; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_timeout); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6gevent_10_semaphore_9Semaphore_18acquire[] = "\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_10_semaphore_9Semaphore_19acquire = {"acquire", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gevent_10_semaphore_9Semaphore_18acquire}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_19acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_blocking; + PyObject *__pyx_v_timeout = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("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 = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_blocking); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) __PYX_ERR(0, 198, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_blocking = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L3_error) + } else { + __pyx_v_blocking = ((int)1); + } + __pyx_v_timeout = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 198, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_blocking, __pyx_v_timeout); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_18acquire(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_v_blocking, PyObject *__pyx_v_timeout) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("acquire", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 2; + __pyx_t_2.blocking = __pyx_v_blocking; + __pyx_t_2.timeout = __pyx_v_timeout; + __pyx_t_1 = __pyx_vtabptr_6gevent_10_semaphore_Semaphore->acquire(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1000)) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":239 + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.acquire() + * + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + __Pyx_RefNannySetupContext("__enter__", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":240 + * + * def __enter__(self): + * self.acquire() # <<<<<<<<<<<<<< + * + * def __exit__(self, t, v, tb): + */ + __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->acquire(__pyx_v_self, 0, NULL); if (unlikely(__pyx_t_5 == -1000)) __PYX_ERR(0, 240, __pyx_L1_error) + + /* "gevent/_semaphore.py":239 + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.acquire() + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_21__enter__ = {"__enter__", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_21__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_20__enter__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__enter__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore___enter__(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":242 + * self.acquire() + * + * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< + * self.release() + * + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6gevent_10_semaphore_9Semaphore___exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("__exit__", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + __pyx_t_5 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_5 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_t, __pyx_v_v, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_t); + __Pyx_GIVEREF(__pyx_v_t); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_t); + __Pyx_INCREF(__pyx_v_v); + __Pyx_GIVEREF(__pyx_v_v); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_v); + __Pyx_INCREF(__pyx_v_tb); + __Pyx_GIVEREF(__pyx_v_tb); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":243 + * + * def __exit__(self, t, v, tb): + * self.release() # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = ((struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore *)__pyx_v_self->__pyx_vtab)->release(__pyx_v_self, 0); if (unlikely(__pyx_t_5 == -1000)) __PYX_ERR(0, 243, __pyx_L1_error) + + /* "gevent/_semaphore.py":242 + * self.acquire() + * + * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< + * self.release() + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_9Semaphore_23__exit__ = {"__exit__", (PyCFunction)__pyx_pw_6gevent_10_semaphore_9Semaphore_23__exit__, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_23__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; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__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 = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 242, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 242, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 242, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_t = values[0]; + __pyx_v_v = values[1]; + __pyx_v_tb = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 242, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_22__exit__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_v, PyObject *__pyx_v_tb) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__exit__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_9Semaphore___exit__(__pyx_v_self, __pyx_v_t, __pyx_v_v, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.pxd":2 + * cdef class Semaphore: + * cdef public int counter # <<<<<<<<<<<<<< + * cdef readonly object _links + * cdef readonly object _notifier + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_7counter___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore.counter.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_10_semaphore_9Semaphore_7counter_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__set__", 0); + __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_v_self->counter = __pyx_t_1; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore.counter.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.pxd":3 + * cdef class Semaphore: + * cdef public int counter + * cdef readonly object _links # <<<<<<<<<<<<<< + * cdef readonly object _notifier + * cdef public int _dirty + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_links___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_links); + __pyx_r = __pyx_v_self->_links; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.pxd":4 + * cdef public int counter + * cdef readonly object _links + * cdef readonly object _notifier # <<<<<<<<<<<<<< + * cdef public int _dirty + * cdef object __weakref__ + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_9_notifier___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_notifier); + __pyx_r = __pyx_v_self->_notifier; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.pxd":5 + * cdef readonly object _links + * cdef readonly object _notifier + * cdef public int _dirty # <<<<<<<<<<<<<< + * cdef object __weakref__ + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty___get__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_dirty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.Semaphore._dirty.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_10_semaphore_9Semaphore_6_dirty_2__set__(struct __pyx_obj_6gevent_10_semaphore_Semaphore *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__set__", 0); + __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5, __pyx_L1_error) + __pyx_v_self->_dirty = __pyx_t_1; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent._semaphore.Semaphore._dirty.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":262 + * _OVER_RELEASE_ERROR = ValueError + * + * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< + * Semaphore.__init__(self, *args, **kwargs) + * self._initial_value = self.counter + */ + +/* Python wrapper */ +static int __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_10_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; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1; + if (unlikely(__pyx_kwds)) { + __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return -1; + __Pyx_GOTREF(__pyx_v_kwargs); + } else { + __pyx_v_kwargs = NULL; + } + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore___init__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "gevent/_semaphore.py":263 + * + * def __init__(self, *args, **kwargs): + * Semaphore.__init__(self, *args, **kwargs) # <<<<<<<<<<<<<< + * self._initial_value = self.counter + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore), __pyx_n_s_init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":264 + * def __init__(self, *args, **kwargs): + * Semaphore.__init__(self, *args, **kwargs) + * self._initial_value = self.counter # <<<<<<<<<<<<<< + * + * def release(self): + */ + __pyx_t_4 = __pyx_v_self->__pyx_base.counter; + __pyx_v_self->_initial_value = __pyx_t_4; + + /* "gevent/_semaphore.py":262 + * _OVER_RELEASE_ERROR = ValueError + * + * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< + * Semaphore.__init__(self, *args, **kwargs) + * self._initial_value = self.counter + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.py":266 + * self._initial_value = self.counter + * + * def release(self): # <<<<<<<<<<<<<< + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + */ + +static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static int __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + __Pyx_RefNannySetupContext("release", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_5; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/_semaphore.py":267 + * + * def release(self): + * if self.counter >= self._initial_value: # <<<<<<<<<<<<<< + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + * return Semaphore.release(self) + */ + __pyx_t_6 = ((__pyx_v_self->__pyx_base.counter >= __pyx_v_self->_initial_value) != 0); + if (__pyx_t_6) { + + /* "gevent/_semaphore.py":268 + * def release(self): + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<< + * return Semaphore.release(self) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_OVER_RELEASE_ERROR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 268, __pyx_L1_error) + + /* "gevent/_semaphore.py":267 + * + * def release(self): + * if self.counter >= self._initial_value: # <<<<<<<<<<<<<< + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + * return Semaphore.release(self) + */ + } + + /* "gevent/_semaphore.py":269 + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + * return Semaphore.release(self) # <<<<<<<<<<<<<< + */ + __pyx_t_5 = __pyx_f_6gevent_10_semaphore_9Semaphore_release(((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)__pyx_v_self), 1); if (unlikely(__pyx_t_5 == -1000)) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_r = __pyx_t_5; + goto __pyx_L0; + + /* "gevent/_semaphore.py":266 + * self._initial_value = self.counter + * + * def release(self): # <<<<<<<<<<<<<< + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1000; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_10_semaphore_16BoundedSemaphore_3release = {"release", (PyCFunction)__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_3release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("release (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_2release(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("release", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == -1000)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore.release", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/_semaphore.pxd":21 + * + * cdef class BoundedSemaphore(Semaphore): + * cdef readonly int _initial_value # <<<<<<<<<<<<<< + * + * cpdef int release(self) except -1000 + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value___get__(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_initial_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 21, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent._semaphore.BoundedSemaphore._initial_value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore __pyx_vtable_6gevent_10_semaphore_Semaphore; + +static PyObject *__pyx_tp_new_6gevent_10_semaphore_Semaphore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_6gevent_10_semaphore_Semaphore *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o); + p->__pyx_vtab = __pyx_vtabptr_6gevent_10_semaphore_Semaphore; + p->_links = Py_None; Py_INCREF(Py_None); + p->_notifier = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore(PyObject *o) { + struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + if (p->__weakref__) PyObject_ClearWeakRefs(o); + Py_CLEAR(p->_links); + Py_CLEAR(p->_notifier); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6gevent_10_semaphore_Semaphore(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; + if (p->_links) { + e = (*v)(p->_links, a); if (e) return e; + } + if (p->_notifier) { + e = (*v)(p->_notifier, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_10_semaphore_Semaphore(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6gevent_10_semaphore_Semaphore *p = (struct __pyx_obj_6gevent_10_semaphore_Semaphore *)o; + tmp = ((PyObject*)p->_links); + p->_links = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_notifier); + p->_notifier = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore_counter(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_1__get__(o); +} + +static int __pyx_setprop_6gevent_10_semaphore_9Semaphore_counter(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_7counter_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__links(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_links_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__notifier(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_9_notifier_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_10_semaphore_9Semaphore__dirty(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_1__get__(o); +} + +static int __pyx_setprop_6gevent_10_semaphore_9Semaphore__dirty(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_10_semaphore_9Semaphore_6_dirty_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyMethodDef __pyx_methods_6gevent_10_semaphore_Semaphore[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_10_semaphore_Semaphore[] = { + {(char *)"counter", __pyx_getprop_6gevent_10_semaphore_9Semaphore_counter, __pyx_setprop_6gevent_10_semaphore_9Semaphore_counter, (char *)0, 0}, + {(char *)"_links", __pyx_getprop_6gevent_10_semaphore_9Semaphore__links, 0, (char *)0, 0}, + {(char *)"_notifier", __pyx_getprop_6gevent_10_semaphore_9Semaphore__notifier, 0, (char *)0, 0}, + {(char *)"_dirty", __pyx_getprop_6gevent_10_semaphore_9Semaphore__dirty, __pyx_setprop_6gevent_10_semaphore_9Semaphore__dirty, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_6gevent_10_semaphore_Semaphore = { + PyVarObject_HEAD_INIT(0, 0) + "gevent._semaphore.Semaphore", /*tp_name*/ + sizeof(struct __pyx_obj_6gevent_10_semaphore_Semaphore), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "\n Semaphore(value=1) -> Semaphore\n\n A semaphore manages a counter representing the number of release()\n calls minus the number of acquire() calls, plus an initial value.\n The acquire() method blocks if necessary until it can return\n without making the counter negative.\n\n If not given, ``value`` defaults to 1.\n\n The semaphore is a context manager and can be used in ``with`` statements.\n\n This Semaphore's ``__exit__`` method does not call the trace function\n on CPython, but does under PyPy.\n\n .. seealso:: :class:`BoundedSemaphore` for a safer version that prevents\n some classes of bugs.\n ", /*tp_doc*/ + __pyx_tp_traverse_6gevent_10_semaphore_Semaphore, /*tp_traverse*/ + __pyx_tp_clear_6gevent_10_semaphore_Semaphore, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_10_semaphore_Semaphore, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_10_semaphore_Semaphore, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_10_semaphore_9Semaphore_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_10_semaphore_Semaphore, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_6gevent_10_semaphore_BoundedSemaphore __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore; + +static PyObject *__pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *p; + PyObject *o = __pyx_tp_new_6gevent_10_semaphore_Semaphore(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6gevent_10_semaphore_Semaphore*)__pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore; + return o; +} + +static PyObject *__pyx_getprop_6gevent_10_semaphore_16BoundedSemaphore__initial_value(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_14_initial_value_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_10_semaphore_BoundedSemaphore[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_10_semaphore_BoundedSemaphore[] = { + {(char *)"_initial_value", __pyx_getprop_6gevent_10_semaphore_16BoundedSemaphore__initial_value, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_6gevent_10_semaphore_BoundedSemaphore = { + PyVarObject_HEAD_INIT(0, 0) + "gevent._semaphore.BoundedSemaphore", /*tp_name*/ + sizeof(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_10_semaphore_Semaphore, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_10_semaphore_9Semaphore_3__str__, /*tp_str*/ + #else + 0, /*tp_str*/ + #endif + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "\n BoundedSemaphore(value=1) -> BoundedSemaphore\n\n A bounded semaphore checks to make sure its current value doesn't\n exceed its initial value. If it does, :class:`ValueError` is\n raised. In most situations semaphores are used to guard resources\n with limited capacity. If the semaphore is released too many times\n it's a sign of a bug.\n\n If not given, *value* defaults to 1.\n ", /*tp_doc*/ + __pyx_tp_traverse_6gevent_10_semaphore_Semaphore, /*tp_traverse*/ + __pyx_tp_clear_6gevent_10_semaphore_Semaphore, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_10_semaphore_BoundedSemaphore, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_10_semaphore_BoundedSemaphore, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_10_semaphore_16BoundedSemaphore_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_10_semaphore_BoundedSemaphore, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "_semaphore", + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, + {&__pyx_n_s_BoundedSemaphore, __pyx_k_BoundedSemaphore, sizeof(__pyx_k_BoundedSemaphore), 0, 0, 1, 1}, + {&__pyx_n_s_BoundedSemaphore_release, __pyx_k_BoundedSemaphore_release, sizeof(__pyx_k_BoundedSemaphore_release), 0, 0, 1, 1}, + {&__pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_k_C_projects_gevent_src_gevent__se, sizeof(__pyx_k_C_projects_gevent_src_gevent__se), 0, 0, 1, 0}, + {&__pyx_kp_s_Expected_callable, __pyx_k_Expected_callable, sizeof(__pyx_k_Expected_callable), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_switch_into_Semaphore_wa, __pyx_k_Invalid_switch_into_Semaphore_wa, sizeof(__pyx_k_Invalid_switch_into_Semaphore_wa), 0, 0, 1, 0}, + {&__pyx_n_s_OVER_RELEASE_ERROR, __pyx_k_OVER_RELEASE_ERROR, sizeof(__pyx_k_OVER_RELEASE_ERROR), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore, __pyx_k_Semaphore, sizeof(__pyx_k_Semaphore), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore___enter, __pyx_k_Semaphore___enter, sizeof(__pyx_k_Semaphore___enter), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore___exit, __pyx_k_Semaphore___exit, sizeof(__pyx_k_Semaphore___exit), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore__notify_links, __pyx_k_Semaphore__notify_links, sizeof(__pyx_k_Semaphore__notify_links), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore__start_notify, __pyx_k_Semaphore__start_notify, sizeof(__pyx_k_Semaphore__start_notify), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore_acquire, __pyx_k_Semaphore_acquire, sizeof(__pyx_k_Semaphore_acquire), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore_locked, __pyx_k_Semaphore_locked, sizeof(__pyx_k_Semaphore_locked), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore_rawlink, __pyx_k_Semaphore_rawlink, sizeof(__pyx_k_Semaphore_rawlink), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore_release, __pyx_k_Semaphore_release, sizeof(__pyx_k_Semaphore_release), 0, 0, 1, 1}, + {&__pyx_kp_s_Semaphore_released_too_many_time, __pyx_k_Semaphore_released_too_many_time, sizeof(__pyx_k_Semaphore_released_too_many_time), 0, 0, 1, 0}, + {&__pyx_n_s_Semaphore_unlink, __pyx_k_Semaphore_unlink, sizeof(__pyx_k_Semaphore_unlink), 0, 0, 1, 1}, + {&__pyx_n_s_Semaphore_wait, __pyx_k_Semaphore_wait, sizeof(__pyx_k_Semaphore_wait), 0, 0, 1, 1}, + {&__pyx_n_s_Timeout, __pyx_k_Timeout, sizeof(__pyx_k_Timeout), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, + {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1}, + {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1}, + {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1}, + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, + {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1}, + {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, + {&__pyx_n_s_get_hub, __pyx_k_get_hub, sizeof(__pyx_k_get_hub), 0, 0, 1, 1}, + {&__pyx_n_s_getcurrent, __pyx_k_getcurrent, sizeof(__pyx_k_getcurrent), 0, 0, 1, 1}, + {&__pyx_n_s_gevent__semaphore, __pyx_k_gevent__semaphore, sizeof(__pyx_k_gevent__semaphore), 0, 0, 1, 1}, + {&__pyx_n_s_gevent_hub, __pyx_k_gevent_hub, sizeof(__pyx_k_gevent_hub), 0, 0, 1, 1}, + {&__pyx_n_s_gevent_timeout, __pyx_k_gevent_timeout, sizeof(__pyx_k_gevent_timeout), 0, 0, 1, 1}, + {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, + {&__pyx_n_s_locked, __pyx_k_locked, sizeof(__pyx_k_locked), 0, 0, 1, 1}, + {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_notify_links, __pyx_k_notify_links, sizeof(__pyx_k_notify_links), 0, 0, 1, 1}, + {&__pyx_n_s_py3k_acquire, __pyx_k_py3k_acquire, sizeof(__pyx_k_py3k_acquire), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_rawlink, __pyx_k_rawlink, sizeof(__pyx_k_rawlink), 0, 0, 1, 1}, + {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1}, + {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1}, + {&__pyx_n_s_run_callback, __pyx_k_run_callback, sizeof(__pyx_k_run_callback), 0, 0, 1, 1}, + {&__pyx_kp_s_s_counter_s__links_s, __pyx_k_s_counter_s__links_s, sizeof(__pyx_k_s_counter_s__links_s), 0, 0, 1, 0}, + {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, + {&__pyx_kp_s_semaphore_initial_value_must_be, __pyx_k_semaphore_initial_value_must_be, sizeof(__pyx_k_semaphore_initial_value_must_be), 0, 0, 1, 0}, + {&__pyx_n_s_start_new_or_dummy, __pyx_k_start_new_or_dummy, sizeof(__pyx_k_start_new_or_dummy), 0, 0, 1, 1}, + {&__pyx_n_s_start_notify, __pyx_k_start_notify, sizeof(__pyx_k_start_notify), 0, 0, 1, 1}, + {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1}, + {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, + {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1}, + {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1}, + {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1}, + {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1}, + {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, + {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 148, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "gevent/_semaphore.py":31 + * def __init__(self, value=1): + * if value < 0: + * raise ValueError("semaphore initial value must be >= 0") # <<<<<<<<<<<<<< + * self.counter = value + * self._dirty = False + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_semaphore_initial_value_must_be); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 31, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "gevent/_semaphore.py":268 + * def release(self): + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") # <<<<<<<<<<<<<< + * return Semaphore.release(self) + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Semaphore_released_too_many_time); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "gevent/_semaphore.py":56 + * return '<%s counter=%s _links[%s]>' % params + * + * def locked(self): # <<<<<<<<<<<<<< + * """Return a boolean indicating whether the semaphore can be acquired. + * Most useful with binary semaphores.""" + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_locked, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 56, __pyx_L1_error) + + /* "gevent/_semaphore.py":61 + * return self.counter <= 0 + * + * def release(self): # <<<<<<<<<<<<<< + * """ + * Release the semaphore, notifying any waiters if needed. + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_release, 61, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 61, __pyx_L1_error) + + /* "gevent/_semaphore.py":69 + * return self.counter + * + * def _start_notify(self): # <<<<<<<<<<<<<< + * if self._links and self.counter > 0 and not self._notifier: + * # We create a new self._notifier each time through the loop, + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_start_notify, 69, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 69, __pyx_L1_error) + + /* "gevent/_semaphore.py":80 + * self._notifier = get_hub().loop.run_callback(self._notify_links) + * + * def _notify_links(self): # <<<<<<<<<<<<<< + * # Subclasses CANNOT override. This is a cdef method. + * + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_notify_links, 80, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 80, __pyx_L1_error) + + /* "gevent/_semaphore.py":116 + * self._notifier = None + * + * def rawlink(self, callback): # <<<<<<<<<<<<<< + * """ + * rawlink(callback) -> None + */ + __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_rawlink, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 116, __pyx_L1_error) + + /* "gevent/_semaphore.py":136 + * self._dirty = True + * + * def unlink(self, callback): # <<<<<<<<<<<<<< + * """ + * unlink(callback) -> None + */ + __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_unlink, 136, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 136, __pyx_L1_error) + + /* "gevent/_semaphore.py":177 + * self.unlink(switch) + * + * def wait(self, timeout=None): # <<<<<<<<<<<<<< + * """ + * wait(timeout=None) -> int + */ + __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_wait, 177, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 177, __pyx_L1_error) + + /* "gevent/_semaphore.py":198 + * return self.counter + * + * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< + * """ + * acquire(blocking=True, timeout=None) -> bool + */ + __pyx_tuple__17 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_blocking, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_acquire, 198, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 198, __pyx_L1_error) + + /* "gevent/_semaphore.py":239 + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.acquire() + * + */ + __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); + __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_enter, 239, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 239, __pyx_L1_error) + + /* "gevent/_semaphore.py":242 + * self.acquire() + * + * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< + * self.release() + * + */ + __pyx_tuple__21 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_exit, 242, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 242, __pyx_L1_error) + + /* "gevent/_semaphore.py":266 + * self._initial_value = self.counter + * + * def release(self): # <<<<<<<<<<<<<< + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + */ + __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); + __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent__se, __pyx_n_s_release, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_semaphore(void); /*proto*/ +PyMODINIT_FUNC init_semaphore(void) +#else +PyMODINIT_FUNC PyInit__semaphore(void); /*proto*/ +PyMODINIT_FUNC PyInit__semaphore(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__semaphore(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("_semaphore", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_gevent___semaphore) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "gevent._semaphore")) { + if (unlikely(PyDict_SetItemString(modules, "gevent._semaphore", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_6gevent_10_semaphore_Semaphore = &__pyx_vtable_6gevent_10_semaphore_Semaphore; + __pyx_vtable_6gevent_10_semaphore_Semaphore.locked = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_locked; + __pyx_vtable_6gevent_10_semaphore_Semaphore.release = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_release; + __pyx_vtable_6gevent_10_semaphore_Semaphore.rawlink = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_rawlink; + __pyx_vtable_6gevent_10_semaphore_Semaphore.unlink = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore_unlink; + __pyx_vtable_6gevent_10_semaphore_Semaphore._start_notify = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore__start_notify; + __pyx_vtable_6gevent_10_semaphore_Semaphore._notify_links = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore__notify_links; + __pyx_vtable_6gevent_10_semaphore_Semaphore._do_wait = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *))__pyx_f_6gevent_10_semaphore_9Semaphore__do_wait; + __pyx_vtable_6gevent_10_semaphore_Semaphore.wait = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_wait *__pyx_optional_args))__pyx_f_6gevent_10_semaphore_9Semaphore_wait; + __pyx_vtable_6gevent_10_semaphore_Semaphore.acquire = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_10_semaphore_9Semaphore_acquire *__pyx_optional_args))__pyx_f_6gevent_10_semaphore_9Semaphore_acquire; + __pyx_vtable_6gevent_10_semaphore_Semaphore.__pyx___enter__ = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore___enter__; + __pyx_vtable_6gevent_10_semaphore_Semaphore.__pyx___exit__ = (PyObject *(*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_9Semaphore___exit__; + if (PyType_Ready(&__pyx_type_6gevent_10_semaphore_Semaphore) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + __pyx_type_6gevent_10_semaphore_Semaphore.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6gevent_10_semaphore_Semaphore.tp_dict, __pyx_vtabptr_6gevent_10_semaphore_Semaphore) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Semaphore", (PyObject *)&__pyx_type_6gevent_10_semaphore_Semaphore) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + if (__pyx_type_6gevent_10_semaphore_Semaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_10_semaphore_Semaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_10_semaphore_Semaphore, __weakref__); + __pyx_ptype_6gevent_10_semaphore_Semaphore = &__pyx_type_6gevent_10_semaphore_Semaphore; + __pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore = &__pyx_vtable_6gevent_10_semaphore_BoundedSemaphore; + __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore.__pyx_base = *__pyx_vtabptr_6gevent_10_semaphore_Semaphore; + __pyx_vtable_6gevent_10_semaphore_BoundedSemaphore.__pyx_base.release = (int (*)(struct __pyx_obj_6gevent_10_semaphore_Semaphore *, int __pyx_skip_dispatch))__pyx_f_6gevent_10_semaphore_16BoundedSemaphore_release; + __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_base = __pyx_ptype_6gevent_10_semaphore_Semaphore; + if (PyType_Ready(&__pyx_type_6gevent_10_semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_dict, __pyx_vtabptr_6gevent_10_semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "BoundedSemaphore", (PyObject *)&__pyx_type_6gevent_10_semaphore_BoundedSemaphore) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + if (__pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_weaklistoffset == 0) __pyx_type_6gevent_10_semaphore_BoundedSemaphore.tp_weaklistoffset = offsetof(struct __pyx_obj_6gevent_10_semaphore_BoundedSemaphore, __pyx_base.__weakref__); + __pyx_ptype_6gevent_10_semaphore_BoundedSemaphore = &__pyx_type_6gevent_10_semaphore_BoundedSemaphore; + /*--- Type import code ---*/ + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "gevent/_semaphore.py":1 + * import sys # <<<<<<<<<<<<<< + * from gevent.hub import get_hub, getcurrent + * from gevent.timeout import Timeout + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":2 + * import sys + * from gevent.hub import get_hub, getcurrent # <<<<<<<<<<<<<< + * from gevent.timeout import Timeout + * + */ + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_get_hub); + __Pyx_GIVEREF(__pyx_n_s_get_hub); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_hub); + __Pyx_INCREF(__pyx_n_s_getcurrent); + __Pyx_GIVEREF(__pyx_n_s_getcurrent); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_getcurrent); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent_hub, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_hub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_hub, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_getcurrent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_getcurrent, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/_semaphore.py":3 + * import sys + * from gevent.hub import get_hub, getcurrent + * from gevent.timeout import Timeout # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_Timeout); + __Pyx_GIVEREF(__pyx_n_s_Timeout); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Timeout); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_timeout, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timeout, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":6 + * + * + * __all__ = ['Semaphore', 'BoundedSemaphore'] # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_Semaphore); + __Pyx_GIVEREF(__pyx_n_s_Semaphore); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Semaphore); + __Pyx_INCREF(__pyx_n_s_BoundedSemaphore); + __Pyx_GIVEREF(__pyx_n_s_BoundedSemaphore); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_BoundedSemaphore); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/_semaphore.py":56 + * return '<%s counter=%s _links[%s]>' % params + * + * def locked(self): # <<<<<<<<<<<<<< + * """Return a boolean indicating whether the semaphore can be acquired. + * Most useful with binary semaphores.""" + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_5locked, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_locked, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_locked, __pyx_t_1) < 0) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":61 + * return self.counter <= 0 + * + * def release(self): # <<<<<<<<<<<<<< + * """ + * Release the semaphore, notifying any waiters if needed. + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_release, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_release, __pyx_t_1) < 0) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":69 + * return self.counter + * + * def _start_notify(self): # <<<<<<<<<<<<<< + * if self._links and self.counter > 0 and not self._notifier: + * # We create a new self._notifier each time through the loop, + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_9_start_notify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__start_notify, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_start_notify, __pyx_t_1) < 0) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":80 + * self._notifier = get_hub().loop.run_callback(self._notify_links) + * + * def _notify_links(self): # <<<<<<<<<<<<<< + * # Subclasses CANNOT override. This is a cdef method. + * + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_11_notify_links, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore__notify_links, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_notify_links, __pyx_t_1) < 0) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":116 + * self._notifier = None + * + * def rawlink(self, callback): # <<<<<<<<<<<<<< + * """ + * rawlink(callback) -> None + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_13rawlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_rawlink, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_rawlink, __pyx_t_1) < 0) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":136 + * self._dirty = True + * + * def unlink(self, callback): # <<<<<<<<<<<<<< + * """ + * unlink(callback) -> None + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_15unlink, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_unlink, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_unlink, __pyx_t_1) < 0) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":177 + * self.unlink(switch) + * + * def wait(self, timeout=None): # <<<<<<<<<<<<<< + * """ + * wait(timeout=None) -> int + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_17wait, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_wait, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_wait, __pyx_t_1) < 0) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":198 + * return self.counter + * + * def acquire(self, blocking=True, timeout=None): # <<<<<<<<<<<<<< + * """ + * acquire(blocking=True, timeout=None) -> bool + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_19acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore_acquire, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_acquire, __pyx_t_1) < 0) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":237 + * return True + * + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython # <<<<<<<<<<<<<< + * + * def __enter__(self): + */ + __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore, __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_py3k_acquire, __pyx_t_1) < 0) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":239 + * _py3k_acquire = acquire # PyPy needs this; it must be static for Cython + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.acquire() + * + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_21__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___enter, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_enter, __pyx_t_1) < 0) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":242 + * self.acquire() + * + * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< + * self.release() + * + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_9Semaphore_23__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Semaphore___exit, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_Semaphore->tp_dict, __pyx_n_s_exit, __pyx_t_1) < 0) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_Semaphore); + + /* "gevent/_semaphore.py":260 + * + * #: For monkey-patching, allow changing the class of error we raise + * _OVER_RELEASE_ERROR = ValueError # <<<<<<<<<<<<<< + * + * def __init__(self, *args, **kwargs): + */ + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_OVER_RELEASE_ERROR, __pyx_builtin_ValueError) < 0) __PYX_ERR(0, 260, __pyx_L1_error) + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore); + + /* "gevent/_semaphore.py":266 + * self._initial_value = self.counter + * + * def release(self): # <<<<<<<<<<<<<< + * if self.counter >= self._initial_value: + * raise self._OVER_RELEASE_ERROR("Semaphore released too many times") + */ + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_10_semaphore_16BoundedSemaphore_3release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BoundedSemaphore_release, NULL, __pyx_n_s_gevent__semaphore, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore->tp_dict, __pyx_n_s_release, __pyx_t_1) < 0) __PYX_ERR(0, 266, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyType_Modified(__pyx_ptype_6gevent_10_semaphore_BoundedSemaphore); + + /* "gevent/_semaphore.py":1 + * import sys # <<<<<<<<<<<<<< + * from gevent.hub import get_hub, getcurrent + * from gevent.timeout import Timeout + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init gevent._semaphore", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init gevent._semaphore"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); +} +#endif // CYTHON_FAST_PYCCALL + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif // CPython < 3.6 +#endif // CYTHON_FAST_PYCALL + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* GetModuleGlobalName */ + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* SwapException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* PyObjectCallMethod1 */ + static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { + PyObject *method, *result = NULL; + method = __Pyx_PyObject_GetAttrStr(obj, method_name); + if (unlikely(!method)) goto done; +#if CYTHON_UNPACK_METHODS + if (likely(PyMethod_Check(method))) { + PyObject *self = PyMethod_GET_SELF(method); + if (likely(self)) { + PyObject *args; + PyObject *function = PyMethod_GET_FUNCTION(method); + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyFunction_FastCall(function, args, 2); + goto done; + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyCFunction_FastCall(function, args, 2); + goto done; + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 1, arg); + Py_INCREF(function); + Py_DECREF(method); method = NULL; + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); + return result; + } + } +#endif + result = __Pyx_PyObject_CallOneArg(method, arg); +done: + Py_XDECREF(method); + return result; +} + +/* append */ + static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { + if (likely(PyList_CheckExact(L))) { + if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; + } else { + PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); + if (unlikely(!retval)) + return -1; + Py_DECREF(retval); + } + return 0; +} + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + return PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* KeywordStringCheck */ + static CYTHON_INLINE int __Pyx_CheckKeywordStrings( + PyObject *kwdict, + const char* function_name, + int kw_allowed) +{ + PyObject* key = 0; + Py_ssize_t pos = 0; +#if CYTHON_COMPILING_IN_PYPY + if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) + goto invalid_keyword; + return 1; +#else + while (PyDict_Next(kwdict, &pos, &key, 0)) { + #if PY_MAJOR_VERSION < 3 + if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + #endif + if (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; + } + if ((!kw_allowed) && unlikely(key)) + goto invalid_keyword; + return 1; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + return 0; +#endif +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif + return 0; +} + +/* SetVTable */ + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* Import */ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* ImportFrom */ + static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* FetchCommonType */ + static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } +done: + Py_DECREF(fake_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + +/* CythonFunction */ + static PyObject * +__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) +{ + if (unlikely(op->func_doc == NULL)) { + if (op->func.m_ml->ml_doc) { +#if PY_MAJOR_VERSION >= 3 + op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); +#else + op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); +#endif + if (unlikely(op->func_doc == NULL)) + return NULL; + } else { + Py_INCREF(Py_None); + return Py_None; + } + } + Py_INCREF(op->func_doc); + return op->func_doc; +} +static int +__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp = op->func_doc; + if (value == NULL) { + value = Py_None; + } + Py_INCREF(value); + op->func_doc = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) +{ + if (unlikely(op->func_name == NULL)) { +#if PY_MAJOR_VERSION >= 3 + op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); +#else + op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); +#endif + if (unlikely(op->func_name == NULL)) + return NULL; + } + Py_INCREF(op->func_name); + return op->func_name; +} +static int +__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) +{ + Py_INCREF(op->func_qualname); + return op->func_qualname; +} +static int +__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = op->func_qualname; + Py_INCREF(value); + op->func_qualname = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) +{ + PyObject *self; + self = m->func_closure; + if (self == NULL) + self = Py_None; + Py_INCREF(self); + return self; +} +static PyObject * +__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) +{ + if (unlikely(op->func_dict == NULL)) { + op->func_dict = PyDict_New(); + if (unlikely(op->func_dict == NULL)) + return NULL; + } + Py_INCREF(op->func_dict); + return op->func_dict; +} +static int +__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; + if (unlikely(value == NULL)) { + PyErr_SetString(PyExc_TypeError, + "function's dictionary may not be deleted"); + return -1; + } + if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "setting function's dictionary to a non-dict"); + return -1; + } + tmp = op->func_dict; + Py_INCREF(value); + op->func_dict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) +{ + Py_INCREF(op->func_globals); + return op->func_globals; +} +static PyObject * +__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) +{ + Py_INCREF(Py_None); + return Py_None; +} +static PyObject * +__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) +{ + PyObject* result = (op->func_code) ? op->func_code : Py_None; + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { + int result = 0; + PyObject *res = op->defaults_getter((PyObject *) op); + if (unlikely(!res)) + return -1; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + op->defaults_tuple = PyTuple_GET_ITEM(res, 0); + Py_INCREF(op->defaults_tuple); + op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); + Py_INCREF(op->defaults_kwdict); + #else + op->defaults_tuple = PySequence_ITEM(res, 0); + if (unlikely(!op->defaults_tuple)) result = -1; + else { + op->defaults_kwdict = PySequence_ITEM(res, 1); + if (unlikely(!op->defaults_kwdict)) result = -1; + } + #endif + Py_DECREF(res); + return result; +} +static int +__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyTuple_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__defaults__ must be set to a tuple object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_tuple; + op->defaults_tuple = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { + PyObject* result = op->defaults_tuple; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_tuple; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__kwdefaults__ must be set to a dict object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_kwdict; + op->defaults_kwdict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { + PyObject* result = op->defaults_kwdict; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_kwdict; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value || value == Py_None) { + value = NULL; + } else if (!PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__annotations__ must be set to a dict object"); + return -1; + } + Py_XINCREF(value); + tmp = op->func_annotations; + op->func_annotations = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { + PyObject* result = op->func_annotations; + if (unlikely(!result)) { + result = PyDict_New(); + if (unlikely(!result)) return NULL; + op->func_annotations = result; + } + Py_INCREF(result); + return result; +} +static PyGetSetDef __pyx_CyFunction_getsets[] = { + {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, + {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, + {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, + {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, + {0, 0, 0, 0, 0} +}; +static PyMemberDef __pyx_CyFunction_members[] = { + {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, + {0, 0, 0, 0, 0} +}; +static PyObject * +__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromString(m->func.m_ml->ml_name); +#else + return PyString_FromString(m->func.m_ml->ml_name); +#endif +} +static PyMethodDef __pyx_CyFunction_methods[] = { + {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, + {0, 0, 0, 0} +}; +#if PY_VERSION_HEX < 0x030500A0 +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) +#else +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) +#endif +static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); + if (op == NULL) + return NULL; + op->flags = flags; + __Pyx_CyFunction_weakreflist(op) = NULL; + op->func.m_ml = ml; + op->func.m_self = (PyObject *) op; + Py_XINCREF(closure); + op->func_closure = closure; + Py_XINCREF(module); + op->func.m_module = module; + op->func_dict = NULL; + op->func_name = NULL; + Py_INCREF(qualname); + op->func_qualname = qualname; + op->func_doc = NULL; + op->func_classobj = NULL; + op->func_globals = globals; + Py_INCREF(op->func_globals); + Py_XINCREF(code); + op->func_code = code; + op->defaults_pyobjects = 0; + op->defaults = NULL; + op->defaults_tuple = NULL; + op->defaults_kwdict = NULL; + op->defaults_getter = NULL; + op->func_annotations = NULL; + PyObject_GC_Track(op); + return (PyObject *) op; +} +static int +__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) +{ + Py_CLEAR(m->func_closure); + Py_CLEAR(m->func.m_module); + Py_CLEAR(m->func_dict); + Py_CLEAR(m->func_name); + Py_CLEAR(m->func_qualname); + Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); + Py_CLEAR(m->func_code); + Py_CLEAR(m->func_classobj); + Py_CLEAR(m->defaults_tuple); + Py_CLEAR(m->defaults_kwdict); + Py_CLEAR(m->func_annotations); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_XDECREF(pydefaults[i]); + PyObject_Free(m->defaults); + m->defaults = NULL; + } + return 0; +} +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + if (__Pyx_CyFunction_weakreflist(m) != NULL) + PyObject_ClearWeakRefs((PyObject *) m); + __Pyx_CyFunction_clear(m); + PyObject_GC_Del(m); +} +static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) +{ + Py_VISIT(m->func_closure); + Py_VISIT(m->func.m_module); + Py_VISIT(m->func_dict); + Py_VISIT(m->func_name); + Py_VISIT(m->func_qualname); + Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); + Py_VISIT(m->func_code); + Py_VISIT(m->func_classobj); + Py_VISIT(m->defaults_tuple); + Py_VISIT(m->defaults_kwdict); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_VISIT(pydefaults[i]); + } + return 0; +} +static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { + Py_INCREF(func); + return func; + } + if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { + if (type == NULL) + type = (PyObject *)(Py_TYPE(obj)); + return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); + } + if (obj == Py_None) + obj = NULL; + return __Pyx_PyMethod_New(func, obj, type); +} +static PyObject* +__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromFormat("<cyfunction %U at %p>", + op->func_qualname, (void *)op); +#else + return PyString_FromFormat("<cyfunction %s at %p>", + PyString_AsString(op->func_qualname), (void *)op); +#endif +} +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = f->m_ml->ml_meth; + Py_ssize_t size; + switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + case METH_VARARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 0)) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 1)) { + PyObject *result, *arg0 = PySequence_ITEM(arg, 0); + if (unlikely(!arg0)) return NULL; + result = (*meth)(self, arg0); + Py_DECREF(arg0); + return result; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags in " + "__Pyx_CyFunction_Call. METH_OLDARGS is no " + "longer supported!"); + return NULL; + } + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; +} +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; +} +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + "cython_function_or_method", + sizeof(__pyx_CyFunctionObject), + 0, + (destructor) __Pyx_CyFunction_dealloc, + 0, + 0, + 0, +#if PY_MAJOR_VERSION < 3 + 0, +#else + 0, +#endif + (reprfunc) __Pyx_CyFunction_repr, + 0, + 0, + 0, + 0, + __Pyx_CyFunction_CallAsMethod, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + 0, + (traverseproc) __Pyx_CyFunction_traverse, + (inquiry) __Pyx_CyFunction_clear, + 0, +#if PY_VERSION_HEX < 0x030500A0 + offsetof(__pyx_CyFunctionObject, func_weakreflist), +#else + offsetof(PyCFunctionObject, m_weakreflist), +#endif + 0, + 0, + __pyx_CyFunction_methods, + __pyx_CyFunction_members, + __pyx_CyFunction_getsets, + 0, + 0, + __Pyx_CyFunction_descr_get, + 0, + offsetof(__pyx_CyFunctionObject, func_dict), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +}; +static int __pyx_CyFunction_init(void) { + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); + if (__pyx_CyFunctionType == NULL) { + return -1; + } + return 0; +} +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults = PyObject_Malloc(size); + if (!m->defaults) + return PyErr_NoMemory(); + memset(m->defaults, 0, size); + m->defaults_pyobjects = pyobjects; + return m->defaults; +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_kwdict = dict; + Py_INCREF(dict); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->func_annotations = dict; + Py_INCREF(dict); +} + +/* GetNameInClass */ + static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { + PyObject *result; + result = __Pyx_PyObject_GetAttrStr(nmspace, name); + if (!result) + result = __Pyx_GetModuleGlobalName(name); + return result; +} + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +#endif + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } + #else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } + #endif +#else + res = PyNumber_Int(x); +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/python/gevent/gevent.ares.c b/python/gevent/gevent.ares.c new file mode 100644 index 0000000..e1680ce --- /dev/null +++ b/python/gevent/gevent.ares.c @@ -0,0 +1,14103 @@ +/* Generated by Cython 0.25.2 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. +#else +#define CYTHON_ABI "0_25_2" +#include <stddef.h> +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include <math.h> +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__gevent__ares +#define __PYX_HAVE_API__gevent__ares +#include "ares.h" +#include "cares_pton.h" +#include "frameobject.h" +#include "dnshelper.c" +#ifdef _OPENMP +#include <omp.h> +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include <cstdlib> + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) && defined (_M_X64) + #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + + +static const char *__pyx_f[] = { + "src\\gevent\\ares.pyx", +}; + +/*--- Type declarations ---*/ +struct __pyx_obj_6gevent_4ares_result; +struct PyGeventAresChannelObject; +struct __pyx_opt_args_6gevent_4ares__convert_cares_flags; + +/* "gevent/ares.pyx":137 + * + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + */ +struct __pyx_opt_args_6gevent_4ares__convert_cares_flags { + int __pyx_n; + int __pyx_default; +}; + +/* "gevent/ares.pyx":164 + * + * + * cdef class result: # <<<<<<<<<<<<<< + * cdef public object value + * cdef public object exception + */ +struct __pyx_obj_6gevent_4ares_result { + PyObject_HEAD + PyObject *value; + PyObject *exception; +}; + + +/* "gevent/ares.pyx":245 + * + * + * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: # <<<<<<<<<<<<<< + * + * cdef public object loop + */ +struct PyGeventAresChannelObject { + PyObject_HEAD + struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtab; + PyObject *loop; + struct ares_channeldata *channel; + PyObject *_watchers; + PyObject *_timer; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type; + +struct __pyx_vtabstruct_6gevent_4ares_channel { + PyObject *(*_sock_state_callback)(struct PyGeventAresChannelObject *, int, int, int); + PyObject *(*_getnameinfo)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtabptr_6gevent_4ares_channel; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* GetAttr.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); + +/* GetAttr3.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* IterFinish.proto */ +static CYTHON_INLINE int __Pyx_IterFinish(void); + +/* UnpackItemEndCheck.proto */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* PyObjectSetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* pyobject_as_double.proto */ +static double __Pyx__PyObject_AsDouble(PyObject* obj); +#if CYTHON_COMPILING_IN_PYPY +#define __Pyx_PyObject_AsDouble(obj)\ +(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\ + likely(PyInt_CheckExact(obj)) ?\ + PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj)) +#else +#define __Pyx_PyObject_AsDouble(obj)\ +((likely(PyFloat_CheckExact(obj))) ?\ + PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) +#endif + +/* py_dict_clear.proto */ +#define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0) + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* dict_getitem_default.proto */ +static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); + +/* ArgTypeTest.proto */ +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* CalculateMetaclass.proto */ +static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); + +/* Py3ClassCreate.proto */ +static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, + PyObject *mkw, PyObject *modname, PyObject *doc); +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, + PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); + +/* FetchCommonType.proto */ +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/* CythonFunction.proto */ +#define __Pyx_CyFunction_USED 1 +#include <structmember.h> +#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 +#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 +#define __Pyx_CYFUNCTION_CCLASS 0x04 +#define __Pyx_CyFunction_GetClosure(f)\ + (((__pyx_CyFunctionObject *) (f))->func_closure) +#define __Pyx_CyFunction_GetClassObj(f)\ + (((__pyx_CyFunctionObject *) (f))->func_classobj) +#define __Pyx_CyFunction_Defaults(type, f)\ + ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) +#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ + ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) +typedef struct { + PyCFunctionObject func; +#if PY_VERSION_HEX < 0x030500A0 + PyObject *func_weakreflist; +#endif + PyObject *func_dict; + PyObject *func_name; + PyObject *func_qualname; + PyObject *func_doc; + PyObject *func_globals; + PyObject *func_code; + PyObject *func_closure; + PyObject *func_classobj; + void *defaults; + int defaults_pyobjects; + int flags; + PyObject *defaults_tuple; + PyObject *defaults_kwdict; + PyObject *(*defaults_getter)(PyObject *); + PyObject *func_annotations; +} __pyx_CyFunctionObject; +static PyTypeObject *__pyx_CyFunctionType = 0; +#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ + __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) +static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *self, + PyObject *module, PyObject *globals, + PyObject* code); +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, + size_t size, + int pyobjects); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, + PyObject *tuple); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, + PyObject *dict); +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, + PyObject *dict); +static int __pyx_CyFunction_init(void); + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write); /* proto*/ +static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch); /* proto*/ + +/* Module declarations from 'gevent.cares' */ + +/* Module declarations from 'gevent.python' */ + +/* Module declarations from 'gevent.ares' */ +static PyTypeObject *__pyx_ptype_6gevent_4ares_result = 0; +static PyTypeObject *__pyx_ptype_6gevent_4ares_channel = 0; +static PyObject *__pyx_v_6gevent_4ares_string_types = 0; +static PyObject *__pyx_v_6gevent_4ares_text_type = 0; +static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void); /*proto*/ +static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args); /*proto*/ +static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *, int __pyx_skip_dispatch); /*proto*/ +static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *, int, int, int); /*proto*/ +static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *, int, int, struct hostent *); /*proto*/ +static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *, int, int, char *, char *); /*proto*/ +#define __Pyx_MODULE_NAME "gevent.ares" +int __pyx_module_is_main_gevent__ares = 0; + +/* Implementation of 'gevent.ares' */ +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_id; +static PyObject *__pyx_builtin_MemoryError; +static PyObject *__pyx_builtin_TypeError; +static const char __pyx_k__2[] = ","; +static const char __pyx_k_fd[] = "fd"; +static const char __pyx_k_id[] = "id"; +static const char __pyx_k_io[] = "io"; +static const char __pyx_k_all[] = "__all__"; +static const char __pyx_k_cls[] = "cls"; +static const char __pyx_k_doc[] = "__doc__"; +static const char __pyx_k_get[] = "get"; +static const char __pyx_k_new[] = "__new__"; +static const char __pyx_k_pop[] = "pop"; +static const char __pyx_k_s_r[] = "%s(%r)"; +static const char __pyx_k_s_s[] = "%s: %s"; +static const char __pyx_k_sys[] = "sys"; +static const char __pyx_k_addr[] = "addr"; +static const char __pyx_k_loop[] = "loop"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_self[] = "self"; +static const char __pyx_k_stop[] = "stop"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_again[] = "again"; +static const char __pyx_k_ascii[] = "ascii"; +static const char __pyx_k_class[] = "__class__"; +static const char __pyx_k_flags[] = "flags"; +static const char __pyx_k_ndots[] = "ndots"; +static const char __pyx_k_split[] = "split"; +static const char __pyx_k_start[] = "start"; +static const char __pyx_k_timer[] = "timer"; +static const char __pyx_k_tries[] = "tries"; +static const char __pyx_k_value[] = "value"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_events[] = "events"; +static const char __pyx_k_family[] = "family"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_module[] = "__module__"; +static const char __pyx_k_name_2[] = "name"; +static const char __pyx_k_socket[] = "_socket"; +static const char __pyx_k_TIMEOUT[] = "TIMEOUT"; +static const char __pyx_k_channel[] = "channel"; +static const char __pyx_k_default[] = "default"; +static const char __pyx_k_destroy[] = "destroy"; +static const char __pyx_k_prepare[] = "__prepare__"; +static const char __pyx_k_servers[] = "servers"; +static const char __pyx_k_timeout[] = "timeout"; +static const char __pyx_k_unicode[] = "unicode"; +static const char __pyx_k_watcher[] = "watcher"; +static const char __pyx_k_ARES_EOF[] = "ARES_EOF"; +static const char __pyx_k_NI_DGRAM[] = "NI_DGRAM"; +static const char __pyx_k_builtins[] = "__builtins__"; +static const char __pyx_k_callback[] = "callback"; +static const char __pyx_k_exc_info[] = "exc_info"; +static const char __pyx_k_gaierror[] = "gaierror"; +static const char __pyx_k_iterable[] = "iterable"; +static const char __pyx_k_on_timer[] = "_on_timer"; +static const char __pyx_k_qualname[] = "__qualname__"; +static const char __pyx_k_sockaddr[] = "sockaddr"; +static const char __pyx_k_tcp_port[] = "tcp_port"; +static const char __pyx_k_udp_port[] = "udp_port"; +static const char __pyx_k_InvalidIP[] = "InvalidIP"; +static const char __pyx_k_NI_NOFQDN[] = "NI_NOFQDN"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_exception[] = "exception"; +static const char __pyx_k_metaclass[] = "__metaclass__"; +static const char __pyx_k_ARES_EFILE[] = "ARES_EFILE"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_basestring[] = "basestring"; +static const char __pyx_k_getnewargs[] = "__getnewargs__"; +static const char __pyx_k_process_fd[] = "_process_fd"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_ARES_ENOMEM[] = "ARES_ENOMEM"; +static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_NI_NAMEREQD[] = "NI_NAMEREQD"; +static const char __pyx_k_ares_errors[] = "_ares_errors"; +static const char __pyx_k_getnameinfo[] = "_getnameinfo"; +static const char __pyx_k_gevent_ares[] = "gevent.ares"; +static const char __pyx_k_pass_events[] = "pass_events"; +static const char __pyx_k_set_servers[] = "set_servers"; +static const char __pyx_k_ARES_EBADSTR[] = "ARES_EBADSTR"; +static const char __pyx_k_ARES_ENODATA[] = "ARES_ENODATA"; +static const char __pyx_k_ARES_ENONAME[] = "ARES_ENONAME"; +static const char __pyx_k_ARES_ENOTIMP[] = "ARES_ENOTIMP"; +static const char __pyx_k_ARES_SUCCESS[] = "ARES_SUCCESS"; +static const char __pyx_k_handle_error[] = "handle_error"; +static const char __pyx_k_version_info[] = "version_info"; +static const char __pyx_k_ARES_EBADNAME[] = "ARES_EBADNAME"; +static const char __pyx_k_ARES_EBADRESP[] = "ARES_EBADRESP"; +static const char __pyx_k_ARES_EFORMERR[] = "ARES_EFORMERR"; +static const char __pyx_k_ARES_EREFUSED[] = "ARES_EREFUSED"; +static const char __pyx_k_ARES_ETIMEOUT[] = "ARES_ETIMEOUT"; +static const char __pyx_k_s_exception_r[] = "%s(exception=%r)"; +static const char __pyx_k_ARES_EBADFLAGS[] = "ARES_EBADFLAGS"; +static const char __pyx_k_ARES_EBADHINTS[] = "ARES_EBADHINTS"; +static const char __pyx_k_ARES_EBADQUERY[] = "ARES_EBADQUERY"; +static const char __pyx_k_ARES_ENOTFOUND[] = "ARES_ENOTFOUND"; +static const char __pyx_k_ARES_ESERVFAIL[] = "ARES_ESERVFAIL"; +static const char __pyx_k_NI_NUMERICHOST[] = "NI_NUMERICHOST"; +static const char __pyx_k_NI_NUMERICSERV[] = "NI_NUMERICSERV"; +static const char __pyx_k_cares_flag_map[] = "_cares_flag_map"; +static const char __pyx_k_ARES_EBADFAMILY[] = "ARES_EBADFAMILY"; +static const char __pyx_k_ARES_ECANCELLED[] = "ARES_ECANCELLED"; +static const char __pyx_k_ARES_FLAG_IGNTC[] = "ARES_FLAG_IGNTC"; +static const char __pyx_k_ARES_FLAG_USEVC[] = "ARES_FLAG_USEVC"; +static const char __pyx_k_ares_host_result[] = "ares_host_result"; +static const char __pyx_k_ARES_ECONNREFUSED[] = "ARES_ECONNREFUSED"; +static const char __pyx_k_ARES_EDESTRUCTION[] = "ARES_EDESTRUCTION"; +static const char __pyx_k_ARES_FLAG_PRIMARY[] = "ARES_FLAG_PRIMARY"; +static const char __pyx_k_ARES_ELOADIPHLPAPI[] = "ARES_ELOADIPHLPAPI"; +static const char __pyx_k_ARES_FLAG_NOSEARCH[] = "ARES_FLAG_NOSEARCH"; +static const char __pyx_k_ARES_FLAG_STAYOPEN[] = "ARES_FLAG_STAYOPEN"; +static const char __pyx_k_ARES_FLAG_NOALIASES[] = "ARES_FLAG_NOALIASES"; +static const char __pyx_k_ARES_FLAG_NORECURSE[] = "ARES_FLAG_NORECURSE"; +static const char __pyx_k_ARES_ENOTINITIALIZED[] = "ARES_ENOTINITIALIZED"; +static const char __pyx_k_ARES_FLAG_NOCHECKRESP[] = "ARES_FLAG_NOCHECKRESP"; +static const char __pyx_k_s_value_r_exception_r[] = "%s(value=%r, exception=%r)"; +static const char __pyx_k_ares_host_result___new[] = "ares_host_result.__new__"; +static const char __pyx_k_expected_a_tuple_got_r[] = "expected a tuple, got %r"; +static const char __pyx_k_Invalid_value_for_port_r[] = "Invalid value for port: %r"; +static const char __pyx_k_ARES_EADDRGETNETWORKPARAMS[] = "ARES_EADDRGETNETWORKPARAMS"; +static const char __pyx_k_Bad_value_for_ai_flags_0x_x[] = "Bad value for ai_flags: 0x%x"; +static const char __pyx_k_ares_host_result___getnewargs[] = "ares_host_result.__getnewargs__"; +static const char __pyx_k_s_at_0x_x__timer_r__watchers_s[] = "<%s at 0x%x _timer=%r _watchers[%s]>"; +static const char __pyx_k_C_projects_gevent_src_gevent_are[] = "C:\\projects\\gevent\\src\\gevent\\ares.pyx"; +static const char __pyx_k_this_ares_channel_has_been_destr[] = "this ares channel has been destroyed"; +static PyObject *__pyx_n_s_ARES_EADDRGETNETWORKPARAMS; +static PyObject *__pyx_n_s_ARES_EBADFAMILY; +static PyObject *__pyx_n_s_ARES_EBADFLAGS; +static PyObject *__pyx_n_s_ARES_EBADHINTS; +static PyObject *__pyx_n_s_ARES_EBADNAME; +static PyObject *__pyx_n_s_ARES_EBADQUERY; +static PyObject *__pyx_n_s_ARES_EBADRESP; +static PyObject *__pyx_n_s_ARES_EBADSTR; +static PyObject *__pyx_n_s_ARES_ECANCELLED; +static PyObject *__pyx_n_s_ARES_ECONNREFUSED; +static PyObject *__pyx_n_s_ARES_EDESTRUCTION; +static PyObject *__pyx_n_s_ARES_EFILE; +static PyObject *__pyx_n_s_ARES_EFORMERR; +static PyObject *__pyx_n_s_ARES_ELOADIPHLPAPI; +static PyObject *__pyx_n_s_ARES_ENODATA; +static PyObject *__pyx_n_s_ARES_ENOMEM; +static PyObject *__pyx_n_s_ARES_ENONAME; +static PyObject *__pyx_n_s_ARES_ENOTFOUND; +static PyObject *__pyx_n_s_ARES_ENOTIMP; +static PyObject *__pyx_n_s_ARES_ENOTINITIALIZED; +static PyObject *__pyx_n_s_ARES_EOF; +static PyObject *__pyx_n_s_ARES_EREFUSED; +static PyObject *__pyx_n_s_ARES_ESERVFAIL; +static PyObject *__pyx_n_s_ARES_ETIMEOUT; +static PyObject *__pyx_n_s_ARES_FLAG_IGNTC; +static PyObject *__pyx_n_s_ARES_FLAG_NOALIASES; +static PyObject *__pyx_n_s_ARES_FLAG_NOCHECKRESP; +static PyObject *__pyx_n_s_ARES_FLAG_NORECURSE; +static PyObject *__pyx_n_s_ARES_FLAG_NOSEARCH; +static PyObject *__pyx_n_s_ARES_FLAG_PRIMARY; +static PyObject *__pyx_n_s_ARES_FLAG_STAYOPEN; +static PyObject *__pyx_n_s_ARES_FLAG_USEVC; +static PyObject *__pyx_n_s_ARES_SUCCESS; +static PyObject *__pyx_kp_s_Bad_value_for_ai_flags_0x_x; +static PyObject *__pyx_kp_s_C_projects_gevent_src_gevent_are; +static PyObject *__pyx_n_s_InvalidIP; +static PyObject *__pyx_kp_s_Invalid_value_for_port_r; +static PyObject *__pyx_n_s_MemoryError; +static PyObject *__pyx_n_s_NI_DGRAM; +static PyObject *__pyx_n_s_NI_NAMEREQD; +static PyObject *__pyx_n_s_NI_NOFQDN; +static PyObject *__pyx_n_s_NI_NUMERICHOST; +static PyObject *__pyx_n_s_NI_NUMERICSERV; +static PyObject *__pyx_n_s_TIMEOUT; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_kp_s__2; +static PyObject *__pyx_n_s_addr; +static PyObject *__pyx_n_s_again; +static PyObject *__pyx_n_s_all; +static PyObject *__pyx_n_s_ares_errors; +static PyObject *__pyx_n_s_ares_host_result; +static PyObject *__pyx_n_s_ares_host_result___getnewargs; +static PyObject *__pyx_n_s_ares_host_result___new; +static PyObject *__pyx_n_s_ascii; +static PyObject *__pyx_n_s_basestring; +static PyObject *__pyx_n_s_builtins; +static PyObject *__pyx_n_s_callback; +static PyObject *__pyx_n_s_cares_flag_map; +static PyObject *__pyx_n_s_channel; +static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_cls; +static PyObject *__pyx_n_s_default; +static PyObject *__pyx_n_s_destroy; +static PyObject *__pyx_n_s_doc; +static PyObject *__pyx_n_s_encode; +static PyObject *__pyx_n_s_events; +static PyObject *__pyx_n_s_exc_info; +static PyObject *__pyx_n_s_exception; +static PyObject *__pyx_kp_s_expected_a_tuple_got_r; +static PyObject *__pyx_n_s_family; +static PyObject *__pyx_n_s_fd; +static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_gaierror; +static PyObject *__pyx_n_s_get; +static PyObject *__pyx_n_s_getnameinfo; +static PyObject *__pyx_n_s_getnewargs; +static PyObject *__pyx_n_s_gevent_ares; +static PyObject *__pyx_n_s_handle_error; +static PyObject *__pyx_n_s_id; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_io; +static PyObject *__pyx_n_s_iterable; +static PyObject *__pyx_n_s_loop; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_metaclass; +static PyObject *__pyx_n_s_module; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_name_2; +static PyObject *__pyx_n_s_ndots; +static PyObject *__pyx_n_s_new; +static PyObject *__pyx_n_s_on_timer; +static PyObject *__pyx_n_s_pass_events; +static PyObject *__pyx_n_s_pop; +static PyObject *__pyx_n_s_prepare; +static PyObject *__pyx_n_s_process_fd; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_qualname; +static PyObject *__pyx_kp_s_s_at_0x_x__timer_r__watchers_s; +static PyObject *__pyx_kp_s_s_exception_r; +static PyObject *__pyx_kp_s_s_r; +static PyObject *__pyx_kp_s_s_s; +static PyObject *__pyx_kp_s_s_value_r_exception_r; +static PyObject *__pyx_n_s_self; +static PyObject *__pyx_n_s_servers; +static PyObject *__pyx_n_s_set_servers; +static PyObject *__pyx_n_s_sockaddr; +static PyObject *__pyx_n_s_socket; +static PyObject *__pyx_n_s_split; +static PyObject *__pyx_n_s_start; +static PyObject *__pyx_n_s_stop; +static PyObject *__pyx_n_s_sys; +static PyObject *__pyx_n_s_tcp_port; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_kp_s_this_ares_channel_has_been_destr; +static PyObject *__pyx_n_s_timeout; +static PyObject *__pyx_n_s_timer; +static PyObject *__pyx_n_s_tries; +static PyObject *__pyx_n_s_udp_port; +static PyObject *__pyx_n_s_unicode; +static PyObject *__pyx_n_s_value; +static PyObject *__pyx_n_s_version_info; +static PyObject *__pyx_n_s_watcher; +static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code); /* proto */ +static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_4; +static PyObject *__pyx_int_8; +static PyObject *__pyx_int_16; +static PyObject *__pyx_int_neg_1; +static PyObject *__pyx_int_neg_8; +static int __pyx_k_; +static int __pyx_k__5; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_codeobj__7; +static PyObject *__pyx_codeobj__9; + +/* "gevent/ares.pyx":126 + * + * + * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<< + * global _cares_flag_map + * import _socket + */ + +static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void) { + PyObject *__pyx_v__socket = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_RefNannySetupContext("_prepare_cares_flag_map", 0); + + /* "gevent/ares.pyx":128 + * cdef _prepare_cares_flag_map(): + * global _cares_flag_map + * import _socket # <<<<<<<<<<<<<< + * _cares_flag_map = [ + * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v__socket = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":130 + * import _socket + * _cares_flag_map = [ + * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), # <<<<<<<<<<<<<< + * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), + * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), + */ + __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICHOST, __pyx_int_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NUMERICHOST); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":131 + * _cares_flag_map = [ + * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), + * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), # <<<<<<<<<<<<<< + * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), + * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), + */ + __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICSERV, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NUMERICSERV); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":132 + * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), + * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), + * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), # <<<<<<<<<<<<<< + * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), + * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] + */ + __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NOFQDN, __pyx_int_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NOFQDN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":133 + * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), + * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), + * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), # <<<<<<<<<<<<<< + * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] + * + */ + __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NAMEREQD, __pyx_int_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NAMEREQD); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":134 + * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), + * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), + * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_DGRAM, __pyx_int_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_DGRAM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":129 + * global _cares_flag_map + * import _socket + * _cares_flag_map = [ # <<<<<<<<<<<<<< + * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), + * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), + */ + __pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, __pyx_t_2) < 0) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":126 + * + * + * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<< + * global _cares_flag_map + * import _socket + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.ares._prepare_cares_flag_map", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v__socket); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":137 + * + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + */ + +static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args) { + int __pyx_v_default = __pyx_k_; + PyObject *__pyx_v_socket_flag = NULL; + PyObject *__pyx_v_cares_flag = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *(*__pyx_t_10)(PyObject *); + int __pyx_t_11; + __Pyx_RefNannySetupContext("_convert_cares_flags", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_default = __pyx_optional_args->__pyx_default; + } + } + + /* "gevent/ares.pyx":138 + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): + * if _cares_flag_map is None: # <<<<<<<<<<<<<< + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = (__pyx_t_1 == Py_None); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "gevent/ares.pyx":139 + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): + * if _cares_flag_map is None: + * _prepare_cares_flag_map() # <<<<<<<<<<<<<< + * for socket_flag, cares_flag in _cares_flag_map: + * if socket_flag & flags: + */ + __pyx_t_1 = __pyx_f_6gevent_4ares__prepare_cares_flag_map(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":138 + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): + * if _cares_flag_map is None: # <<<<<<<<<<<<<< + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: + */ + } + + /* "gevent/ares.pyx":140 + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<< + * if socket_flag & flags: + * default |= cares_flag + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 140, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 140, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_7 = PyList_GET_ITEM(sequence, 0); + __pyx_t_8 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + #else + __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; + index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_7); + index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_8); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_t_10 = NULL; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L7_unpacking_done; + __pyx_L6_unpacking_failed:; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_10 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_L7_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_socket_flag, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_XDECREF_SET(__pyx_v_cares_flag, __pyx_t_8); + __pyx_t_8 = 0; + + /* "gevent/ares.pyx":141 + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: + * if socket_flag & flags: # <<<<<<<<<<<<<< + * default |= cares_flag + * flags &= ~socket_flag + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyNumber_And(__pyx_v_socket_flag, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (__pyx_t_3) { + + /* "gevent/ares.pyx":142 + * for socket_flag, cares_flag in _cares_flag_map: + * if socket_flag & flags: + * default |= cares_flag # <<<<<<<<<<<<<< + * flags &= ~socket_flag + * if not flags: + */ + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_1 = PyNumber_InPlaceOr(__pyx_t_8, __pyx_v_cares_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_default = __pyx_t_11; + + /* "gevent/ares.pyx":143 + * if socket_flag & flags: + * default |= cares_flag + * flags &= ~socket_flag # <<<<<<<<<<<<<< + * if not flags: + * return default + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyNumber_Invert(__pyx_v_socket_flag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = PyNumber_InPlaceAnd(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_v_flags = __pyx_t_11; + + /* "gevent/ares.pyx":141 + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: + * if socket_flag & flags: # <<<<<<<<<<<<<< + * default |= cares_flag + * flags &= ~socket_flag + */ + } + + /* "gevent/ares.pyx":144 + * default |= cares_flag + * flags &= ~socket_flag + * if not flags: # <<<<<<<<<<<<<< + * return default + * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) + */ + __pyx_t_3 = ((!(__pyx_v_flags != 0)) != 0); + if (__pyx_t_3) { + + /* "gevent/ares.pyx":145 + * flags &= ~socket_flag + * if not flags: + * return default # <<<<<<<<<<<<<< + * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":144 + * default |= cares_flag + * flags &= ~socket_flag + * if not flags: # <<<<<<<<<<<<<< + * return default + * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) + */ + } + + /* "gevent/ares.pyx":140 + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<< + * if socket_flag & flags: + * default |= cares_flag + */ + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "gevent/ares.pyx":146 + * if not flags: + * return default + * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + __pyx_t_11 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_11 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_8) { + __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; + } + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 146, __pyx_L1_error) + + /* "gevent/ares.pyx":137 + * + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_socket_flag); + __Pyx_XDECREF(__pyx_v_cares_flag); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_flags; + int __pyx_v_default; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_convert_cares_flags (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags,&__pyx_n_s_default,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_convert_cares_flags") < 0)) __PYX_ERR(0, 137, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_flags = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L3_error) + if (values[1]) { + __pyx_v_default = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_default == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L3_error) + } else { + __pyx_v_default = __pyx_k_; + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_convert_cares_flags", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 137, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares__convert_cares_flags(__pyx_self, __pyx_v_flags, __pyx_v_default); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_6gevent_4ares__convert_cares_flags __pyx_t_2; + __Pyx_RefNannySetupContext("_convert_cares_flags", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.__pyx_default = __pyx_v_default; + __pyx_t_1 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":149 + * + * + * cpdef strerror(code): # <<<<<<<<<<<<<< + * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) + * + */ + +static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/ +static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *__pyx_v_code, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + __Pyx_RefNannySetupContext("strerror", 0); + + /* "gevent/ares.pyx":150 + * + * cpdef strerror(code): + * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_errors); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_code); + __Pyx_GIVEREF(__pyx_v_code); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_code); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 150, __pyx_L1_error) + if (!__pyx_t_6) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = __pyx_t_2; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L3_bool_binop_done; + } + __Pyx_INCREF(__pyx_v_code); + __pyx_t_1 = __pyx_v_code; + __pyx_L3_bool_binop_done:; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_code); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromString(ares_strerror(__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":149 + * + * + * cpdef strerror(code): # <<<<<<<<<<<<<< + * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("strerror (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_2strerror(__pyx_self, ((PyObject *)__pyx_v_code)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("strerror", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_4ares_strerror(__pyx_v_code, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":157 + * + * + * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<< + * if not data: + * return + */ + +static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *__pyx_v_data, int __pyx_v_s, int __pyx_v_read, int __pyx_v_write) { + struct PyGeventAresChannelObject *__pyx_v_ch = 0; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("gevent_sock_state_callback", 0); + + /* "gevent/ares.pyx":158 + * + * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): + * if not data: # <<<<<<<<<<<<<< + * return + * cdef channel ch = <channel>data + */ + __pyx_t_1 = ((!(__pyx_v_data != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":159 + * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): + * if not data: + * return # <<<<<<<<<<<<<< + * cdef channel ch = <channel>data + * ch._sock_state_callback(s, read, write) + */ + goto __pyx_L0; + + /* "gevent/ares.pyx":158 + * + * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): + * if not data: # <<<<<<<<<<<<<< + * return + * cdef channel ch = <channel>data + */ + } + + /* "gevent/ares.pyx":160 + * if not data: + * return + * cdef channel ch = <channel>data # <<<<<<<<<<<<<< + * ch._sock_state_callback(s, read, write) + * + */ + __pyx_t_2 = ((PyObject *)__pyx_v_data); + __Pyx_INCREF(__pyx_t_2); + __pyx_v_ch = ((struct PyGeventAresChannelObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":161 + * return + * cdef channel ch = <channel>data + * ch._sock_state_callback(s, read, write) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_ch->__pyx_vtab)->_sock_state_callback(__pyx_v_ch, __pyx_v_s, __pyx_v_read, __pyx_v_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":157 + * + * + * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<< + * if not data: + * return + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("gevent.ares.gevent_sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_ch); + __Pyx_RefNannyFinishContext(); +} + +/* "gevent/ares.pyx":168 + * cdef public object exception + * + * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<< + * self.value = value + * self.exception = exception + */ + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_exception = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_exception,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_None); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_exception); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 168, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_value = values[0]; + __pyx_v_exception = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.result.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_6result___init__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), __pyx_v_value, __pyx_v_exception); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "gevent/ares.pyx":169 + * + * def __init__(self, object value=None, object exception=None): + * self.value = value # <<<<<<<<<<<<<< + * self.exception = exception + * + */ + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->value); + __Pyx_DECREF(__pyx_v_self->value); + __pyx_v_self->value = __pyx_v_value; + + /* "gevent/ares.pyx":170 + * def __init__(self, object value=None, object exception=None): + * self.value = value + * self.exception = exception # <<<<<<<<<<<<<< + * + * def __repr__(self): + */ + __Pyx_INCREF(__pyx_v_exception); + __Pyx_GIVEREF(__pyx_v_exception); + __Pyx_GOTREF(__pyx_v_self->exception); + __Pyx_DECREF(__pyx_v_self->exception); + __pyx_v_self->exception = __pyx_v_exception; + + /* "gevent/ares.pyx":168 + * cdef public object exception + * + * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<< + * self.value = value + * self.exception = exception + */ + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":172 + * self.exception = exception + * + * def __repr__(self): # <<<<<<<<<<<<<< + * if self.exception is None: + * return '%s(%r)' % (self.__class__.__name__, self.value) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_2__repr__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "gevent/ares.pyx":173 + * + * def __repr__(self): + * if self.exception is None: # <<<<<<<<<<<<<< + * return '%s(%r)' % (self.__class__.__name__, self.value) + * elif self.value is None: + */ + __pyx_t_1 = (__pyx_v_self->exception == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":174 + * def __repr__(self): + * if self.exception is None: + * return '%s(%r)' % (self.__class__.__name__, self.value) # <<<<<<<<<<<<<< + * elif self.value is None: + * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __Pyx_INCREF(__pyx_v_self->value); + __Pyx_GIVEREF(__pyx_v_self->value); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":173 + * + * def __repr__(self): + * if self.exception is None: # <<<<<<<<<<<<<< + * return '%s(%r)' % (self.__class__.__name__, self.value) + * elif self.value is None: + */ + } + + /* "gevent/ares.pyx":175 + * if self.exception is None: + * return '%s(%r)' % (self.__class__.__name__, self.value) + * elif self.value is None: # <<<<<<<<<<<<<< + * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) + * else: + */ + __pyx_t_2 = (__pyx_v_self->value == Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":176 + * return '%s(%r)' % (self.__class__.__name__, self.value) + * elif self.value is None: + * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) # <<<<<<<<<<<<<< + * else: + * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_v_self->exception); + __Pyx_GIVEREF(__pyx_v_self->exception); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->exception); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_exception_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":175 + * if self.exception is None: + * return '%s(%r)' % (self.__class__.__name__, self.value) + * elif self.value is None: # <<<<<<<<<<<<<< + * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) + * else: + */ + } + + /* "gevent/ares.pyx":178 + * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) + * else: + * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) # <<<<<<<<<<<<<< + * # add repr_recursive precaution + * + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __Pyx_INCREF(__pyx_v_self->value); + __Pyx_GIVEREF(__pyx_v_self->value); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value); + __Pyx_INCREF(__pyx_v_self->exception); + __Pyx_GIVEREF(__pyx_v_self->exception); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->exception); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_value_r_exception_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + } + + /* "gevent/ares.pyx":172 + * self.exception = exception + * + * def __repr__(self): # <<<<<<<<<<<<<< + * if self.exception is None: + * return '%s(%r)' % (self.__class__.__name__, self.value) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.ares.result.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":181 + * # add repr_recursive precaution + * + * def successful(self): # <<<<<<<<<<<<<< + * return self.exception is None + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("successful (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_4successful(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("successful", 0); + + /* "gevent/ares.pyx":182 + * + * def successful(self): + * return self.exception is None # <<<<<<<<<<<<<< + * + * def get(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = (__pyx_v_self->exception == Py_None); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":181 + * # add repr_recursive precaution + * + * def successful(self): # <<<<<<<<<<<<<< + * return self.exception is None + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.ares.result.successful", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":184 + * return self.exception is None + * + * def get(self): # <<<<<<<<<<<<<< + * if self.exception is not None: + * raise self.exception + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_6get(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("get", 0); + + /* "gevent/ares.pyx":185 + * + * def get(self): + * if self.exception is not None: # <<<<<<<<<<<<<< + * raise self.exception + * return self.value + */ + __pyx_t_1 = (__pyx_v_self->exception != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":186 + * def get(self): + * if self.exception is not None: + * raise self.exception # <<<<<<<<<<<<<< + * return self.value + * + */ + __Pyx_Raise(__pyx_v_self->exception, 0, 0, 0); + __PYX_ERR(0, 186, __pyx_L1_error) + + /* "gevent/ares.pyx":185 + * + * def get(self): + * if self.exception is not None: # <<<<<<<<<<<<<< + * raise self.exception + * return self.value + */ + } + + /* "gevent/ares.pyx":187 + * if self.exception is not None: + * raise self.exception + * return self.value # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->value); + __pyx_r = __pyx_v_self->value; + goto __pyx_L0; + + /* "gevent/ares.pyx":184 + * return self.exception is None + * + * def get(self): # <<<<<<<<<<<<<< + * if self.exception is not None: + * raise self.exception + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.ares.result.get", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":165 + * + * cdef class result: + * cdef public object value # <<<<<<<<<<<<<< + * cdef public object exception + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_5value___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->value); + __pyx_r = __pyx_v_self->value; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->value); + __Pyx_DECREF(__pyx_v_self->value); + __pyx_v_self->value = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->value); + __Pyx_DECREF(__pyx_v_self->value); + __pyx_v_self->value = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":166 + * cdef class result: + * cdef public object value + * cdef public object exception # <<<<<<<<<<<<<< + * + * def __init__(self, object value=None, object exception=None): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->exception); + __pyx_r = __pyx_v_self->exception; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->exception); + __Pyx_DECREF(__pyx_v_self->exception); + __pyx_v_self->exception = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->exception); + __Pyx_DECREF(__pyx_v_self->exception); + __pyx_v_self->exception = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":192 + * class ares_host_result(tuple): + * + * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_1__new__ = {"__new__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_1__new__, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_cls = 0; + PyObject *__pyx_v_family = 0; + PyObject *__pyx_v_iterable = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__new__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_family,&__pyx_n_s_iterable,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 1); __PYX_ERR(0, 192, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_iterable)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 2); __PYX_ERR(0, 192, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 192, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_cls = values[0]; + __pyx_v_family = values[1]; + __pyx_v_iterable = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 192, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result___new__(__pyx_self, __pyx_v_cls, __pyx_v_family, __pyx_v_iterable); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable) { + PyObject *__pyx_v_self = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__new__", 0); + + /* "gevent/ares.pyx":193 + * + * def __new__(cls, family, iterable): + * cdef object self = tuple.__new__(cls, iterable) # <<<<<<<<<<<<<< + * self.family = family + * return self + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + __pyx_t_4 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_4 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_cls); + __Pyx_INCREF(__pyx_v_iterable); + __Pyx_GIVEREF(__pyx_v_iterable); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_iterable); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_self = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":194 + * def __new__(cls, family, iterable): + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family # <<<<<<<<<<<<<< + * return self + * + */ + if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_family, __pyx_v_family) < 0) __PYX_ERR(0, 194, __pyx_L1_error) + + /* "gevent/ares.pyx":195 + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family + * return self # <<<<<<<<<<<<<< + * + * def __getnewargs__(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self); + __pyx_r = __pyx_v_self; + goto __pyx_L0; + + /* "gevent/ares.pyx":192 + * class ares_host_result(tuple): + * + * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_self); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":197 + * return self + * + * def __getnewargs__(self): # <<<<<<<<<<<<<< + * return (self.family, tuple(self)) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__ = {"__getnewargs__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__, METH_O, 0}; +static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getnewargs__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(__pyx_self, ((PyObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__getnewargs__", 0); + + /* "gevent/ares.pyx":198 + * + * def __getnewargs__(self): + * return (self.family, tuple(self)) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_family); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PySequence_Tuple(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":197 + * return self + * + * def __getnewargs__(self): # <<<<<<<<<<<<<< + * return (self.family, tuple(self)) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.ares.ares_host_result.__getnewargs__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":201 + * + * + * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<< + * cdef channel channel + * cdef object callback + */ + +static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, struct hostent *__pyx_v_host) { + struct PyGeventAresChannelObject *__pyx_v_channel = 0; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_host_result = 0; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + __Pyx_RefNannySetupContext("gevent_ares_host_callback", 0); + + /* "gevent/ares.pyx":204 + * cdef channel channel + * cdef object callback + * channel, callback = <tuple>arg # <<<<<<<<<<<<<< + * Py_DECREF(<PyObjectPtr>arg) + * cdef object host_result + */ + __pyx_t_1 = ((PyObject *)__pyx_v_arg); + __Pyx_INCREF(__pyx_t_1); + if (likely(__pyx_t_1 != Py_None)) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 204, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + #else + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 204, __pyx_L1_error) + } + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2); + __pyx_t_2 = 0; + __pyx_v_callback = __pyx_t_3; + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":205 + * cdef object callback + * channel, callback = <tuple>arg + * Py_DECREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<< + * cdef object host_result + * try: + */ + Py_DECREF(((PyObject*)__pyx_v_arg)); + + /* "gevent/ares.pyx":207 + * Py_DECREF(<PyObjectPtr>arg) + * cdef object host_result + * try: # <<<<<<<<<<<<<< + * if status or not host: + * callback(result(None, gaierror(status, strerror(status)))) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + /*try:*/ { + + /* "gevent/ares.pyx":208 + * cdef object host_result + * try: + * if status or not host: # <<<<<<<<<<<<<< + * callback(result(None, gaierror(status, strerror(status)))) + * else: + */ + __pyx_t_8 = (__pyx_v_status != 0); + if (!__pyx_t_8) { + } else { + __pyx_t_7 = __pyx_t_8; + goto __pyx_L12_bool_binop_done; + } + __pyx_t_8 = ((!(__pyx_v_host != 0)) != 0); + __pyx_t_7 = __pyx_t_8; + __pyx_L12_bool_binop_done:; + if (__pyx_t_7) { + + /* "gevent/ares.pyx":209 + * try: + * if status or not host: + * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<< + * else: + * try: + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_12 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_12 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + { + __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_13); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11); + __pyx_t_9 = 0; + __pyx_t_11 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_INCREF(__pyx_v_callback); + __pyx_t_2 = __pyx_v_callback; __pyx_t_13 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_13)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_13); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_13) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":208 + * cdef object host_result + * try: + * if status or not host: # <<<<<<<<<<<<<< + * callback(result(None, gaierror(status, strerror(status)))) + * else: + */ + goto __pyx_L11; + } + + /* "gevent/ares.pyx":211 + * callback(result(None, gaierror(status, strerror(status)))) + * else: + * try: # <<<<<<<<<<<<<< + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + * except: + */ + /*else*/ { + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + /*try:*/ { + + /* "gevent/ares.pyx":212 + * else: + * try: + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) # <<<<<<<<<<<<<< + * except: + * callback(result(None, sys.exc_info()[1])) + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_host_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_host->h_addrtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_3 = parse_h_name(__pyx_v_host); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_13 = parse_h_aliases(__pyx_v_host); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_9 = parse_h_addr_list(__pyx_v_host); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9); + __pyx_t_3 = 0; + __pyx_t_13 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_12 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_12 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_13); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10); + __pyx_t_11 = 0; + __pyx_t_10 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_host_result = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":211 + * callback(result(None, gaierror(status, strerror(status)))) + * else: + * try: # <<<<<<<<<<<<<< + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + * except: + */ + } + + /* "gevent/ares.pyx":216 + * callback(result(None, sys.exc_info()[1])) + * else: + * callback(result(host_result)) # <<<<<<<<<<<<<< + * except: + * channel.loop.handle_error(callback, *sys.exc_info()) + */ + /*else:*/ { + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_host_result); + __Pyx_GIVEREF(__pyx_v_host_result); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_host_result); + __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_INCREF(__pyx_v_callback); + __pyx_t_2 = __pyx_v_callback; __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_10) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_13}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_13}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; + goto __pyx_L21_try_end; + __pyx_L14_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":213 + * try: + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + * except: # <<<<<<<<<<<<<< + * callback(result(None, sys.exc_info()[1])) + * else: + */ + /*except:*/ { + __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_11) < 0) __PYX_ERR(0, 213, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_11); + + /* "gevent/ares.pyx":214 + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + * except: + * callback(result(None, sys.exc_info()[1])) # <<<<<<<<<<<<<< + * else: + * callback(result(host_result)) + */ + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_9) { + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error) + } + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_10, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_10, 0, Py_None); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_INCREF(__pyx_v_callback); + __pyx_t_10 = __pyx_v_callback; __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (!__pyx_t_9) { + __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_13); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3}; + __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3}; + __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_17); + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_9); __pyx_t_9 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + } + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + goto __pyx_L15_exception_handled; + } + __pyx_L16_except_error:; + + /* "gevent/ares.pyx":211 + * callback(result(None, gaierror(status, strerror(status)))) + * else: + * try: # <<<<<<<<<<<<<< + * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) + * except: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); + goto __pyx_L3_error; + __pyx_L15_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); + __pyx_L21_try_end:; + } + } + __pyx_L11:; + + /* "gevent/ares.pyx":207 + * Py_DECREF(<PyObjectPtr>arg) + * cdef object host_result + * try: # <<<<<<<<<<<<<< + * if status or not host: + * callback(result(None, gaierror(status, strerror(status)))) + */ + } + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "gevent/ares.pyx":217 + * else: + * callback(result(host_result)) + * except: # <<<<<<<<<<<<<< + * channel.loop.handle_error(callback, *sys.exc_info()) + * + */ + /*except:*/ { + __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 217, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_1); + + /* "gevent/ares.pyx":218 + * callback(result(host_result)) + * except: + * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_callback); + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + } + } + if (__pyx_t_3) { + __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_17 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error) + } + __Pyx_GOTREF(__pyx_t_17); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PySequence_Tuple(__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __pyx_t_17 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_17); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L4_exception_handled; + } + __pyx_L5_except_error:; + + /* "gevent/ares.pyx":207 + * Py_DECREF(<PyObjectPtr>arg) + * cdef object host_result + * try: # <<<<<<<<<<<<<< + * if status or not host: + * callback(result(None, gaierror(status, strerror(status)))) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + __pyx_L10_try_end:; + } + + /* "gevent/ares.pyx":201 + * + * + * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<< + * cdef channel channel + * cdef object callback + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_17); + __Pyx_WriteUnraisable("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_channel); + __Pyx_XDECREF(__pyx_v_callback); + __Pyx_XDECREF(__pyx_v_host_result); + __Pyx_RefNannyFinishContext(); +} + +/* "gevent/ares.pyx":221 + * + * + * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<< + * cdef channel channel + * cdef object callback + */ + +static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, char *__pyx_v_c_node, char *__pyx_v_c_service) { + struct PyGeventAresChannelObject *__pyx_v_channel = 0; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_node = 0; + PyObject *__pyx_v_service = 0; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + __Pyx_RefNannySetupContext("gevent_ares_nameinfo_callback", 0); + + /* "gevent/ares.pyx":224 + * cdef channel channel + * cdef object callback + * channel, callback = <tuple>arg # <<<<<<<<<<<<<< + * Py_DECREF(<PyObjectPtr>arg) + * cdef object node + */ + __pyx_t_1 = ((PyObject *)__pyx_v_arg); + __Pyx_INCREF(__pyx_t_1); + if (likely(__pyx_t_1 != Py_None)) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 224, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + #else + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 224, __pyx_L1_error) + } + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2); + __pyx_t_2 = 0; + __pyx_v_callback = __pyx_t_3; + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":225 + * cdef object callback + * channel, callback = <tuple>arg + * Py_DECREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<< + * cdef object node + * cdef object service + */ + Py_DECREF(((PyObject*)__pyx_v_arg)); + + /* "gevent/ares.pyx":228 + * cdef object node + * cdef object service + * try: # <<<<<<<<<<<<<< + * if status: + * callback(result(None, gaierror(status, strerror(status)))) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + /*try:*/ { + + /* "gevent/ares.pyx":229 + * cdef object service + * try: + * if status: # <<<<<<<<<<<<<< + * callback(result(None, gaierror(status, strerror(status)))) + * else: + */ + __pyx_t_7 = (__pyx_v_status != 0); + if (__pyx_t_7) { + + /* "gevent/ares.pyx":230 + * try: + * if status: + * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<< + * else: + * if c_node: + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_11 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_11 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); + __pyx_t_8 = 0; + __pyx_t_10 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_INCREF(__pyx_v_callback); + __pyx_t_2 = __pyx_v_callback; __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_12) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL; + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":229 + * cdef object service + * try: + * if status: # <<<<<<<<<<<<<< + * callback(result(None, gaierror(status, strerror(status)))) + * else: + */ + goto __pyx_L11; + } + + /* "gevent/ares.pyx":232 + * callback(result(None, gaierror(status, strerror(status)))) + * else: + * if c_node: # <<<<<<<<<<<<<< + * node = PyUnicode_FromString(c_node) + * else: + */ + /*else*/ { + __pyx_t_7 = (__pyx_v_c_node != 0); + if (__pyx_t_7) { + + /* "gevent/ares.pyx":233 + * else: + * if c_node: + * node = PyUnicode_FromString(c_node) # <<<<<<<<<<<<<< + * else: + * node = None + */ + __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_node); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_node = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":232 + * callback(result(None, gaierror(status, strerror(status)))) + * else: + * if c_node: # <<<<<<<<<<<<<< + * node = PyUnicode_FromString(c_node) + * else: + */ + goto __pyx_L12; + } + + /* "gevent/ares.pyx":235 + * node = PyUnicode_FromString(c_node) + * else: + * node = None # <<<<<<<<<<<<<< + * if c_service: + * service = PyUnicode_FromString(c_service) + */ + /*else*/ { + __Pyx_INCREF(Py_None); + __pyx_v_node = Py_None; + } + __pyx_L12:; + + /* "gevent/ares.pyx":236 + * else: + * node = None + * if c_service: # <<<<<<<<<<<<<< + * service = PyUnicode_FromString(c_service) + * else: + */ + __pyx_t_7 = (__pyx_v_c_service != 0); + if (__pyx_t_7) { + + /* "gevent/ares.pyx":237 + * node = None + * if c_service: + * service = PyUnicode_FromString(c_service) # <<<<<<<<<<<<<< + * else: + * service = None + */ + __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_service = __pyx_t_1; + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":236 + * else: + * node = None + * if c_service: # <<<<<<<<<<<<<< + * service = PyUnicode_FromString(c_service) + * else: + */ + goto __pyx_L13; + } + + /* "gevent/ares.pyx":239 + * service = PyUnicode_FromString(c_service) + * else: + * service = None # <<<<<<<<<<<<<< + * callback(result((node, service))) + * except: + */ + /*else*/ { + __Pyx_INCREF(Py_None); + __pyx_v_service = Py_None; + } + __pyx_L13:; + + /* "gevent/ares.pyx":240 + * else: + * service = None + * callback(result((node, service))) # <<<<<<<<<<<<<< + * except: + * channel.loop.handle_error(callback, *sys.exc_info()) + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_node); + __Pyx_GIVEREF(__pyx_v_node); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_node); + __Pyx_INCREF(__pyx_v_service); + __Pyx_GIVEREF(__pyx_v_service); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_service); + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_INCREF(__pyx_v_callback); + __pyx_t_10 = __pyx_v_callback; __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (!__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L11:; + + /* "gevent/ares.pyx":228 + * cdef object node + * cdef object service + * try: # <<<<<<<<<<<<<< + * if status: + * callback(result(None, gaierror(status, strerror(status)))) + */ + } + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":241 + * service = None + * callback(result((node, service))) + * except: # <<<<<<<<<<<<<< + * channel.loop.handle_error(callback, *sys.exc_info()) + * + */ + /*except:*/ { + __Pyx_AddTraceback("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_12) < 0) __PYX_ERR(0, 241, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GOTREF(__pyx_t_12); + + /* "gevent/ares.pyx":242 + * callback(result((node, service))) + * except: + * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback); + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_13, function); + } + } + if (__pyx_t_9) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error) + } + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = PySequence_Tuple(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + goto __pyx_L4_exception_handled; + } + __pyx_L5_except_error:; + + /* "gevent/ares.pyx":228 + * cdef object node + * cdef object service + * try: # <<<<<<<<<<<<<< + * if status: + * callback(result(None, gaierror(status, strerror(status)))) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + __pyx_L10_try_end:; + } + + /* "gevent/ares.pyx":221 + * + * + * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<< + * cdef channel channel + * cdef object callback + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_WriteUnraisable("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_channel); + __Pyx_XDECREF(__pyx_v_callback); + __Pyx_XDECREF(__pyx_v_node); + __Pyx_XDECREF(__pyx_v_service); + __Pyx_RefNannyFinishContext(); +} + +/* "gevent/ares.pyx":252 + * cdef public object _timer + * + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< + * udp_port=None, tcp_port=None, servers=None): + * cdef ares_channeldata* channel = NULL + */ + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_loop = 0; + PyObject *__pyx_v_flags = 0; + PyObject *__pyx_v_timeout = 0; + PyObject *__pyx_v_tries = 0; + PyObject *__pyx_v_ndots = 0; + PyObject *__pyx_v_udp_port = 0; + PyObject *__pyx_v_tcp_port = 0; + PyObject *__pyx_v_servers = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_flags,&__pyx_n_s_timeout,&__pyx_n_s_tries,&__pyx_n_s_ndots,&__pyx_n_s_udp_port,&__pyx_n_s_tcp_port,&__pyx_n_s_servers,0}; + PyObject* values[8] = {0,0,0,0,0,0,0,0}; + values[1] = ((PyObject *)Py_None); + values[2] = ((PyObject *)Py_None); + values[3] = ((PyObject *)Py_None); + values[4] = ((PyObject *)Py_None); + + /* "gevent/ares.pyx":253 + * + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, + * udp_port=None, tcp_port=None, servers=None): # <<<<<<<<<<<<<< + * cdef ares_channeldata* channel = NULL + * cdef cares.ares_options options + */ + values[5] = ((PyObject *)Py_None); + values[6] = ((PyObject *)Py_None); + values[7] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tries); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndots); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_udp_port); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tcp_port); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers); + if (value) { values[7] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 252, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = values[0]; + __pyx_v_flags = values[1]; + __pyx_v_timeout = values[2]; + __pyx_v_tries = values[3]; + __pyx_v_ndots = values[4]; + __pyx_v_udp_port = values[5]; + __pyx_v_tcp_port = values[6]; + __pyx_v_servers = values[7]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_7channel___init__(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_flags, __pyx_v_timeout, __pyx_v_tries, __pyx_v_ndots, __pyx_v_udp_port, __pyx_v_tcp_port, __pyx_v_servers); + + /* "gevent/ares.pyx":252 + * cdef public object _timer + * + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< + * udp_port=None, tcp_port=None, servers=None): + * cdef ares_channeldata* channel = NULL + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers) { + struct ares_channeldata *__pyx_v_channel; + struct ares_options __pyx_v_options; + int __pyx_v_optmask; + int __pyx_v_result; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + double __pyx_t_5; + unsigned short __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "gevent/ares.pyx":254 + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, + * udp_port=None, tcp_port=None, servers=None): + * cdef ares_channeldata* channel = NULL # <<<<<<<<<<<<<< + * cdef cares.ares_options options + * memset(&options, 0, sizeof(cares.ares_options)) + */ + __pyx_v_channel = NULL; + + /* "gevent/ares.pyx":256 + * cdef ares_channeldata* channel = NULL + * cdef cares.ares_options options + * memset(&options, 0, sizeof(cares.ares_options)) # <<<<<<<<<<<<<< + * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB + * options.sock_state_cb = <void*>gevent_sock_state_callback + */ + memset((&__pyx_v_options), 0, (sizeof(struct ares_options))); + + /* "gevent/ares.pyx":257 + * cdef cares.ares_options options + * memset(&options, 0, sizeof(cares.ares_options)) + * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB # <<<<<<<<<<<<<< + * options.sock_state_cb = <void*>gevent_sock_state_callback + * options.sock_state_cb_data = <void*>self + */ + __pyx_v_optmask = ARES_OPT_SOCK_STATE_CB; + + /* "gevent/ares.pyx":258 + * memset(&options, 0, sizeof(cares.ares_options)) + * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB + * options.sock_state_cb = <void*>gevent_sock_state_callback # <<<<<<<<<<<<<< + * options.sock_state_cb_data = <void*>self + * if flags is not None: + */ + __pyx_v_options.sock_state_cb = ((void *)__pyx_f_6gevent_4ares_gevent_sock_state_callback); + + /* "gevent/ares.pyx":259 + * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB + * options.sock_state_cb = <void*>gevent_sock_state_callback + * options.sock_state_cb_data = <void*>self # <<<<<<<<<<<<<< + * if flags is not None: + * options.flags = int(flags) + */ + __pyx_v_options.sock_state_cb_data = ((void *)__pyx_v_self); + + /* "gevent/ares.pyx":260 + * options.sock_state_cb = <void*>gevent_sock_state_callback + * options.sock_state_cb_data = <void*>self + * if flags is not None: # <<<<<<<<<<<<<< + * options.flags = int(flags) + * optmask |= cares.ARES_OPT_FLAGS + */ + __pyx_t_1 = (__pyx_v_flags != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":261 + * options.sock_state_cb_data = <void*>self + * if flags is not None: + * options.flags = int(flags) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_FLAGS + * if timeout is not None: + */ + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_options.flags = __pyx_t_4; + + /* "gevent/ares.pyx":262 + * if flags is not None: + * options.flags = int(flags) + * optmask |= cares.ARES_OPT_FLAGS # <<<<<<<<<<<<<< + * if timeout is not None: + * options.timeout = int(float(timeout) * 1000) + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_FLAGS); + + /* "gevent/ares.pyx":260 + * options.sock_state_cb = <void*>gevent_sock_state_callback + * options.sock_state_cb_data = <void*>self + * if flags is not None: # <<<<<<<<<<<<<< + * options.flags = int(flags) + * optmask |= cares.ARES_OPT_FLAGS + */ + } + + /* "gevent/ares.pyx":263 + * options.flags = int(flags) + * optmask |= cares.ARES_OPT_FLAGS + * if timeout is not None: # <<<<<<<<<<<<<< + * options.timeout = int(float(timeout) * 1000) + * optmask |= cares.ARES_OPT_TIMEOUTMS + */ + __pyx_t_2 = (__pyx_v_timeout != Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":264 + * optmask |= cares.ARES_OPT_FLAGS + * if timeout is not None: + * options.timeout = int(float(timeout) * 1000) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_TIMEOUTMS + * if tries is not None: + */ + __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_timeout); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_v_options.timeout = ((int)(__pyx_t_5 * 1000.0)); + + /* "gevent/ares.pyx":265 + * if timeout is not None: + * options.timeout = int(float(timeout) * 1000) + * optmask |= cares.ARES_OPT_TIMEOUTMS # <<<<<<<<<<<<<< + * if tries is not None: + * options.tries = int(tries) + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TIMEOUTMS); + + /* "gevent/ares.pyx":263 + * options.flags = int(flags) + * optmask |= cares.ARES_OPT_FLAGS + * if timeout is not None: # <<<<<<<<<<<<<< + * options.timeout = int(float(timeout) * 1000) + * optmask |= cares.ARES_OPT_TIMEOUTMS + */ + } + + /* "gevent/ares.pyx":266 + * options.timeout = int(float(timeout) * 1000) + * optmask |= cares.ARES_OPT_TIMEOUTMS + * if tries is not None: # <<<<<<<<<<<<<< + * options.tries = int(tries) + * optmask |= cares.ARES_OPT_TRIES + */ + __pyx_t_1 = (__pyx_v_tries != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":267 + * optmask |= cares.ARES_OPT_TIMEOUTMS + * if tries is not None: + * options.tries = int(tries) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_TRIES + * if ndots is not None: + */ + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tries); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_options.tries = __pyx_t_4; + + /* "gevent/ares.pyx":268 + * if tries is not None: + * options.tries = int(tries) + * optmask |= cares.ARES_OPT_TRIES # <<<<<<<<<<<<<< + * if ndots is not None: + * options.ndots = int(ndots) + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TRIES); + + /* "gevent/ares.pyx":266 + * options.timeout = int(float(timeout) * 1000) + * optmask |= cares.ARES_OPT_TIMEOUTMS + * if tries is not None: # <<<<<<<<<<<<<< + * options.tries = int(tries) + * optmask |= cares.ARES_OPT_TRIES + */ + } + + /* "gevent/ares.pyx":269 + * options.tries = int(tries) + * optmask |= cares.ARES_OPT_TRIES + * if ndots is not None: # <<<<<<<<<<<<<< + * options.ndots = int(ndots) + * optmask |= cares.ARES_OPT_NDOTS + */ + __pyx_t_2 = (__pyx_v_ndots != Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":270 + * optmask |= cares.ARES_OPT_TRIES + * if ndots is not None: + * options.ndots = int(ndots) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_NDOTS + * if udp_port is not None: + */ + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_ndots); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_options.ndots = __pyx_t_4; + + /* "gevent/ares.pyx":271 + * if ndots is not None: + * options.ndots = int(ndots) + * optmask |= cares.ARES_OPT_NDOTS # <<<<<<<<<<<<<< + * if udp_port is not None: + * options.udp_port = int(udp_port) + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_NDOTS); + + /* "gevent/ares.pyx":269 + * options.tries = int(tries) + * optmask |= cares.ARES_OPT_TRIES + * if ndots is not None: # <<<<<<<<<<<<<< + * options.ndots = int(ndots) + * optmask |= cares.ARES_OPT_NDOTS + */ + } + + /* "gevent/ares.pyx":272 + * options.ndots = int(ndots) + * optmask |= cares.ARES_OPT_NDOTS + * if udp_port is not None: # <<<<<<<<<<<<<< + * options.udp_port = int(udp_port) + * optmask |= cares.ARES_OPT_UDP_PORT + */ + __pyx_t_1 = (__pyx_v_udp_port != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":273 + * optmask |= cares.ARES_OPT_NDOTS + * if udp_port is not None: + * options.udp_port = int(udp_port) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_UDP_PORT + * if tcp_port is not None: + */ + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_udp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_options.udp_port = __pyx_t_6; + + /* "gevent/ares.pyx":274 + * if udp_port is not None: + * options.udp_port = int(udp_port) + * optmask |= cares.ARES_OPT_UDP_PORT # <<<<<<<<<<<<<< + * if tcp_port is not None: + * options.tcp_port = int(tcp_port) + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_UDP_PORT); + + /* "gevent/ares.pyx":272 + * options.ndots = int(ndots) + * optmask |= cares.ARES_OPT_NDOTS + * if udp_port is not None: # <<<<<<<<<<<<<< + * options.udp_port = int(udp_port) + * optmask |= cares.ARES_OPT_UDP_PORT + */ + } + + /* "gevent/ares.pyx":275 + * options.udp_port = int(udp_port) + * optmask |= cares.ARES_OPT_UDP_PORT + * if tcp_port is not None: # <<<<<<<<<<<<<< + * options.tcp_port = int(tcp_port) + * optmask |= cares.ARES_OPT_TCP_PORT + */ + __pyx_t_2 = (__pyx_v_tcp_port != Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":276 + * optmask |= cares.ARES_OPT_UDP_PORT + * if tcp_port is not None: + * options.tcp_port = int(tcp_port) # <<<<<<<<<<<<<< + * optmask |= cares.ARES_OPT_TCP_PORT + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + */ + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tcp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_options.tcp_port = __pyx_t_6; + + /* "gevent/ares.pyx":277 + * if tcp_port is not None: + * options.tcp_port = int(tcp_port) + * optmask |= cares.ARES_OPT_TCP_PORT # <<<<<<<<<<<<<< + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + * if result: + */ + __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TCP_PORT); + + /* "gevent/ares.pyx":275 + * options.udp_port = int(udp_port) + * optmask |= cares.ARES_OPT_UDP_PORT + * if tcp_port is not None: # <<<<<<<<<<<<<< + * options.tcp_port = int(tcp_port) + * optmask |= cares.ARES_OPT_TCP_PORT + */ + } + + /* "gevent/ares.pyx":278 + * options.tcp_port = int(tcp_port) + * optmask |= cares.ARES_OPT_TCP_PORT + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? # <<<<<<<<<<<<<< + * if result: + * raise gaierror(result, strerror(result)) + */ + __pyx_v_result = ares_library_init(ARES_LIB_INIT_ALL); + + /* "gevent/ares.pyx":279 + * optmask |= cares.ARES_OPT_TCP_PORT + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + * if result: # <<<<<<<<<<<<<< + * raise gaierror(result, strerror(result)) + * result = cares.ares_init_options(&channel, &options, optmask) + */ + __pyx_t_1 = (__pyx_v_result != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":280 + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + * if result: + * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<< + * result = cares.ares_init_options(&channel, &options, optmask) + * if result: + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_4 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_4 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_10); + __pyx_t_8 = 0; + __pyx_t_10 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 280, __pyx_L1_error) + + /* "gevent/ares.pyx":279 + * optmask |= cares.ARES_OPT_TCP_PORT + * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? + * if result: # <<<<<<<<<<<<<< + * raise gaierror(result, strerror(result)) + * result = cares.ares_init_options(&channel, &options, optmask) + */ + } + + /* "gevent/ares.pyx":281 + * if result: + * raise gaierror(result, strerror(result)) + * result = cares.ares_init_options(&channel, &options, optmask) # <<<<<<<<<<<<<< + * if result: + * raise gaierror(result, strerror(result)) + */ + __pyx_v_result = ares_init_options((&__pyx_v_channel), (&__pyx_v_options), __pyx_v_optmask); + + /* "gevent/ares.pyx":282 + * raise gaierror(result, strerror(result)) + * result = cares.ares_init_options(&channel, &options, optmask) + * if result: # <<<<<<<<<<<<<< + * raise gaierror(result, strerror(result)) + * self._timer = loop.timer(TIMEOUT, TIMEOUT) + */ + __pyx_t_1 = (__pyx_v_result != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":283 + * result = cares.ares_init_options(&channel, &options, optmask) + * if result: + * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<< + * self._timer = loop.timer(TIMEOUT, TIMEOUT) + * self._watchers = {} + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_8 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_4 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_4 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_4, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_4, __pyx_t_8); + __pyx_t_11 = 0; + __pyx_t_8 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 283, __pyx_L1_error) + + /* "gevent/ares.pyx":282 + * raise gaierror(result, strerror(result)) + * result = cares.ares_init_options(&channel, &options, optmask) + * if result: # <<<<<<<<<<<<<< + * raise gaierror(result, strerror(result)) + * self._timer = loop.timer(TIMEOUT, TIMEOUT) + */ + } + + /* "gevent/ares.pyx":284 + * if result: + * raise gaierror(result, strerror(result)) + * self._timer = loop.timer(TIMEOUT, TIMEOUT) # <<<<<<<<<<<<<< + * self._watchers = {} + * self.channel = channel + */ + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_timer); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_11 = NULL; + __pyx_t_4 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_4 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_11) { + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, __pyx_t_8); + __pyx_t_9 = 0; + __pyx_t_8 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->_timer); + __Pyx_DECREF(__pyx_v_self->_timer); + __pyx_v_self->_timer = __pyx_t_3; + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":285 + * raise gaierror(result, strerror(result)) + * self._timer = loop.timer(TIMEOUT, TIMEOUT) + * self._watchers = {} # <<<<<<<<<<<<<< + * self.channel = channel + * try: + */ + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->_watchers); + __Pyx_DECREF(__pyx_v_self->_watchers); + __pyx_v_self->_watchers = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":286 + * self._timer = loop.timer(TIMEOUT, TIMEOUT) + * self._watchers = {} + * self.channel = channel # <<<<<<<<<<<<<< + * try: + * if servers is not None: + */ + __pyx_v_self->channel = __pyx_v_channel; + + /* "gevent/ares.pyx":287 + * self._watchers = {} + * self.channel = channel + * try: # <<<<<<<<<<<<<< + * if servers is not None: + * self.set_servers(servers) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + /*try:*/ { + + /* "gevent/ares.pyx":288 + * self.channel = channel + * try: + * if servers is not None: # <<<<<<<<<<<<<< + * self.set_servers(servers) + * self.loop = loop + */ + __pyx_t_1 = (__pyx_v_servers != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "gevent/ares.pyx":289 + * try: + * if servers is not None: + * self.set_servers(servers) # <<<<<<<<<<<<<< + * self.loop = loop + * except: + */ + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_servers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_10) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_servers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_servers}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_servers}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + { + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL; + __Pyx_INCREF(__pyx_v_servers); + __Pyx_GIVEREF(__pyx_v_servers); + PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_servers); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":288 + * self.channel = channel + * try: + * if servers is not None: # <<<<<<<<<<<<<< + * self.set_servers(servers) + * self.loop = loop + */ + } + + /* "gevent/ares.pyx":290 + * if servers is not None: + * self.set_servers(servers) + * self.loop = loop # <<<<<<<<<<<<<< + * except: + * self.destroy() + */ + __Pyx_INCREF(__pyx_v_loop); + __Pyx_GIVEREF(__pyx_v_loop); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(__pyx_v_self->loop); + __pyx_v_self->loop = __pyx_v_loop; + + /* "gevent/ares.pyx":287 + * self._watchers = {} + * self.channel = channel + * try: # <<<<<<<<<<<<<< + * if servers is not None: + * self.set_servers(servers) + */ + } + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; + goto __pyx_L18_try_end; + __pyx_L11_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":291 + * self.set_servers(servers) + * self.loop = loop + * except: # <<<<<<<<<<<<<< + * self.destroy() + * raise + */ + /*except:*/ { + __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 291, __pyx_L13_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_8); + + /* "gevent/ares.pyx":292 + * self.loop = loop + * except: + * self.destroy() # <<<<<<<<<<<<<< + * raise + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 292, __pyx_L13_except_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_11 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + } + } + if (__pyx_t_11) { + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 292, __pyx_L13_except_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else { + __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 292, __pyx_L13_except_error) + } + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "gevent/ares.pyx":293 + * except: + * self.destroy() + * raise # <<<<<<<<<<<<<< + * + * def __repr__(self): + */ + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_7, __pyx_t_8); + __pyx_t_3 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; + __PYX_ERR(0, 293, __pyx_L13_except_error) + } + __pyx_L13_except_error:; + + /* "gevent/ares.pyx":287 + * self._watchers = {} + * self.channel = channel + * try: # <<<<<<<<<<<<<< + * if servers is not None: + * self.set_servers(servers) + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); + goto __pyx_L1_error; + __pyx_L18_try_end:; + } + + /* "gevent/ares.pyx":252 + * cdef public object _timer + * + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<< + * udp_port=None, tcp_port=None, servers=None): + * cdef ares_channeldata* channel = NULL + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":295 + * raise + * + * def __repr__(self): # <<<<<<<<<<<<<< + * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_2__repr__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_v_args = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "gevent/ares.pyx":296 + * + * def __repr__(self): + * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) # <<<<<<<<<<<<<< + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __pyx_v_self->_watchers; + __Pyx_INCREF(__pyx_t_1); + if (unlikely(__pyx_t_1 == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(0, 296, __pyx_L1_error) + } + __pyx_t_4 = PyDict_Size(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); + __Pyx_INCREF(__pyx_v_self->_timer); + __Pyx_GIVEREF(__pyx_v_self->_timer); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->_timer); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_1 = 0; + __pyx_v_args = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + /* "gevent/ares.pyx":297 + * def __repr__(self): + * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args # <<<<<<<<<<<<<< + * + * def destroy(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 297, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":295 + * raise + * + * def __repr__(self): # <<<<<<<<<<<<<< + * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.ares.channel.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_args); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":299 + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + * + * def destroy(self): # <<<<<<<<<<<<<< + * if self.channel: + * # XXX ares_library_cleanup? + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("destroy (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_4destroy(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("destroy", 0); + + /* "gevent/ares.pyx":300 + * + * def destroy(self): + * if self.channel: # <<<<<<<<<<<<<< + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + */ + __pyx_t_1 = (__pyx_v_self->channel != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":302 + * if self.channel: + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<< + * self.channel = NULL + * self._watchers.clear() + */ + ares_destroy(__pyx_v_self->channel); + + /* "gevent/ares.pyx":303 + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + * self.channel = NULL # <<<<<<<<<<<<<< + * self._watchers.clear() + * self._timer.stop() + */ + __pyx_v_self->channel = NULL; + + /* "gevent/ares.pyx":304 + * cares.ares_destroy(self.channel) + * self.channel = NULL + * self._watchers.clear() # <<<<<<<<<<<<<< + * self._timer.stop() + * self.loop = None + */ + if (unlikely(__pyx_v_self->_watchers == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "clear"); + __PYX_ERR(0, 304, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyDict_Clear(__pyx_v_self->_watchers); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 304, __pyx_L1_error) + + /* "gevent/ares.pyx":305 + * self.channel = NULL + * self._watchers.clear() + * self._timer.stop() # <<<<<<<<<<<<<< + * self.loop = None + * + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":306 + * self._watchers.clear() + * self._timer.stop() + * self.loop = None # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(__pyx_v_self->loop); + __pyx_v_self->loop = Py_None; + + /* "gevent/ares.pyx":300 + * + * def destroy(self): + * if self.channel: # <<<<<<<<<<<<<< + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + */ + } + + /* "gevent/ares.pyx":299 + * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args + * + * def destroy(self): # <<<<<<<<<<<<<< + * if self.channel: + * # XXX ares_library_cleanup? + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.ares.channel.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":308 + * self.loop = None + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.channel: + * # XXX ares_library_cleanup? + */ + +/* Python wrapper */ +static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_6gevent_4ares_7channel_6__dealloc__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "gevent/ares.pyx":309 + * + * def __dealloc__(self): + * if self.channel: # <<<<<<<<<<<<<< + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + */ + __pyx_t_1 = (__pyx_v_self->channel != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":311 + * if self.channel: + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<< + * self.channel = NULL + * + */ + ares_destroy(__pyx_v_self->channel); + + /* "gevent/ares.pyx":312 + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + * self.channel = NULL # <<<<<<<<<<<<<< + * + * def set_servers(self, servers=None): + */ + __pyx_v_self->channel = NULL; + + /* "gevent/ares.pyx":309 + * + * def __dealloc__(self): + * if self.channel: # <<<<<<<<<<<<<< + * # XXX ares_library_cleanup? + * cares.ares_destroy(self.channel) + */ + } + + /* "gevent/ares.pyx":308 + * self.loop = None + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.channel: + * # XXX ares_library_cleanup? + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "gevent/ares.pyx":314 + * self.channel = NULL + * + * def set_servers(self, servers=None): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_servers = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_servers (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_servers,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 = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_servers") < 0)) __PYX_ERR(0, 314, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_servers = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("set_servers", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 314, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_7channel_8set_servers(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_servers); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers) { + int __pyx_v_length; + CYTHON_UNUSED int __pyx_v_result; + int __pyx_v_index; + char *__pyx_v_string; + struct ares_addr_node *__pyx_v_c_servers; + PyObject *__pyx_v_server = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + Py_ssize_t __pyx_t_9; + PyObject *(*__pyx_t_10)(PyObject *); + char *__pyx_t_11; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + char const *__pyx_t_14; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + PyObject *__pyx_t_19 = NULL; + PyObject *__pyx_t_20 = NULL; + __Pyx_RefNannySetupContext("set_servers", 0); + __Pyx_INCREF(__pyx_v_servers); + + /* "gevent/ares.pyx":315 + * + * def set_servers(self, servers=None): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * if not servers: + */ + __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":316 + * def set_servers(self, servers=None): + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< + * if not servers: + * servers = [] + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); + __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 316, __pyx_L1_error) + + /* "gevent/ares.pyx":315 + * + * def set_servers(self, servers=None): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * if not servers: + */ + } + + /* "gevent/ares.pyx":317 + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * if not servers: # <<<<<<<<<<<<<< + * servers = [] + * if isinstance(servers, string_types): + */ + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_servers); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_t_8 = ((!__pyx_t_1) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":318 + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * if not servers: + * servers = [] # <<<<<<<<<<<<<< + * if isinstance(servers, string_types): + * servers = servers.split(',') + */ + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_2); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":317 + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * if not servers: # <<<<<<<<<<<<<< + * servers = [] + * if isinstance(servers, string_types): + */ + } + + /* "gevent/ares.pyx":319 + * if not servers: + * servers = [] + * if isinstance(servers, string_types): # <<<<<<<<<<<<<< + * servers = servers.split(',') + * cdef int length = len(servers) + */ + __pyx_t_2 = __pyx_v_6gevent_4ares_string_types; + __Pyx_INCREF(__pyx_t_2); + __pyx_t_8 = PyObject_IsInstance(__pyx_v_servers, __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = (__pyx_t_8 != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":320 + * servers = [] + * if isinstance(servers, string_types): + * servers = servers.split(',') # <<<<<<<<<<<<<< + * cdef int length = len(servers) + * cdef int result, index + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_servers, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_3); + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":319 + * if not servers: + * servers = [] + * if isinstance(servers, string_types): # <<<<<<<<<<<<<< + * servers = servers.split(',') + * cdef int length = len(servers) + */ + } + + /* "gevent/ares.pyx":321 + * if isinstance(servers, string_types): + * servers = servers.split(',') + * cdef int length = len(servers) # <<<<<<<<<<<<<< + * cdef int result, index + * cdef char* string + */ + __pyx_t_9 = PyObject_Length(__pyx_v_servers); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 321, __pyx_L1_error) + __pyx_v_length = __pyx_t_9; + + /* "gevent/ares.pyx":325 + * cdef char* string + * cdef cares.ares_addr_node* c_servers + * if length <= 0: # <<<<<<<<<<<<<< + * result = cares.ares_set_servers(self.channel, NULL) + * else: + */ + __pyx_t_1 = ((__pyx_v_length <= 0) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":326 + * cdef cares.ares_addr_node* c_servers + * if length <= 0: + * result = cares.ares_set_servers(self.channel, NULL) # <<<<<<<<<<<<<< + * else: + * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) + */ + __pyx_v_result = ares_set_servers(__pyx_v_self->channel, NULL); + + /* "gevent/ares.pyx":325 + * cdef char* string + * cdef cares.ares_addr_node* c_servers + * if length <= 0: # <<<<<<<<<<<<<< + * result = cares.ares_set_servers(self.channel, NULL) + * else: + */ + goto __pyx_L6; + } + + /* "gevent/ares.pyx":328 + * result = cares.ares_set_servers(self.channel, NULL) + * else: + * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) # <<<<<<<<<<<<<< + * if not c_servers: + * raise MemoryError + */ + /*else*/ { + __pyx_v_c_servers = ((struct ares_addr_node *)malloc(((sizeof(struct ares_addr_node)) * __pyx_v_length))); + + /* "gevent/ares.pyx":329 + * else: + * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) + * if not c_servers: # <<<<<<<<<<<<<< + * raise MemoryError + * try: + */ + __pyx_t_1 = ((!(__pyx_v_c_servers != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":330 + * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) + * if not c_servers: + * raise MemoryError # <<<<<<<<<<<<<< + * try: + * index = 0 + */ + PyErr_NoMemory(); __PYX_ERR(0, 330, __pyx_L1_error) + + /* "gevent/ares.pyx":329 + * else: + * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) + * if not c_servers: # <<<<<<<<<<<<<< + * raise MemoryError + * try: + */ + } + + /* "gevent/ares.pyx":331 + * if not c_servers: + * raise MemoryError + * try: # <<<<<<<<<<<<<< + * index = 0 + * for server in servers: + */ + /*try:*/ { + + /* "gevent/ares.pyx":332 + * raise MemoryError + * try: + * index = 0 # <<<<<<<<<<<<<< + * for server in servers: + * if isinstance(server, unicode): + */ + __pyx_v_index = 0; + + /* "gevent/ares.pyx":333 + * try: + * index = 0 + * for server in servers: # <<<<<<<<<<<<<< + * if isinstance(server, unicode): + * server = server.encode('ascii') + */ + if (likely(PyList_CheckExact(__pyx_v_servers)) || PyTuple_CheckExact(__pyx_v_servers)) { + __pyx_t_3 = __pyx_v_servers; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0; + __pyx_t_10 = NULL; + } else { + __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_servers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 333, __pyx_L9_error) + } + for (;;) { + if (likely(!__pyx_t_10)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 333, __pyx_L9_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } else { + if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 333, __pyx_L9_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } + } else { + __pyx_t_2 = __pyx_t_10(__pyx_t_3); + if (unlikely(!__pyx_t_2)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 333, __pyx_L9_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF_SET(__pyx_v_server, __pyx_t_2); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":334 + * index = 0 + * for server in servers: + * if isinstance(server, unicode): # <<<<<<<<<<<<<< + * server = server.encode('ascii') + * string = <char*?>server + */ + __pyx_t_1 = PyUnicode_Check(__pyx_v_server); + __pyx_t_8 = (__pyx_t_1 != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":335 + * for server in servers: + * if isinstance(server, unicode): + * server = server.encode('ascii') # <<<<<<<<<<<<<< + * string = <char*?>server + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_server, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 335, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_server, __pyx_t_7); + __pyx_t_7 = 0; + + /* "gevent/ares.pyx":334 + * index = 0 + * for server in servers: + * if isinstance(server, unicode): # <<<<<<<<<<<<<< + * server = server.encode('ascii') + * string = <char*?>server + */ + } + + /* "gevent/ares.pyx":336 + * if isinstance(server, unicode): + * server = server.encode('ascii') + * string = <char*?>server # <<<<<<<<<<<<<< + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET + */ + __pyx_t_11 = __Pyx_PyObject_AsString(__pyx_v_server); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L9_error) + __pyx_v_string = ((char *)__pyx_t_11); + + /* "gevent/ares.pyx":337 + * server = server.encode('ascii') + * string = <char*?>server + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< + * c_servers[index].family = AF_INET + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: + */ + __pyx_t_8 = ((ares_inet_pton(AF_INET, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":338 + * string = <char*?>server + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET # <<<<<<<<<<<<<< + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET6 + */ + (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET; + + /* "gevent/ares.pyx":337 + * server = server.encode('ascii') + * string = <char*?>server + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< + * c_servers[index].family = AF_INET + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: + */ + goto __pyx_L14; + } + + /* "gevent/ares.pyx":339 + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< + * c_servers[index].family = AF_INET6 + * else: + */ + __pyx_t_8 = ((ares_inet_pton(AF_INET6, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":340 + * c_servers[index].family = AF_INET + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET6 # <<<<<<<<<<<<<< + * else: + * raise InvalidIP(repr(string)) + */ + (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET6; + + /* "gevent/ares.pyx":339 + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + * c_servers[index].family = AF_INET + * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<< + * c_servers[index].family = AF_INET6 + * else: + */ + goto __pyx_L14; + } + + /* "gevent/ares.pyx":342 + * c_servers[index].family = AF_INET6 + * else: + * raise InvalidIP(repr(string)) # <<<<<<<<<<<<<< + * c_servers[index].next = &c_servers[index] + 1 + * index += 1 + */ + /*else*/ { + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_string); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_Repr(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_4) { + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_7); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; + __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; + __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_7, 0, 0, 0); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __PYX_ERR(0, 342, __pyx_L9_error) + } + __pyx_L14:; + + /* "gevent/ares.pyx":343 + * else: + * raise InvalidIP(repr(string)) + * c_servers[index].next = &c_servers[index] + 1 # <<<<<<<<<<<<<< + * index += 1 + * if index >= length: + */ + (__pyx_v_c_servers[__pyx_v_index]).next = ((&(__pyx_v_c_servers[__pyx_v_index])) + 1); + + /* "gevent/ares.pyx":344 + * raise InvalidIP(repr(string)) + * c_servers[index].next = &c_servers[index] + 1 + * index += 1 # <<<<<<<<<<<<<< + * if index >= length: + * break + */ + __pyx_v_index = (__pyx_v_index + 1); + + /* "gevent/ares.pyx":345 + * c_servers[index].next = &c_servers[index] + 1 + * index += 1 + * if index >= length: # <<<<<<<<<<<<<< + * break + * c_servers[length - 1].next = NULL + */ + __pyx_t_8 = ((__pyx_v_index >= __pyx_v_length) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":346 + * index += 1 + * if index >= length: + * break # <<<<<<<<<<<<<< + * c_servers[length - 1].next = NULL + * index = cares.ares_set_servers(self.channel, c_servers) + */ + goto __pyx_L12_break; + + /* "gevent/ares.pyx":345 + * c_servers[index].next = &c_servers[index] + 1 + * index += 1 + * if index >= length: # <<<<<<<<<<<<<< + * break + * c_servers[length - 1].next = NULL + */ + } + + /* "gevent/ares.pyx":333 + * try: + * index = 0 + * for server in servers: # <<<<<<<<<<<<<< + * if isinstance(server, unicode): + * server = server.encode('ascii') + */ + } + __pyx_L12_break:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":347 + * if index >= length: + * break + * c_servers[length - 1].next = NULL # <<<<<<<<<<<<<< + * index = cares.ares_set_servers(self.channel, c_servers) + * if index: + */ + (__pyx_v_c_servers[(__pyx_v_length - 1)]).next = NULL; + + /* "gevent/ares.pyx":348 + * break + * c_servers[length - 1].next = NULL + * index = cares.ares_set_servers(self.channel, c_servers) # <<<<<<<<<<<<<< + * if index: + * raise ValueError(strerror(index)) + */ + __pyx_v_index = ares_set_servers(__pyx_v_self->channel, __pyx_v_c_servers); + + /* "gevent/ares.pyx":349 + * c_servers[length - 1].next = NULL + * index = cares.ares_set_servers(self.channel, c_servers) + * if index: # <<<<<<<<<<<<<< + * raise ValueError(strerror(index)) + * finally: + */ + __pyx_t_8 = (__pyx_v_index != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":350 + * index = cares.ares_set_servers(self.channel, c_servers) + * if index: + * raise ValueError(strerror(index)) # <<<<<<<<<<<<<< + * finally: + * free(c_servers) + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = __pyx_f_6gevent_4ares_strerror(__pyx_t_3, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L9_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_7, 0, 0, 0); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __PYX_ERR(0, 350, __pyx_L9_error) + + /* "gevent/ares.pyx":349 + * c_servers[length - 1].next = NULL + * index = cares.ares_set_servers(self.channel, c_servers) + * if index: # <<<<<<<<<<<<<< + * raise ValueError(strerror(index)) + * finally: + */ + } + } + + /* "gevent/ares.pyx":352 + * raise ValueError(strerror(index)) + * finally: + * free(c_servers) # <<<<<<<<<<<<<< + * + * # this crashes c-ares + */ + /*finally:*/ { + /*normal exit:*/{ + free(__pyx_v_c_servers); + goto __pyx_L10; + } + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L9_error:; + __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __Pyx_XGOTREF(__pyx_t_19); + __Pyx_XGOTREF(__pyx_t_20); + __pyx_t_6 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; + { + free(__pyx_v_c_servers); + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_XGIVEREF(__pyx_t_19); + __Pyx_XGIVEREF(__pyx_t_20); + __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); + } + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); + __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; + goto __pyx_L1_error; + } + __pyx_L10:; + } + } + __pyx_L6:; + + /* "gevent/ares.pyx":314 + * self.channel = NULL + * + * def set_servers(self, servers=None): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_server); + __Pyx_XDECREF(__pyx_v_servers); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":358 + * # cares.ares_cancel(self.channel) + * + * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<< + * if not self.channel: + * return + */ + +static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write) { + PyObject *__pyx_v_watcher = 0; + int __pyx_v_events; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + __Pyx_RefNannySetupContext("_sock_state_callback", 0); + + /* "gevent/ares.pyx":359 + * + * cdef _sock_state_callback(self, int socket, int read, int write): + * if not self.channel: # <<<<<<<<<<<<<< + * return + * cdef object watcher = self._watchers.get(socket) + */ + __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":360 + * cdef _sock_state_callback(self, int socket, int read, int write): + * if not self.channel: + * return # <<<<<<<<<<<<<< + * cdef object watcher = self._watchers.get(socket) + * cdef int events = 0 + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "gevent/ares.pyx":359 + * + * cdef _sock_state_callback(self, int socket, int read, int write): + * if not self.channel: # <<<<<<<<<<<<<< + * return + * cdef object watcher = self._watchers.get(socket) + */ + } + + /* "gevent/ares.pyx":361 + * if not self.channel: + * return + * cdef object watcher = self._watchers.get(socket) # <<<<<<<<<<<<<< + * cdef int events = 0 + * if read: + */ + if (unlikely(__pyx_v_self->_watchers == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get"); + __PYX_ERR(0, 361, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->_watchers, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_watcher = __pyx_t_3; + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":362 + * return + * cdef object watcher = self._watchers.get(socket) + * cdef int events = 0 # <<<<<<<<<<<<<< + * if read: + * events |= EV_READ + */ + __pyx_v_events = 0; + + /* "gevent/ares.pyx":363 + * cdef object watcher = self._watchers.get(socket) + * cdef int events = 0 + * if read: # <<<<<<<<<<<<<< + * events |= EV_READ + * if write: + */ + __pyx_t_1 = (__pyx_v_read != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":364 + * cdef int events = 0 + * if read: + * events |= EV_READ # <<<<<<<<<<<<<< + * if write: + * events |= EV_WRITE + */ + __pyx_v_events = (__pyx_v_events | 1); + + /* "gevent/ares.pyx":363 + * cdef object watcher = self._watchers.get(socket) + * cdef int events = 0 + * if read: # <<<<<<<<<<<<<< + * events |= EV_READ + * if write: + */ + } + + /* "gevent/ares.pyx":365 + * if read: + * events |= EV_READ + * if write: # <<<<<<<<<<<<<< + * events |= EV_WRITE + * if watcher is None: + */ + __pyx_t_1 = (__pyx_v_write != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":366 + * events |= EV_READ + * if write: + * events |= EV_WRITE # <<<<<<<<<<<<<< + * if watcher is None: + * if not events: + */ + __pyx_v_events = (__pyx_v_events | 2); + + /* "gevent/ares.pyx":365 + * if read: + * events |= EV_READ + * if write: # <<<<<<<<<<<<<< + * events |= EV_WRITE + * if watcher is None: + */ + } + + /* "gevent/ares.pyx":367 + * if write: + * events |= EV_WRITE + * if watcher is None: # <<<<<<<<<<<<<< + * if not events: + * return + */ + __pyx_t_1 = (__pyx_v_watcher == Py_None); + __pyx_t_4 = (__pyx_t_1 != 0); + if (__pyx_t_4) { + + /* "gevent/ares.pyx":368 + * events |= EV_WRITE + * if watcher is None: + * if not events: # <<<<<<<<<<<<<< + * return + * watcher = self.loop.io(socket, events) + */ + __pyx_t_4 = ((!(__pyx_v_events != 0)) != 0); + if (__pyx_t_4) { + + /* "gevent/ares.pyx":369 + * if watcher is None: + * if not events: + * return # <<<<<<<<<<<<<< + * watcher = self.loop.io(socket, events) + * self._watchers[socket] = watcher + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "gevent/ares.pyx":368 + * events |= EV_WRITE + * if watcher is None: + * if not events: # <<<<<<<<<<<<<< + * return + * watcher = self.loop.io(socket, events) + */ + } + + /* "gevent/ares.pyx":370 + * if not events: + * return + * watcher = self.loop.io(socket, events) # <<<<<<<<<<<<<< + * self._watchers[socket] = watcher + * elif events: + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6); + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_watcher, __pyx_t_3); + __pyx_t_3 = 0; + + /* "gevent/ares.pyx":371 + * return + * watcher = self.loop.io(socket, events) + * self._watchers[socket] = watcher # <<<<<<<<<<<<<< + * elif events: + * if watcher.events == events: + */ + if (unlikely(__pyx_v_self->_watchers == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(0, 371, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(PyDict_SetItem(__pyx_v_self->_watchers, __pyx_t_3, __pyx_v_watcher) < 0)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":367 + * if write: + * events |= EV_WRITE + * if watcher is None: # <<<<<<<<<<<<<< + * if not events: + * return + */ + goto __pyx_L6; + } + + /* "gevent/ares.pyx":372 + * watcher = self.loop.io(socket, events) + * self._watchers[socket] = watcher + * elif events: # <<<<<<<<<<<<<< + * if watcher.events == events: + * return + */ + __pyx_t_4 = (__pyx_v_events != 0); + if (__pyx_t_4) { + + /* "gevent/ares.pyx":373 + * self._watchers[socket] = watcher + * elif events: + * if watcher.events == events: # <<<<<<<<<<<<<< + * return + * watcher.stop() + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 373, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 373, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_4) { + + /* "gevent/ares.pyx":374 + * elif events: + * if watcher.events == events: + * return # <<<<<<<<<<<<<< + * watcher.stop() + * watcher.events = events + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "gevent/ares.pyx":373 + * self._watchers[socket] = watcher + * elif events: + * if watcher.events == events: # <<<<<<<<<<<<<< + * return + * watcher.stop() + */ + } + + /* "gevent/ares.pyx":375 + * if watcher.events == events: + * return + * watcher.stop() # <<<<<<<<<<<<<< + * watcher.events = events + * else: + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 375, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 375, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "gevent/ares.pyx":376 + * return + * watcher.stop() + * watcher.events = events # <<<<<<<<<<<<<< + * else: + * watcher.stop() + */ + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 376, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__Pyx_PyObject_SetAttrStr(__pyx_v_watcher, __pyx_n_s_events, __pyx_t_9) < 0) __PYX_ERR(0, 376, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "gevent/ares.pyx":372 + * watcher = self.loop.io(socket, events) + * self._watchers[socket] = watcher + * elif events: # <<<<<<<<<<<<<< + * if watcher.events == events: + * return + */ + goto __pyx_L6; + } + + /* "gevent/ares.pyx":378 + * watcher.events = events + * else: + * watcher.stop() # <<<<<<<<<<<<<< + * self._watchers.pop(socket, None) + * if not self._watchers: + */ + /*else*/ { + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 378, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 378, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "gevent/ares.pyx":379 + * else: + * watcher.stop() + * self._watchers.pop(socket, None) # <<<<<<<<<<<<<< + * if not self._watchers: + * self._timer.stop() + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_watchers, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, Py_None}; + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, Py_None}; + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_t_3); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, Py_None); + __pyx_t_3 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "gevent/ares.pyx":380 + * watcher.stop() + * self._watchers.pop(socket, None) + * if not self._watchers: # <<<<<<<<<<<<<< + * self._timer.stop() + * return + */ + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_watchers); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_1 = ((!__pyx_t_4) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":381 + * self._watchers.pop(socket, None) + * if not self._watchers: + * self._timer.stop() # <<<<<<<<<<<<<< + * return + * watcher.start(self._process_fd, watcher, pass_events=True) + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_5) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 381, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else { + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 381, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "gevent/ares.pyx":380 + * watcher.stop() + * self._watchers.pop(socket, None) + * if not self._watchers: # <<<<<<<<<<<<<< + * self._timer.stop() + * return + */ + } + + /* "gevent/ares.pyx":382 + * if not self._watchers: + * self._timer.stop() + * return # <<<<<<<<<<<<<< + * watcher.start(self._process_fd, watcher, pass_events=True) + * self._timer.again(self._on_timer) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + } + __pyx_L6:; + + /* "gevent/ares.pyx":383 + * self._timer.stop() + * return + * watcher.start(self._process_fd, watcher, pass_events=True) # <<<<<<<<<<<<<< + * self._timer.again(self._on_timer) + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_process_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_v_watcher); + __Pyx_GIVEREF(__pyx_v_watcher); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_watcher); + __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pass_events, Py_True) < 0) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":384 + * return + * watcher.start(self._process_fd, watcher, pass_events=True) + * self._timer.again(self._on_timer) # <<<<<<<<<<<<<< + * + * def _on_timer(self): + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_again); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timer); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_9) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "gevent/ares.pyx":358 + * # cares.ares_cancel(self.channel) + * + * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<< + * if not self.channel: + * return + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("gevent.ares.channel._sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_watcher); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":386 + * self._timer.again(self._on_timer) + * + * def _on_timer(self): # <<<<<<<<<<<<<< + * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_on_timer (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_10_on_timer(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_on_timer", 0); + + /* "gevent/ares.pyx":387 + * + * def _on_timer(self): + * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) # <<<<<<<<<<<<<< + * + * def _process_fd(self, int events, object watcher): + */ + ares_process_fd(__pyx_v_self->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); + + /* "gevent/ares.pyx":386 + * self._timer.again(self._on_timer) + * + * def _on_timer(self): # <<<<<<<<<<<<<< + * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":389 + * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) + * + * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<< + * if not self.channel: + * return + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_events; + PyObject *__pyx_v_watcher = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_process_fd (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_events,&__pyx_n_s_watcher,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, 1); __PYX_ERR(0, 389, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_process_fd") < 0)) __PYX_ERR(0, 389, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_events = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L3_error) + __pyx_v_watcher = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 389, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_7channel_12_process_fd(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_events, __pyx_v_watcher); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher) { + int __pyx_v_read_fd; + int __pyx_v_write_fd; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("_process_fd", 0); + + /* "gevent/ares.pyx":390 + * + * def _process_fd(self, int events, object watcher): + * if not self.channel: # <<<<<<<<<<<<<< + * return + * cdef int read_fd = watcher.fd + */ + __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":391 + * def _process_fd(self, int events, object watcher): + * if not self.channel: + * return # <<<<<<<<<<<<<< + * cdef int read_fd = watcher.fd + * cdef int write_fd = read_fd + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "gevent/ares.pyx":390 + * + * def _process_fd(self, int events, object watcher): + * if not self.channel: # <<<<<<<<<<<<<< + * return + * cdef int read_fd = watcher.fd + */ + } + + /* "gevent/ares.pyx":392 + * if not self.channel: + * return + * cdef int read_fd = watcher.fd # <<<<<<<<<<<<<< + * cdef int write_fd = read_fd + * if not (events & EV_READ): + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 392, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_read_fd = __pyx_t_3; + + /* "gevent/ares.pyx":393 + * return + * cdef int read_fd = watcher.fd + * cdef int write_fd = read_fd # <<<<<<<<<<<<<< + * if not (events & EV_READ): + * read_fd = cares.ARES_SOCKET_BAD + */ + __pyx_v_write_fd = __pyx_v_read_fd; + + /* "gevent/ares.pyx":394 + * cdef int read_fd = watcher.fd + * cdef int write_fd = read_fd + * if not (events & EV_READ): # <<<<<<<<<<<<<< + * read_fd = cares.ARES_SOCKET_BAD + * if not (events & EV_WRITE): + */ + __pyx_t_1 = ((!((__pyx_v_events & 1) != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":395 + * cdef int write_fd = read_fd + * if not (events & EV_READ): + * read_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<< + * if not (events & EV_WRITE): + * write_fd = cares.ARES_SOCKET_BAD + */ + __pyx_v_read_fd = ARES_SOCKET_BAD; + + /* "gevent/ares.pyx":394 + * cdef int read_fd = watcher.fd + * cdef int write_fd = read_fd + * if not (events & EV_READ): # <<<<<<<<<<<<<< + * read_fd = cares.ARES_SOCKET_BAD + * if not (events & EV_WRITE): + */ + } + + /* "gevent/ares.pyx":396 + * if not (events & EV_READ): + * read_fd = cares.ARES_SOCKET_BAD + * if not (events & EV_WRITE): # <<<<<<<<<<<<<< + * write_fd = cares.ARES_SOCKET_BAD + * cares.ares_process_fd(self.channel, read_fd, write_fd) + */ + __pyx_t_1 = ((!((__pyx_v_events & 2) != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":397 + * read_fd = cares.ARES_SOCKET_BAD + * if not (events & EV_WRITE): + * write_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<< + * cares.ares_process_fd(self.channel, read_fd, write_fd) + * + */ + __pyx_v_write_fd = ARES_SOCKET_BAD; + + /* "gevent/ares.pyx":396 + * if not (events & EV_READ): + * read_fd = cares.ARES_SOCKET_BAD + * if not (events & EV_WRITE): # <<<<<<<<<<<<<< + * write_fd = cares.ARES_SOCKET_BAD + * cares.ares_process_fd(self.channel, read_fd, write_fd) + */ + } + + /* "gevent/ares.pyx":398 + * if not (events & EV_WRITE): + * write_fd = cares.ARES_SOCKET_BAD + * cares.ares_process_fd(self.channel, read_fd, write_fd) # <<<<<<<<<<<<<< + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): + */ + ares_process_fd(__pyx_v_self->channel, __pyx_v_read_fd, __pyx_v_write_fd); + + /* "gevent/ares.pyx":389 + * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) + * + * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<< + * if not self.channel: + * return + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":400 + * cares.ares_process_fd(self.channel, read_fd, write_fd) + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + char *__pyx_v_name; + int __pyx_v_family; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gethostbyname (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_name_2,&__pyx_n_s_family,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name_2)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, 1); __PYX_ERR(0, 400, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyname") < 0)) __PYX_ERR(0, 400, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_callback = values[0]; + __pyx_v_name = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L3_error) + if (values[2]) { + __pyx_v_family = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_family == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L3_error) + } else { + __pyx_v_family = __pyx_k__5; + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 400, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_7channel_14gethostbyname(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_name, __pyx_v_family); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family) { + PyObject *__pyx_v_arg = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + __Pyx_RefNannySetupContext("gethostbyname", 0); + + /* "gevent/ares.pyx":401 + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * # note that for file lookups still AF_INET can be returned for AF_INET6 request + */ + __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":402 + * def gethostbyname(self, object callback, char* name, int family=AF_INET): + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< + * # note that for file lookups still AF_INET can be returned for AF_INET6 request + * cdef object arg = (self, callback) + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); + __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 402, __pyx_L1_error) + + /* "gevent/ares.pyx":401 + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * # note that for file lookups still AF_INET can be returned for AF_INET6 request + */ + } + + /* "gevent/ares.pyx":404 + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * # note that for file lookups still AF_INET can be returned for AF_INET6 request + * cdef object arg = (self, callback) # <<<<<<<<<<<<<< + * Py_INCREF(<PyObjectPtr>arg) + * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); + __pyx_v_arg = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":405 + * # note that for file lookups still AF_INET can be returned for AF_INET6 request + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<< + * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) + * + */ + Py_INCREF(((PyObject*)__pyx_v_arg)); + + /* "gevent/ares.pyx":406 + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) + * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<< + * + * def gethostbyaddr(self, object callback, char* addr): + */ + ares_gethostbyname(__pyx_v_self->channel, __pyx_v_name, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg)); + + /* "gevent/ares.pyx":400 + * cares.ares_process_fd(self.channel, read_fd, write_fd) + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arg); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":408 + * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) + * + * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + char *__pyx_v_addr; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gethostbyaddr (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_addr,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, 1); __PYX_ERR(0, 408, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyaddr") < 0)) __PYX_ERR(0, 408, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_callback = values[0]; + __pyx_v_addr = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_addr) && PyErr_Occurred())) __PYX_ERR(0, 408, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 408, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_addr); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr) { + char __pyx_v_addr_packed[16]; + int __pyx_v_family; + int __pyx_v_length; + PyObject *__pyx_v_arg = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + __Pyx_RefNannySetupContext("gethostbyaddr", 0); + + /* "gevent/ares.pyx":409 + * + * def gethostbyaddr(self, object callback, char* addr): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * # will guess the family + */ + __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":410 + * def gethostbyaddr(self, object callback, char* addr): + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< + * # will guess the family + * cdef char addr_packed[16] + */ + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); + __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 410, __pyx_L1_error) + + /* "gevent/ares.pyx":409 + * + * def gethostbyaddr(self, object callback, char* addr): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * # will guess the family + */ + } + + /* "gevent/ares.pyx":415 + * cdef int family + * cdef int length + * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<< + * family = AF_INET + * length = 4 + */ + __pyx_t_1 = ((ares_inet_pton(AF_INET, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":416 + * cdef int length + * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: + * family = AF_INET # <<<<<<<<<<<<<< + * length = 4 + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: + */ + __pyx_v_family = AF_INET; + + /* "gevent/ares.pyx":417 + * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: + * family = AF_INET + * length = 4 # <<<<<<<<<<<<<< + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: + * family = AF_INET6 + */ + __pyx_v_length = 4; + + /* "gevent/ares.pyx":415 + * cdef int family + * cdef int length + * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<< + * family = AF_INET + * length = 4 + */ + goto __pyx_L4; + } + + /* "gevent/ares.pyx":418 + * family = AF_INET + * length = 4 + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<< + * family = AF_INET6 + * length = 16 + */ + __pyx_t_1 = ((ares_inet_pton(AF_INET6, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0); + if (__pyx_t_1) { + + /* "gevent/ares.pyx":419 + * length = 4 + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: + * family = AF_INET6 # <<<<<<<<<<<<<< + * length = 16 + * else: + */ + __pyx_v_family = AF_INET6; + + /* "gevent/ares.pyx":420 + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: + * family = AF_INET6 + * length = 16 # <<<<<<<<<<<<<< + * else: + * raise InvalidIP(repr(addr)) + */ + __pyx_v_length = 16; + + /* "gevent/ares.pyx":418 + * family = AF_INET + * length = 4 + * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<< + * family = AF_INET6 + * length = 16 + */ + goto __pyx_L4; + } + + /* "gevent/ares.pyx":422 + * length = 16 + * else: + * raise InvalidIP(repr(addr)) # <<<<<<<<<<<<<< + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) + */ + /*else*/ { + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_addr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_7) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 422, __pyx_L1_error) + } + __pyx_L4:; + + /* "gevent/ares.pyx":423 + * else: + * raise InvalidIP(repr(addr)) + * cdef object arg = (self, callback) # <<<<<<<<<<<<<< + * Py_INCREF(<PyObjectPtr>arg) + * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); + __pyx_v_arg = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":424 + * raise InvalidIP(repr(addr)) + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<< + * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) + * + */ + Py_INCREF(((PyObject*)__pyx_v_arg)); + + /* "gevent/ares.pyx":425 + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) + * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<< + * + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): + */ + ares_gethostbyaddr(__pyx_v_self->channel, __pyx_v_addr_packed, __pyx_v_length, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg)); + + /* "gevent/ares.pyx":408 + * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) + * + * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arg); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":427 + * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) + * + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + +static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch) { + char *__pyx_v_hostp; + int __pyx_v_port; + int __pyx_v_flowinfo; + int __pyx_v_scope_id; + struct sockaddr_in6 __pyx_v_sa6; + int __pyx_v_length; + PyObject *__pyx_v_arg = 0; + struct sockaddr *__pyx_v_x; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + __Pyx_RefNannySetupContext("_getnameinfo", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getnameinfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_callback); + __Pyx_INCREF(__pyx_v_sockaddr); + __Pyx_GIVEREF(__pyx_v_sockaddr); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_sockaddr); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "gevent/ares.pyx":428 + * + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * cdef char* hostp = NULL + */ + __pyx_t_8 = ((!(__pyx_v_self->channel != 0)) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":429 + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<< + * cdef char* hostp = NULL + * cdef int port = 0 + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr); + __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 429, __pyx_L1_error) + + /* "gevent/ares.pyx":428 + * + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): + * if not self.channel: # <<<<<<<<<<<<<< + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * cdef char* hostp = NULL + */ + } + + /* "gevent/ares.pyx":430 + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * cdef char* hostp = NULL # <<<<<<<<<<<<<< + * cdef int port = 0 + * cdef int flowinfo = 0 + */ + __pyx_v_hostp = NULL; + + /* "gevent/ares.pyx":431 + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + * cdef char* hostp = NULL + * cdef int port = 0 # <<<<<<<<<<<<<< + * cdef int flowinfo = 0 + * cdef int scope_id = 0 + */ + __pyx_v_port = 0; + + /* "gevent/ares.pyx":432 + * cdef char* hostp = NULL + * cdef int port = 0 + * cdef int flowinfo = 0 # <<<<<<<<<<<<<< + * cdef int scope_id = 0 + * cdef sockaddr_in6 sa6 + */ + __pyx_v_flowinfo = 0; + + /* "gevent/ares.pyx":433 + * cdef int port = 0 + * cdef int flowinfo = 0 + * cdef int scope_id = 0 # <<<<<<<<<<<<<< + * cdef sockaddr_in6 sa6 + * if not PyTuple_Check(sockaddr): + */ + __pyx_v_scope_id = 0; + + /* "gevent/ares.pyx":435 + * cdef int scope_id = 0 + * cdef sockaddr_in6 sa6 + * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<< + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + */ + __pyx_t_8 = ((!(PyTuple_Check(__pyx_v_sockaddr) != 0)) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":436 + * cdef sockaddr_in6 sa6 + * if not PyTuple_Check(sockaddr): + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) # <<<<<<<<<<<<<< + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + * if port < 0 or port > 65535: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_sockaddr); + __Pyx_GIVEREF(__pyx_v_sockaddr); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sockaddr); + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_expected_a_tuple_got_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 436, __pyx_L1_error) + + /* "gevent/ares.pyx":435 + * cdef int scope_id = 0 + * cdef sockaddr_in6 sa6 + * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<< + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + */ + } + + /* "gevent/ares.pyx":437 + * if not PyTuple_Check(sockaddr): + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) # <<<<<<<<<<<<<< + * if port < 0 or port > 65535: + * raise gaierror(-8, 'Invalid value for port: %r' % port) + */ + __pyx_t_6 = PyArg_ParseTuple(__pyx_v_sockaddr, ((char *)"si|ii"), (&__pyx_v_hostp), (&__pyx_v_port), (&__pyx_v_flowinfo), (&__pyx_v_scope_id)); if (unlikely(__pyx_t_6 == 0)) __PYX_ERR(0, 437, __pyx_L1_error) + + /* "gevent/ares.pyx":438 + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + * if port < 0 or port > 65535: # <<<<<<<<<<<<<< + * raise gaierror(-8, 'Invalid value for port: %r' % port) + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + */ + __pyx_t_9 = ((__pyx_v_port < 0) != 0); + if (!__pyx_t_9) { + } else { + __pyx_t_8 = __pyx_t_9; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_9 = ((__pyx_v_port > 0xFFFF) != 0); + __pyx_t_8 = __pyx_t_9; + __pyx_L6_bool_binop_done:; + if (__pyx_t_8) { + + /* "gevent/ares.pyx":439 + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + * if port < 0 or port > 65535: + * raise gaierror(-8, 'Invalid value for port: %r' % port) # <<<<<<<<<<<<<< + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + * if length <= 0: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_port_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_int_neg_8); + __Pyx_GIVEREF(__pyx_int_neg_8); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_int_neg_8); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 439, __pyx_L1_error) + + /* "gevent/ares.pyx":438 + * raise TypeError('expected a tuple, got %r' % (sockaddr, )) + * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) + * if port < 0 or port > 65535: # <<<<<<<<<<<<<< + * raise gaierror(-8, 'Invalid value for port: %r' % port) + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + */ + } + + /* "gevent/ares.pyx":440 + * if port < 0 or port > 65535: + * raise gaierror(-8, 'Invalid value for port: %r' % port) + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) # <<<<<<<<<<<<<< + * if length <= 0: + * raise InvalidIP(repr(hostp)) + */ + __pyx_v_length = gevent_make_sockaddr(__pyx_v_hostp, __pyx_v_port, __pyx_v_flowinfo, __pyx_v_scope_id, (&__pyx_v_sa6)); + + /* "gevent/ares.pyx":441 + * raise gaierror(-8, 'Invalid value for port: %r' % port) + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + * if length <= 0: # <<<<<<<<<<<<<< + * raise InvalidIP(repr(hostp)) + * cdef object arg = (self, callback) + */ + __pyx_t_8 = ((__pyx_v_length <= 0) != 0); + if (__pyx_t_8) { + + /* "gevent/ares.pyx":442 + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + * if length <= 0: + * raise InvalidIP(repr(hostp)) # <<<<<<<<<<<<<< + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_hostp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_7) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 442, __pyx_L1_error) + + /* "gevent/ares.pyx":441 + * raise gaierror(-8, 'Invalid value for port: %r' % port) + * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) + * if length <= 0: # <<<<<<<<<<<<<< + * raise InvalidIP(repr(hostp)) + * cdef object arg = (self, callback) + */ + } + + /* "gevent/ares.pyx":443 + * if length <= 0: + * raise InvalidIP(repr(hostp)) + * cdef object arg = (self, callback) # <<<<<<<<<<<<<< + * Py_INCREF(<PyObjectPtr>arg) + * cdef sockaddr_t* x = <sockaddr_t*>&sa6 + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback); + __pyx_v_arg = __pyx_t_2; + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":444 + * raise InvalidIP(repr(hostp)) + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<< + * cdef sockaddr_t* x = <sockaddr_t*>&sa6 + * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) + */ + Py_INCREF(((PyObject*)__pyx_v_arg)); + + /* "gevent/ares.pyx":445 + * cdef object arg = (self, callback) + * Py_INCREF(<PyObjectPtr>arg) + * cdef sockaddr_t* x = <sockaddr_t*>&sa6 # <<<<<<<<<<<<<< + * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) + * + */ + __pyx_v_x = ((struct sockaddr *)(&__pyx_v_sa6)); + + /* "gevent/ares.pyx":446 + * Py_INCREF(<PyObjectPtr>arg) + * cdef sockaddr_t* x = <sockaddr_t*>&sa6 + * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) # <<<<<<<<<<<<<< + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): + */ + ares_getnameinfo(__pyx_v_self->channel, __pyx_v_x, __pyx_v_length, __pyx_v_flags, ((void *)__pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback), ((void *)__pyx_v_arg)); + + /* "gevent/ares.pyx":427 + * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) + * + * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arg); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_sockaddr = 0; + int __pyx_v_flags; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_getnameinfo (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 427, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 427, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getnameinfo") < 0)) __PYX_ERR(0, 427, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_callback = values[0]; + __pyx_v_sockaddr = ((PyObject*)values[1]); + __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 427, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 427, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_4ares_7channel_18_getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_getnameinfo", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_4ares_7channel__getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":448 + * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< + * try: + * flags = _convert_cares_flags(flags) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_sockaddr = 0; + int __pyx_v_flags; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("getnameinfo (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 448, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 448, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getnameinfo") < 0)) __PYX_ERR(0, 448, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_callback = values[0]; + __pyx_v_sockaddr = ((PyObject*)values[1]); + __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 448, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 448, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 448, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_4ares_7channel_20getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + __Pyx_RefNannySetupContext("getnameinfo", 0); + + /* "gevent/ares.pyx":449 + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): + * try: # <<<<<<<<<<<<<< + * flags = _convert_cares_flags(flags) + * except gaierror: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "gevent/ares.pyx":450 + * def getnameinfo(self, object callback, tuple sockaddr, int flags): + * try: + * flags = _convert_cares_flags(flags) # <<<<<<<<<<<<<< + * except gaierror: + * # The stdlib just ignores bad flags + */ + __pyx_t_4 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 450, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 450, __pyx_L3_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_flags = __pyx_t_5; + + /* "gevent/ares.pyx":449 + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): + * try: # <<<<<<<<<<<<<< + * flags = _convert_cares_flags(flags) + * except gaierror: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "gevent/ares.pyx":451 + * try: + * flags = _convert_cares_flags(flags) + * except gaierror: # <<<<<<<<<<<<<< + * # The stdlib just ignores bad flags + * flags = 0 + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 451, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { + __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 451, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "gevent/ares.pyx":453 + * except gaierror: + * # The stdlib just ignores bad flags + * flags = 0 # <<<<<<<<<<<<<< + * return self._getnameinfo(callback, sockaddr, flags) + */ + __pyx_v_flags = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L4_exception_handled; + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "gevent/ares.pyx":449 + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): + * try: # <<<<<<<<<<<<<< + * flags = _convert_cares_flags(flags) + * except gaierror: + */ + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + __pyx_L10_try_end:; + } + + /* "gevent/ares.pyx":454 + * # The stdlib just ignores bad flags + * flags = 0 + * return self._getnameinfo(callback, sockaddr, flags) # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_7 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_self->__pyx_vtab)->_getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 454, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "gevent/ares.pyx":448 + * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) + * + * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<< + * try: + * flags = _convert_cares_flags(flags) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":247 + * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: + * + * cdef public object loop # <<<<<<<<<<<<<< + * cdef ares_channeldata* channel + * cdef public dict _watchers + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->loop); + __pyx_r = __pyx_v_self->loop; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(__pyx_v_self->loop); + __pyx_v_self->loop = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(__pyx_v_self->loop); + __pyx_v_self->loop = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":249 + * cdef public object loop + * cdef ares_channeldata* channel + * cdef public dict _watchers # <<<<<<<<<<<<<< + * cdef public object _timer + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_watchers); + __pyx_r = __pyx_v_self->_watchers; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 249, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->_watchers); + __Pyx_DECREF(__pyx_v_self->_watchers); + __pyx_v_self->_watchers = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.ares.channel._watchers.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_watchers); + __Pyx_DECREF(__pyx_v_self->_watchers); + __pyx_v_self->_watchers = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "gevent/ares.pyx":250 + * cdef ares_channeldata* channel + * cdef public dict _watchers + * cdef public object _timer # <<<<<<<<<<<<<< + * + * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer___get__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_timer); + __pyx_r = __pyx_v_self->_timer; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->_timer); + __Pyx_DECREF(__pyx_v_self->_timer); + __pyx_v_self->_timer = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_timer); + __Pyx_DECREF(__pyx_v_self->_timer); + __pyx_v_self->_timer = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_6gevent_4ares_result *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6gevent_4ares_result *)o); + p->value = Py_None; Py_INCREF(Py_None); + p->exception = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_4ares_result(PyObject *o) { + struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->value); + Py_CLEAR(p->exception); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6gevent_4ares_result(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; + if (p->value) { + e = (*v)(p->value, a); if (e) return e; + } + if (p->exception) { + e = (*v)(p->exception, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_4ares_result(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o; + tmp = ((PyObject*)p->value); + p->value = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->exception); + p->exception = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_4ares_6result_value(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_4ares_6result_5value_1__get__(o); +} + +static int __pyx_setprop_6gevent_4ares_6result_value(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_4ares_6result_5value_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_4ares_6result_5value_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_4ares_6result_exception(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_4ares_6result_9exception_1__get__(o); +} + +static int __pyx_setprop_6gevent_4ares_6result_exception(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_4ares_6result_9exception_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_4ares_6result_9exception_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_6gevent_4ares_result[] = { + {"successful", (PyCFunction)__pyx_pw_6gevent_4ares_6result_5successful, METH_NOARGS, 0}, + {"get", (PyCFunction)__pyx_pw_6gevent_4ares_6result_7get, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_4ares_result[] = { + {(char *)"value", __pyx_getprop_6gevent_4ares_6result_value, __pyx_setprop_6gevent_4ares_6result_value, (char *)0, 0}, + {(char *)"exception", __pyx_getprop_6gevent_4ares_6result_exception, __pyx_setprop_6gevent_4ares_6result_exception, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_6gevent_4ares_result = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.ares.result", /*tp_name*/ + sizeof(struct __pyx_obj_6gevent_4ares_result), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_4ares_result, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_4ares_6result_3__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_4ares_result, /*tp_traverse*/ + __pyx_tp_clear_6gevent_4ares_result, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_4ares_result, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_4ares_result, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_4ares_6result_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_4ares_result, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_6gevent_4ares_channel __pyx_vtable_6gevent_4ares_channel; + +static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct PyGeventAresChannelObject *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct PyGeventAresChannelObject *)o); + p->__pyx_vtab = __pyx_vtabptr_6gevent_4ares_channel; + p->loop = Py_None; Py_INCREF(Py_None); + p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_timer = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_4ares_channel(PyObject *o) { + struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_6gevent_4ares_7channel_7__dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->loop); + Py_CLEAR(p->_watchers); + Py_CLEAR(p->_timer); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6gevent_4ares_channel(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; + if (p->loop) { + e = (*v)(p->loop, a); if (e) return e; + } + if (p->_watchers) { + e = (*v)(p->_watchers, a); if (e) return e; + } + if (p->_timer) { + e = (*v)(p->_timer, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_4ares_channel(PyObject *o) { + PyObject* tmp; + struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o; + tmp = ((PyObject*)p->loop); + p->loop = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_watchers); + p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_timer); + p->_timer = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_4ares_7channel_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_4ares_7channel_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_4ares_7channel_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_4ares_7channel__watchers(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(o); +} + +static int __pyx_setprop_6gevent_4ares_7channel__watchers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_4ares_7channel__timer(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(o); +} + +static int __pyx_setprop_6gevent_4ares_7channel__timer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_6gevent_4ares_channel[] = { + {"destroy", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_5destroy, METH_NOARGS, 0}, + {"set_servers", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_9set_servers, METH_VARARGS|METH_KEYWORDS, 0}, + {"_on_timer", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_11_on_timer, METH_NOARGS, 0}, + {"_process_fd", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_13_process_fd, METH_VARARGS|METH_KEYWORDS, 0}, + {"gethostbyname", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_15gethostbyname, METH_VARARGS|METH_KEYWORDS, 0}, + {"gethostbyaddr", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr, METH_VARARGS|METH_KEYWORDS, 0}, + {"_getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo, METH_VARARGS|METH_KEYWORDS, 0}, + {"getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_21getnameinfo, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_4ares_channel[] = { + {(char *)"loop", __pyx_getprop_6gevent_4ares_7channel_loop, __pyx_setprop_6gevent_4ares_7channel_loop, (char *)0, 0}, + {(char *)"_watchers", __pyx_getprop_6gevent_4ares_7channel__watchers, __pyx_setprop_6gevent_4ares_7channel__watchers, (char *)0, 0}, + {(char *)"_timer", __pyx_getprop_6gevent_4ares_7channel__timer, __pyx_setprop_6gevent_4ares_7channel__timer, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.ares.channel", /*tp_name*/ + sizeof(struct PyGeventAresChannelObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_4ares_channel, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_4ares_7channel_3__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_4ares_channel, /*tp_traverse*/ + __pyx_tp_clear_6gevent_4ares_channel, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_4ares_channel, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_4ares_channel, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_4ares_7channel_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_4ares_channel, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {"_convert_cares_flags", (PyCFunction)__pyx_pw_6gevent_4ares_1_convert_cares_flags, METH_VARARGS|METH_KEYWORDS, 0}, + {"strerror", (PyCFunction)__pyx_pw_6gevent_4ares_3strerror, METH_O, 0}, + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "ares", + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_k_ARES_EADDRGETNETWORKPARAMS, sizeof(__pyx_k_ARES_EADDRGETNETWORKPARAMS), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADFAMILY, __pyx_k_ARES_EBADFAMILY, sizeof(__pyx_k_ARES_EBADFAMILY), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADFLAGS, __pyx_k_ARES_EBADFLAGS, sizeof(__pyx_k_ARES_EBADFLAGS), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADHINTS, __pyx_k_ARES_EBADHINTS, sizeof(__pyx_k_ARES_EBADHINTS), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADNAME, __pyx_k_ARES_EBADNAME, sizeof(__pyx_k_ARES_EBADNAME), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADQUERY, __pyx_k_ARES_EBADQUERY, sizeof(__pyx_k_ARES_EBADQUERY), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADRESP, __pyx_k_ARES_EBADRESP, sizeof(__pyx_k_ARES_EBADRESP), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EBADSTR, __pyx_k_ARES_EBADSTR, sizeof(__pyx_k_ARES_EBADSTR), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ECANCELLED, __pyx_k_ARES_ECANCELLED, sizeof(__pyx_k_ARES_ECANCELLED), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ECONNREFUSED, __pyx_k_ARES_ECONNREFUSED, sizeof(__pyx_k_ARES_ECONNREFUSED), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EDESTRUCTION, __pyx_k_ARES_EDESTRUCTION, sizeof(__pyx_k_ARES_EDESTRUCTION), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EFILE, __pyx_k_ARES_EFILE, sizeof(__pyx_k_ARES_EFILE), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EFORMERR, __pyx_k_ARES_EFORMERR, sizeof(__pyx_k_ARES_EFORMERR), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_k_ARES_ELOADIPHLPAPI, sizeof(__pyx_k_ARES_ELOADIPHLPAPI), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENODATA, __pyx_k_ARES_ENODATA, sizeof(__pyx_k_ARES_ENODATA), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENOMEM, __pyx_k_ARES_ENOMEM, sizeof(__pyx_k_ARES_ENOMEM), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENONAME, __pyx_k_ARES_ENONAME, sizeof(__pyx_k_ARES_ENONAME), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENOTFOUND, __pyx_k_ARES_ENOTFOUND, sizeof(__pyx_k_ARES_ENOTFOUND), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENOTIMP, __pyx_k_ARES_ENOTIMP, sizeof(__pyx_k_ARES_ENOTIMP), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ENOTINITIALIZED, __pyx_k_ARES_ENOTINITIALIZED, sizeof(__pyx_k_ARES_ENOTINITIALIZED), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EOF, __pyx_k_ARES_EOF, sizeof(__pyx_k_ARES_EOF), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_EREFUSED, __pyx_k_ARES_EREFUSED, sizeof(__pyx_k_ARES_EREFUSED), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ESERVFAIL, __pyx_k_ARES_ESERVFAIL, sizeof(__pyx_k_ARES_ESERVFAIL), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_ETIMEOUT, __pyx_k_ARES_ETIMEOUT, sizeof(__pyx_k_ARES_ETIMEOUT), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_IGNTC, __pyx_k_ARES_FLAG_IGNTC, sizeof(__pyx_k_ARES_FLAG_IGNTC), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_NOALIASES, __pyx_k_ARES_FLAG_NOALIASES, sizeof(__pyx_k_ARES_FLAG_NOALIASES), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_k_ARES_FLAG_NOCHECKRESP, sizeof(__pyx_k_ARES_FLAG_NOCHECKRESP), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_NORECURSE, __pyx_k_ARES_FLAG_NORECURSE, sizeof(__pyx_k_ARES_FLAG_NORECURSE), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_k_ARES_FLAG_NOSEARCH, sizeof(__pyx_k_ARES_FLAG_NOSEARCH), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_PRIMARY, __pyx_k_ARES_FLAG_PRIMARY, sizeof(__pyx_k_ARES_FLAG_PRIMARY), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_k_ARES_FLAG_STAYOPEN, sizeof(__pyx_k_ARES_FLAG_STAYOPEN), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_FLAG_USEVC, __pyx_k_ARES_FLAG_USEVC, sizeof(__pyx_k_ARES_FLAG_USEVC), 0, 0, 1, 1}, + {&__pyx_n_s_ARES_SUCCESS, __pyx_k_ARES_SUCCESS, sizeof(__pyx_k_ARES_SUCCESS), 0, 0, 1, 1}, + {&__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_k_Bad_value_for_ai_flags_0x_x, sizeof(__pyx_k_Bad_value_for_ai_flags_0x_x), 0, 0, 1, 0}, + {&__pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_k_C_projects_gevent_src_gevent_are, sizeof(__pyx_k_C_projects_gevent_src_gevent_are), 0, 0, 1, 0}, + {&__pyx_n_s_InvalidIP, __pyx_k_InvalidIP, sizeof(__pyx_k_InvalidIP), 0, 0, 1, 1}, + {&__pyx_kp_s_Invalid_value_for_port_r, __pyx_k_Invalid_value_for_port_r, sizeof(__pyx_k_Invalid_value_for_port_r), 0, 0, 1, 0}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_n_s_NI_DGRAM, __pyx_k_NI_DGRAM, sizeof(__pyx_k_NI_DGRAM), 0, 0, 1, 1}, + {&__pyx_n_s_NI_NAMEREQD, __pyx_k_NI_NAMEREQD, sizeof(__pyx_k_NI_NAMEREQD), 0, 0, 1, 1}, + {&__pyx_n_s_NI_NOFQDN, __pyx_k_NI_NOFQDN, sizeof(__pyx_k_NI_NOFQDN), 0, 0, 1, 1}, + {&__pyx_n_s_NI_NUMERICHOST, __pyx_k_NI_NUMERICHOST, sizeof(__pyx_k_NI_NUMERICHOST), 0, 0, 1, 1}, + {&__pyx_n_s_NI_NUMERICSERV, __pyx_k_NI_NUMERICSERV, sizeof(__pyx_k_NI_NUMERICSERV), 0, 0, 1, 1}, + {&__pyx_n_s_TIMEOUT, __pyx_k_TIMEOUT, sizeof(__pyx_k_TIMEOUT), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, + {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1}, + {&__pyx_n_s_again, __pyx_k_again, sizeof(__pyx_k_again), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_ares_errors, __pyx_k_ares_errors, sizeof(__pyx_k_ares_errors), 0, 0, 1, 1}, + {&__pyx_n_s_ares_host_result, __pyx_k_ares_host_result, sizeof(__pyx_k_ares_host_result), 0, 0, 1, 1}, + {&__pyx_n_s_ares_host_result___getnewargs, __pyx_k_ares_host_result___getnewargs, sizeof(__pyx_k_ares_host_result___getnewargs), 0, 0, 1, 1}, + {&__pyx_n_s_ares_host_result___new, __pyx_k_ares_host_result___new, sizeof(__pyx_k_ares_host_result___new), 0, 0, 1, 1}, + {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1}, + {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1}, + {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1}, + {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1}, + {&__pyx_n_s_cares_flag_map, __pyx_k_cares_flag_map, sizeof(__pyx_k_cares_flag_map), 0, 0, 1, 1}, + {&__pyx_n_s_channel, __pyx_k_channel, sizeof(__pyx_k_channel), 0, 0, 1, 1}, + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1}, + {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1}, + {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1}, + {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1}, + {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1}, + {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1}, + {&__pyx_kp_s_expected_a_tuple_got_r, __pyx_k_expected_a_tuple_got_r, sizeof(__pyx_k_expected_a_tuple_got_r), 0, 0, 1, 0}, + {&__pyx_n_s_family, __pyx_k_family, sizeof(__pyx_k_family), 0, 0, 1, 1}, + {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1}, + {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_gaierror, __pyx_k_gaierror, sizeof(__pyx_k_gaierror), 0, 0, 1, 1}, + {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, + {&__pyx_n_s_getnameinfo, __pyx_k_getnameinfo, sizeof(__pyx_k_getnameinfo), 0, 0, 1, 1}, + {&__pyx_n_s_getnewargs, __pyx_k_getnewargs, sizeof(__pyx_k_getnewargs), 0, 0, 1, 1}, + {&__pyx_n_s_gevent_ares, __pyx_k_gevent_ares, sizeof(__pyx_k_gevent_ares), 0, 0, 1, 1}, + {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, + {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1}, + {&__pyx_n_s_iterable, __pyx_k_iterable, sizeof(__pyx_k_iterable), 0, 0, 1, 1}, + {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, + {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, + {&__pyx_n_s_ndots, __pyx_k_ndots, sizeof(__pyx_k_ndots), 0, 0, 1, 1}, + {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, + {&__pyx_n_s_on_timer, __pyx_k_on_timer, sizeof(__pyx_k_on_timer), 0, 0, 1, 1}, + {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1}, + {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, + {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, + {&__pyx_n_s_process_fd, __pyx_k_process_fd, sizeof(__pyx_k_process_fd), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, + {&__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_k_s_at_0x_x__timer_r__watchers_s, sizeof(__pyx_k_s_at_0x_x__timer_r__watchers_s), 0, 0, 1, 0}, + {&__pyx_kp_s_s_exception_r, __pyx_k_s_exception_r, sizeof(__pyx_k_s_exception_r), 0, 0, 1, 0}, + {&__pyx_kp_s_s_r, __pyx_k_s_r, sizeof(__pyx_k_s_r), 0, 0, 1, 0}, + {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0}, + {&__pyx_kp_s_s_value_r_exception_r, __pyx_k_s_value_r_exception_r, sizeof(__pyx_k_s_value_r_exception_r), 0, 0, 1, 0}, + {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, + {&__pyx_n_s_servers, __pyx_k_servers, sizeof(__pyx_k_servers), 0, 0, 1, 1}, + {&__pyx_n_s_set_servers, __pyx_k_set_servers, sizeof(__pyx_k_set_servers), 0, 0, 1, 1}, + {&__pyx_n_s_sockaddr, __pyx_k_sockaddr, sizeof(__pyx_k_sockaddr), 0, 0, 1, 1}, + {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1}, + {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, + {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, + {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, + {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, + {&__pyx_n_s_tcp_port, __pyx_k_tcp_port, sizeof(__pyx_k_tcp_port), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_kp_s_this_ares_channel_has_been_destr, __pyx_k_this_ares_channel_has_been_destr, sizeof(__pyx_k_this_ares_channel_has_been_destr), 0, 0, 1, 0}, + {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1}, + {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1}, + {&__pyx_n_s_tries, __pyx_k_tries, sizeof(__pyx_k_tries), 0, 0, 1, 1}, + {&__pyx_n_s_udp_port, __pyx_k_udp_port, sizeof(__pyx_k_udp_port), 0, 0, 1, 1}, + {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1}, + {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, + {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, + {&__pyx_n_s_watcher, __pyx_k_watcher, sizeof(__pyx_k_watcher), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 330, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 436, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "gevent/ares.pyx":320 + * servers = [] + * if isinstance(servers, string_types): + * servers = servers.split(',') # <<<<<<<<<<<<<< + * cdef int length = len(servers) + * cdef int result, index + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s__2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "gevent/ares.pyx":335 + * for server in servers: + * if isinstance(server, unicode): + * server = server.encode('ascii') # <<<<<<<<<<<<<< + * string = <char*?>server + * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 335, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "gevent/ares.pyx":192 + * class ares_host_result(tuple): + * + * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family + */ + __pyx_tuple__6 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_family, __pyx_n_s_iterable, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_n_s_new, 192, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 192, __pyx_L1_error) + + /* "gevent/ares.pyx":197 + * return self + * + * def __getnewargs__(self): # <<<<<<<<<<<<<< + * return (self.family, tuple(self)) + * + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_n_s_getnewargs, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initares(void); /*proto*/ +PyMODINIT_FUNC initares(void) +#else +PyMODINIT_FUNC PyInit_ares(void); /*proto*/ +PyMODINIT_FUNC PyInit_ares(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + PyObject *__pyx_t_19 = NULL; + PyObject *__pyx_t_20 = NULL; + PyObject *__pyx_t_21 = NULL; + PyObject *__pyx_t_22 = NULL; + PyObject *__pyx_t_23 = NULL; + PyObject *__pyx_t_24 = NULL; + PyObject *__pyx_t_25 = NULL; + PyObject *__pyx_t_26 = NULL; + PyObject *__pyx_t_27 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ares(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("ares", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_gevent__ares) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "gevent.ares")) { + if (unlikely(PyDict_SetItemString(modules, "gevent.ares", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + __pyx_v_6gevent_4ares_string_types = Py_None; Py_INCREF(Py_None); + __pyx_v_6gevent_4ares_text_type = Py_None; Py_INCREF(Py_None); + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + if (PyType_Ready(&__pyx_type_6gevent_4ares_result) < 0) __PYX_ERR(0, 164, __pyx_L1_error) + __pyx_type_6gevent_4ares_result.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "result", (PyObject *)&__pyx_type_6gevent_4ares_result) < 0) __PYX_ERR(0, 164, __pyx_L1_error) + __pyx_ptype_6gevent_4ares_result = &__pyx_type_6gevent_4ares_result; + __pyx_vtabptr_6gevent_4ares_channel = &__pyx_vtable_6gevent_4ares_channel; + __pyx_vtable_6gevent_4ares_channel._sock_state_callback = (PyObject *(*)(struct PyGeventAresChannelObject *, int, int, int))__pyx_f_6gevent_4ares_7channel__sock_state_callback; + __pyx_vtable_6gevent_4ares_channel._getnameinfo = (PyObject *(*)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_6gevent_4ares_7channel__getnameinfo; + if (PyType_Ready(&PyGeventAresChannel_Type) < 0) __PYX_ERR(0, 245, __pyx_L1_error) + PyGeventAresChannel_Type.tp_print = 0; + if (__Pyx_SetVtable(PyGeventAresChannel_Type.tp_dict, __pyx_vtabptr_6gevent_4ares_channel) < 0) __PYX_ERR(0, 245, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "channel", (PyObject *)&PyGeventAresChannel_Type) < 0) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_ptype_6gevent_4ares_channel = &PyGeventAresChannel_Type; + /*--- Type import code ---*/ + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "gevent/ares.pyx":3 + * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. + * cimport cares + * import sys # <<<<<<<<<<<<<< + * from python cimport * + * from _socket import gaierror + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "gevent/ares.pyx":5 + * import sys + * from python cimport * + * from _socket import gaierror # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_gaierror); + __Pyx_GIVEREF(__pyx_n_s_gaierror); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gaierror); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_socket, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_gaierror, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":8 + * + * + * __all__ = ['channel'] # <<<<<<<<<<<<<< + * + * cdef object string_types + */ + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_channel); + __Pyx_GIVEREF(__pyx_n_s_channel); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_channel); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":13 + * cdef object text_type + * + * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< + * string_types = str, + * text_type = str + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_3) { + + /* "gevent/ares.pyx":14 + * + * if sys.version_info[0] >= 3: + * string_types = str, # <<<<<<<<<<<<<< + * text_type = str + * else: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)(&PyString_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyString_Type))); + __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types); + __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":15 + * if sys.version_info[0] >= 3: + * string_types = str, + * text_type = str # <<<<<<<<<<<<<< + * else: + * string_types = __builtins__.basestring, + */ + __Pyx_INCREF(((PyObject *)(&PyString_Type))); + __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type); + __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, ((PyObject *)(&PyString_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); + + /* "gevent/ares.pyx":13 + * cdef object text_type + * + * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<< + * string_types = str, + * text_type = str + */ + goto __pyx_L2; + } + + /* "gevent/ares.pyx":17 + * text_type = str + * else: + * string_types = __builtins__.basestring, # <<<<<<<<<<<<<< + * text_type = __builtins__.unicode + * + */ + /*else*/ { + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basestring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_2 = 0; + __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types); + __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "gevent/ares.pyx":18 + * else: + * string_types = __builtins__.basestring, + * text_type = __builtins__.unicode # <<<<<<<<<<<<<< + * + * TIMEOUT = 1 + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type); + __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + } + __pyx_L2:; + + /* "gevent/ares.pyx":20 + * text_type = __builtins__.unicode + * + * TIMEOUT = 1 # <<<<<<<<<<<<<< + * + * DEF EV_READ = 1 + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_int_1) < 0) __PYX_ERR(0, 20, __pyx_L1_error) + + /* "gevent/ares.pyx":58 + * + * + * ARES_SUCCESS = cares.ARES_SUCCESS # <<<<<<<<<<<<<< + * ARES_ENODATA = cares.ARES_ENODATA + * ARES_EFORMERR = cares.ARES_EFORMERR + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_SUCCESS, __pyx_t_2) < 0) __PYX_ERR(0, 58, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":59 + * + * ARES_SUCCESS = cares.ARES_SUCCESS + * ARES_ENODATA = cares.ARES_ENODATA # <<<<<<<<<<<<<< + * ARES_EFORMERR = cares.ARES_EFORMERR + * ARES_ESERVFAIL = cares.ARES_ESERVFAIL + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENODATA, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":60 + * ARES_SUCCESS = cares.ARES_SUCCESS + * ARES_ENODATA = cares.ARES_ENODATA + * ARES_EFORMERR = cares.ARES_EFORMERR # <<<<<<<<<<<<<< + * ARES_ESERVFAIL = cares.ARES_ESERVFAIL + * ARES_ENOTFOUND = cares.ARES_ENOTFOUND + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFORMERR, __pyx_t_2) < 0) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":61 + * ARES_ENODATA = cares.ARES_ENODATA + * ARES_EFORMERR = cares.ARES_EFORMERR + * ARES_ESERVFAIL = cares.ARES_ESERVFAIL # <<<<<<<<<<<<<< + * ARES_ENOTFOUND = cares.ARES_ENOTFOUND + * ARES_ENOTIMP = cares.ARES_ENOTIMP + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ESERVFAIL, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":62 + * ARES_EFORMERR = cares.ARES_EFORMERR + * ARES_ESERVFAIL = cares.ARES_ESERVFAIL + * ARES_ENOTFOUND = cares.ARES_ENOTFOUND # <<<<<<<<<<<<<< + * ARES_ENOTIMP = cares.ARES_ENOTIMP + * ARES_EREFUSED = cares.ARES_EREFUSED + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTFOUND, __pyx_t_2) < 0) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":63 + * ARES_ESERVFAIL = cares.ARES_ESERVFAIL + * ARES_ENOTFOUND = cares.ARES_ENOTFOUND + * ARES_ENOTIMP = cares.ARES_ENOTIMP # <<<<<<<<<<<<<< + * ARES_EREFUSED = cares.ARES_EREFUSED + * ARES_EBADQUERY = cares.ARES_EBADQUERY + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTIMP, __pyx_t_2) < 0) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":64 + * ARES_ENOTFOUND = cares.ARES_ENOTFOUND + * ARES_ENOTIMP = cares.ARES_ENOTIMP + * ARES_EREFUSED = cares.ARES_EREFUSED # <<<<<<<<<<<<<< + * ARES_EBADQUERY = cares.ARES_EBADQUERY + * ARES_EBADNAME = cares.ARES_EBADNAME + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":65 + * ARES_ENOTIMP = cares.ARES_ENOTIMP + * ARES_EREFUSED = cares.ARES_EREFUSED + * ARES_EBADQUERY = cares.ARES_EBADQUERY # <<<<<<<<<<<<<< + * ARES_EBADNAME = cares.ARES_EBADNAME + * ARES_EBADFAMILY = cares.ARES_EBADFAMILY + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADQUERY, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":66 + * ARES_EREFUSED = cares.ARES_EREFUSED + * ARES_EBADQUERY = cares.ARES_EBADQUERY + * ARES_EBADNAME = cares.ARES_EBADNAME # <<<<<<<<<<<<<< + * ARES_EBADFAMILY = cares.ARES_EBADFAMILY + * ARES_EBADRESP = cares.ARES_EBADRESP + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADNAME, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":67 + * ARES_EBADQUERY = cares.ARES_EBADQUERY + * ARES_EBADNAME = cares.ARES_EBADNAME + * ARES_EBADFAMILY = cares.ARES_EBADFAMILY # <<<<<<<<<<<<<< + * ARES_EBADRESP = cares.ARES_EBADRESP + * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFAMILY, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":68 + * ARES_EBADNAME = cares.ARES_EBADNAME + * ARES_EBADFAMILY = cares.ARES_EBADFAMILY + * ARES_EBADRESP = cares.ARES_EBADRESP # <<<<<<<<<<<<<< + * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED + * ARES_ETIMEOUT = cares.ARES_ETIMEOUT + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADRESP, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":69 + * ARES_EBADFAMILY = cares.ARES_EBADFAMILY + * ARES_EBADRESP = cares.ARES_EBADRESP + * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED # <<<<<<<<<<<<<< + * ARES_ETIMEOUT = cares.ARES_ETIMEOUT + * ARES_EOF = cares.ARES_EOF + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECONNREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":70 + * ARES_EBADRESP = cares.ARES_EBADRESP + * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED + * ARES_ETIMEOUT = cares.ARES_ETIMEOUT # <<<<<<<<<<<<<< + * ARES_EOF = cares.ARES_EOF + * ARES_EFILE = cares.ARES_EFILE + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ETIMEOUT, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":71 + * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED + * ARES_ETIMEOUT = cares.ARES_ETIMEOUT + * ARES_EOF = cares.ARES_EOF # <<<<<<<<<<<<<< + * ARES_EFILE = cares.ARES_EFILE + * ARES_ENOMEM = cares.ARES_ENOMEM + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EOF, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":72 + * ARES_ETIMEOUT = cares.ARES_ETIMEOUT + * ARES_EOF = cares.ARES_EOF + * ARES_EFILE = cares.ARES_EFILE # <<<<<<<<<<<<<< + * ARES_ENOMEM = cares.ARES_ENOMEM + * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFILE, __pyx_t_2) < 0) __PYX_ERR(0, 72, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":73 + * ARES_EOF = cares.ARES_EOF + * ARES_EFILE = cares.ARES_EFILE + * ARES_ENOMEM = cares.ARES_ENOMEM # <<<<<<<<<<<<<< + * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION + * ARES_EBADSTR = cares.ARES_EBADSTR + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOMEM, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":74 + * ARES_EFILE = cares.ARES_EFILE + * ARES_ENOMEM = cares.ARES_ENOMEM + * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION # <<<<<<<<<<<<<< + * ARES_EBADSTR = cares.ARES_EBADSTR + * ARES_EBADFLAGS = cares.ARES_EBADFLAGS + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EDESTRUCTION, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":75 + * ARES_ENOMEM = cares.ARES_ENOMEM + * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION + * ARES_EBADSTR = cares.ARES_EBADSTR # <<<<<<<<<<<<<< + * ARES_EBADFLAGS = cares.ARES_EBADFLAGS + * ARES_ENONAME = cares.ARES_ENONAME + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADSTR, __pyx_t_2) < 0) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":76 + * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION + * ARES_EBADSTR = cares.ARES_EBADSTR + * ARES_EBADFLAGS = cares.ARES_EBADFLAGS # <<<<<<<<<<<<<< + * ARES_ENONAME = cares.ARES_ENONAME + * ARES_EBADHINTS = cares.ARES_EBADHINTS + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFLAGS, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":77 + * ARES_EBADSTR = cares.ARES_EBADSTR + * ARES_EBADFLAGS = cares.ARES_EBADFLAGS + * ARES_ENONAME = cares.ARES_ENONAME # <<<<<<<<<<<<<< + * ARES_EBADHINTS = cares.ARES_EBADHINTS + * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENONAME, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":78 + * ARES_EBADFLAGS = cares.ARES_EBADFLAGS + * ARES_ENONAME = cares.ARES_ENONAME + * ARES_EBADHINTS = cares.ARES_EBADHINTS # <<<<<<<<<<<<<< + * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED + * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADHINTS, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":79 + * ARES_ENONAME = cares.ARES_ENONAME + * ARES_EBADHINTS = cares.ARES_EBADHINTS + * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED # <<<<<<<<<<<<<< + * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI + * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTINITIALIZED, __pyx_t_2) < 0) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":80 + * ARES_EBADHINTS = cares.ARES_EBADHINTS + * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED + * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI # <<<<<<<<<<<<<< + * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS + * ARES_ECANCELLED = cares.ARES_ECANCELLED + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_t_2) < 0) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":81 + * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED + * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI + * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS # <<<<<<<<<<<<<< + * ARES_ECANCELLED = cares.ARES_ECANCELLED + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":82 + * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI + * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS + * ARES_ECANCELLED = cares.ARES_ECANCELLED # <<<<<<<<<<<<<< + * + * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECANCELLED, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":84 + * ARES_ECANCELLED = cares.ARES_ECANCELLED + * + * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC # <<<<<<<<<<<<<< + * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY + * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_USEVC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_USEVC, __pyx_t_2) < 0) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":85 + * + * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC + * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY # <<<<<<<<<<<<<< + * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC + * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_PRIMARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_PRIMARY, __pyx_t_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":86 + * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC + * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY + * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC # <<<<<<<<<<<<<< + * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE + * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_IGNTC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_IGNTC, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":87 + * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY + * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC + * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE # <<<<<<<<<<<<<< + * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN + * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NORECURSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NORECURSE, __pyx_t_2) < 0) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":88 + * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC + * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE + * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN # <<<<<<<<<<<<<< + * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH + * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_STAYOPEN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":89 + * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE + * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN + * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH # <<<<<<<<<<<<<< + * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES + * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOSEARCH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":90 + * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN + * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH + * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES # <<<<<<<<<<<<<< + * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOALIASES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOALIASES, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":91 + * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH + * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES + * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOCHECKRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":95 + * + * _ares_errors = dict([ + * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), # <<<<<<<<<<<<<< + * (cares.ARES_ENODATA, 'ARES_ENODATA'), + * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_SUCCESS); + __Pyx_GIVEREF(__pyx_n_s_ARES_SUCCESS); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ARES_SUCCESS); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":96 + * _ares_errors = dict([ + * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), + * (cares.ARES_ENODATA, 'ARES_ENODATA'), # <<<<<<<<<<<<<< + * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), + * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENODATA); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENODATA); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_ARES_ENODATA); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":97 + * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), + * (cares.ARES_ENODATA, 'ARES_ENODATA'), + * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), # <<<<<<<<<<<<<< + * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), + * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EFORMERR); + __Pyx_GIVEREF(__pyx_n_s_ARES_EFORMERR); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_ARES_EFORMERR); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":98 + * (cares.ARES_ENODATA, 'ARES_ENODATA'), + * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), + * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), # <<<<<<<<<<<<<< + * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), + * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ESERVFAIL); + __Pyx_GIVEREF(__pyx_n_s_ARES_ESERVFAIL); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_ARES_ESERVFAIL); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":99 + * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), + * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), + * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), # <<<<<<<<<<<<<< + * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), + * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 99, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENOTFOUND); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTFOUND); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ARES_ENOTFOUND); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":100 + * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), + * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), + * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), # <<<<<<<<<<<<<< + * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), + * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 100, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENOTIMP); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTIMP); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_ARES_ENOTIMP); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":101 + * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), + * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), + * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), + * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EREFUSED); + __Pyx_GIVEREF(__pyx_n_s_ARES_EREFUSED); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_ARES_EREFUSED); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":102 + * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), + * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), + * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), + * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADQUERY); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADQUERY); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_ARES_EBADQUERY); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":103 + * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), + * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), + * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), + * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADNAME); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADNAME); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_ARES_EBADNAME); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":104 + * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), + * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), + * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), + * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADFAMILY); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFAMILY); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_ARES_EBADFAMILY); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":105 + * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), + * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), + * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), # <<<<<<<<<<<<<< + * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), + * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 105, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADRESP); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADRESP); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_ARES_EBADRESP); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":106 + * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), + * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), + * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), # <<<<<<<<<<<<<< + * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), + * (cares.ARES_EOF, 'ARES_EOF'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ECONNREFUSED); + __Pyx_GIVEREF(__pyx_n_s_ARES_ECONNREFUSED); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_ARES_ECONNREFUSED); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":107 + * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), + * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), + * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), # <<<<<<<<<<<<<< + * (cares.ARES_EOF, 'ARES_EOF'), + * (cares.ARES_EFILE, 'ARES_EFILE'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 107, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ETIMEOUT); + __Pyx_GIVEREF(__pyx_n_s_ARES_ETIMEOUT); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_ARES_ETIMEOUT); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":108 + * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), + * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), + * (cares.ARES_EOF, 'ARES_EOF'), # <<<<<<<<<<<<<< + * (cares.ARES_EFILE, 'ARES_EFILE'), + * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EOF); + __Pyx_GIVEREF(__pyx_n_s_ARES_EOF); + PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ARES_EOF); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":109 + * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), + * (cares.ARES_EOF, 'ARES_EOF'), + * (cares.ARES_EFILE, 'ARES_EFILE'), # <<<<<<<<<<<<<< + * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), + * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_17); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EFILE); + __Pyx_GIVEREF(__pyx_n_s_ARES_EFILE); + PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_ARES_EFILE); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":110 + * (cares.ARES_EOF, 'ARES_EOF'), + * (cares.ARES_EFILE, 'ARES_EFILE'), + * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), # <<<<<<<<<<<<<< + * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), + * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_18); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENOMEM); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENOMEM); + PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ARES_ENOMEM); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":111 + * (cares.ARES_EFILE, 'ARES_EFILE'), + * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), + * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), + * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_19); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EDESTRUCTION); + __Pyx_GIVEREF(__pyx_n_s_ARES_EDESTRUCTION); + PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_n_s_ARES_EDESTRUCTION); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":112 + * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), + * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), + * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), + * (cares.ARES_ENONAME, 'ARES_ENONAME'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_20); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADSTR); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADSTR); + PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_n_s_ARES_EBADSTR); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":113 + * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), + * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), + * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), # <<<<<<<<<<<<<< + * (cares.ARES_ENONAME, 'ARES_ENONAME'), + * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_21); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADFLAGS); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFLAGS); + PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_n_s_ARES_EBADFLAGS); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":114 + * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), + * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), + * (cares.ARES_ENONAME, 'ARES_ENONAME'), # <<<<<<<<<<<<<< + * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), + * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_22); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENONAME); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENONAME); + PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_n_s_ARES_ENONAME); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":115 + * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), + * (cares.ARES_ENONAME, 'ARES_ENONAME'), + * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), # <<<<<<<<<<<<<< + * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), + * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_23); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EBADHINTS); + __Pyx_GIVEREF(__pyx_n_s_ARES_EBADHINTS); + PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_n_s_ARES_EBADHINTS); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":116 + * (cares.ARES_ENONAME, 'ARES_ENONAME'), + * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), + * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), # <<<<<<<<<<<<<< + * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), + * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_24); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ENOTINITIALIZED); + __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTINITIALIZED); + PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_n_s_ARES_ENOTINITIALIZED); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":117 + * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), + * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), + * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), # <<<<<<<<<<<<<< + * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), + * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_25); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ELOADIPHLPAPI); + __Pyx_GIVEREF(__pyx_n_s_ARES_ELOADIPHLPAPI); + PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_n_s_ARES_ELOADIPHLPAPI); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":118 + * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), + * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), + * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), # <<<<<<<<<<<<<< + * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_26 = PyTuple_New(2); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_26); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS); + __Pyx_GIVEREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS); + PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":119 + * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), + * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), + * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_27); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ARES_ECANCELLED); + __Pyx_GIVEREF(__pyx_n_s_ARES_ECANCELLED); + PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_n_s_ARES_ECANCELLED); + __pyx_t_2 = 0; + + /* "gevent/ares.pyx":94 + * + * + * _ares_errors = dict([ # <<<<<<<<<<<<<< + * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), + * (cares.ARES_ENODATA, 'ARES_ENODATA'), + */ + __pyx_t_2 = PyList_New(25); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_9); + PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_10); + PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_13); + PyList_SET_ITEM(__pyx_t_2, 10, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_14); + PyList_SET_ITEM(__pyx_t_2, 11, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_15); + PyList_SET_ITEM(__pyx_t_2, 12, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_16); + PyList_SET_ITEM(__pyx_t_2, 13, __pyx_t_16); + __Pyx_GIVEREF(__pyx_t_17); + PyList_SET_ITEM(__pyx_t_2, 14, __pyx_t_17); + __Pyx_GIVEREF(__pyx_t_18); + PyList_SET_ITEM(__pyx_t_2, 15, __pyx_t_18); + __Pyx_GIVEREF(__pyx_t_19); + PyList_SET_ITEM(__pyx_t_2, 16, __pyx_t_19); + __Pyx_GIVEREF(__pyx_t_20); + PyList_SET_ITEM(__pyx_t_2, 17, __pyx_t_20); + __Pyx_GIVEREF(__pyx_t_21); + PyList_SET_ITEM(__pyx_t_2, 18, __pyx_t_21); + __Pyx_GIVEREF(__pyx_t_22); + PyList_SET_ITEM(__pyx_t_2, 19, __pyx_t_22); + __Pyx_GIVEREF(__pyx_t_23); + PyList_SET_ITEM(__pyx_t_2, 20, __pyx_t_23); + __Pyx_GIVEREF(__pyx_t_24); + PyList_SET_ITEM(__pyx_t_2, 21, __pyx_t_24); + __Pyx_GIVEREF(__pyx_t_25); + PyList_SET_ITEM(__pyx_t_2, 22, __pyx_t_25); + __Pyx_GIVEREF(__pyx_t_26); + PyList_SET_ITEM(__pyx_t_2, 23, __pyx_t_26); + __Pyx_GIVEREF(__pyx_t_27); + PyList_SET_ITEM(__pyx_t_2, 24, __pyx_t_27); + __pyx_t_1 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_8 = 0; + __pyx_t_9 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_12 = 0; + __pyx_t_13 = 0; + __pyx_t_14 = 0; + __pyx_t_15 = 0; + __pyx_t_16 = 0; + __pyx_t_17 = 0; + __pyx_t_18 = 0; + __pyx_t_19 = 0; + __pyx_t_20 = 0; + __pyx_t_21 = 0; + __pyx_t_22 = 0; + __pyx_t_23 = 0; + __pyx_t_24 = 0; + __pyx_t_25 = 0; + __pyx_t_26 = 0; + __pyx_t_27 = 0; + __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_27); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_27, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_errors, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":123 + * + * # maps c-ares flag to _socket module flag + * _cares_flag_map = None # <<<<<<<<<<<<<< + * + * + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, Py_None) < 0) __PYX_ERR(0, 123, __pyx_L1_error) + + /* "gevent/ares.pyx":137 + * + * + * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<< + * if _cares_flag_map is None: + * _prepare_cares_flag_map() + */ + __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE); + __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE); + + /* "gevent/ares.pyx":153 + * + * + * class InvalidIP(ValueError): # <<<<<<<<<<<<<< + * pass + * + */ + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_builtin_ValueError); + __Pyx_GIVEREF(__pyx_builtin_ValueError); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_ValueError); + __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_27); + __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_InvalidIP, __pyx_n_s_InvalidIP, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_26); + __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_InvalidIP, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_25); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidIP, __pyx_t_25) < 0) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; + __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":190 + * + * + * class ares_host_result(tuple): # <<<<<<<<<<<<<< + * + * def __new__(cls, family, iterable): + */ + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)(&PyTuple_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type))); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyTuple_Type))); + __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_27); + __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_ares_host_result, __pyx_n_s_ares_host_result, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_26); + + /* "gevent/ares.pyx":192 + * class ares_host_result(tuple): + * + * def __new__(cls, family, iterable): # <<<<<<<<<<<<<< + * cdef object self = tuple.__new__(cls, iterable) + * self.family = family + */ + __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ares_host_result___new, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_25); + if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_new, __pyx_t_25) < 0) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; + + /* "gevent/ares.pyx":197 + * return self + * + * def __getnewargs__(self): # <<<<<<<<<<<<<< + * return (self.family, tuple(self)) + * + */ + __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__, 0, __pyx_n_s_ares_host_result___getnewargs, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_25); + if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_getnewargs, __pyx_t_25) < 0) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; + + /* "gevent/ares.pyx":190 + * + * + * class ares_host_result(tuple): # <<<<<<<<<<<<<< + * + * def __new__(cls, family, iterable): + */ + __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_ares_host_result, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_25); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_host_result, __pyx_t_25) < 0) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; + __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "gevent/ares.pyx":400 + * cares.ares_process_fd(self.channel, read_fd, write_fd) + * + * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<< + * if not self.channel: + * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') + */ + __pyx_k__5 = AF_INET; + + /* "gevent/ares.pyx":1 + * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<< + * cimport cares + * import sys + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_16); + __Pyx_XDECREF(__pyx_t_17); + __Pyx_XDECREF(__pyx_t_18); + __Pyx_XDECREF(__pyx_t_19); + __Pyx_XDECREF(__pyx_t_20); + __Pyx_XDECREF(__pyx_t_21); + __Pyx_XDECREF(__pyx_t_22); + __Pyx_XDECREF(__pyx_t_23); + __Pyx_XDECREF(__pyx_t_24); + __Pyx_XDECREF(__pyx_t_25); + __Pyx_XDECREF(__pyx_t_26); + __Pyx_XDECREF(__pyx_t_27); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init gevent.ares", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init gevent.ares"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* Import */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* GetAttr */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { +#if CYTHON_COMPILING_IN_CPYTHON +#if PY_MAJOR_VERSION >= 3 + if (likely(PyUnicode_Check(n))) +#else + if (likely(PyString_Check(n))) +#endif + return __Pyx_PyObject_GetAttrStr(o, n); +#endif + return PyObject_GetAttr(o, n); +} + +/* GetAttr3 */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + goto bad; + PyErr_Clear(); + r = d; + Py_INCREF(d); + } + return r; +bad: + return NULL; +} + +/* GetModuleGlobalName */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* IterFinish */ + static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +/* UnpackItemEndCheck */ + static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif // CPython < 3.6 +#endif // CYTHON_FAST_PYCALL + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); +} +#endif // CYTHON_FAST_PYCCALL + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyErrFetchRestore */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* RaiseDoubleKeywords */ + static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ + static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* RaiseArgTupleInvalid */ + static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* RaiseNoneIterError */ + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* GetItemInt */ + static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* pyobject_as_double */ + static double __Pyx__PyObject_AsDouble(PyObject* obj) { + PyObject* float_value; +#if !CYTHON_USE_TYPE_SLOTS + float_value = PyNumber_Float(obj); if (0) goto bad; +#else + PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; + if (likely(nb) && likely(nb->nb_float)) { + float_value = nb->nb_float(obj); + if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { + PyErr_Format(PyExc_TypeError, + "__float__ returned non-float (type %.200s)", + Py_TYPE(float_value)->tp_name); + Py_DECREF(float_value); + goto bad; + } + } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { +#if PY_MAJOR_VERSION >= 3 + float_value = PyFloat_FromString(obj); +#else + float_value = PyFloat_FromString(obj, 0); +#endif + } else { + PyObject* args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + PyTuple_SET_ITEM(args, 0, obj); + float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); + PyTuple_SET_ITEM(args, 0, 0); + Py_DECREF(args); + } +#endif + if (likely(float_value)) { + double value = PyFloat_AS_DOUBLE(float_value); + Py_DECREF(float_value); + return value; + } +bad: + return (double)-1; +} + +/* SwapException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* dict_getitem_default */ + static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { + PyObject* value; +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (unlikely(PyErr_Occurred())) + return NULL; + value = default_value; + } + Py_INCREF(value); +#else + if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { + value = PyDict_GetItem(d, key); + if (unlikely(!value)) { + value = default_value; + } + Py_INCREF(value); + } else { + if (default_value == Py_None) + default_value = NULL; + value = PyObject_CallMethodObjArgs( + d, __pyx_n_s_get, key, default_value, NULL); + } +#endif + return value; +} + +/* ArgTypeTest */ + static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; + } + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; +} + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + return PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* SetVTable */ + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* ImportFrom */ + static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* CalculateMetaclass */ + static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { + Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); + for (i=0; i < nbases; i++) { + PyTypeObject *tmptype; + PyObject *tmp = PyTuple_GET_ITEM(bases, i); + tmptype = Py_TYPE(tmp); +#if PY_MAJOR_VERSION < 3 + if (tmptype == &PyClass_Type) + continue; +#endif + if (!metaclass) { + metaclass = tmptype; + continue; + } + if (PyType_IsSubtype(metaclass, tmptype)) + continue; + if (PyType_IsSubtype(tmptype, metaclass)) { + metaclass = tmptype; + continue; + } + PyErr_SetString(PyExc_TypeError, + "metaclass conflict: " + "the metaclass of a derived class " + "must be a (non-strict) subclass " + "of the metaclasses of all its bases"); + return NULL; + } + if (!metaclass) { +#if PY_MAJOR_VERSION < 3 + metaclass = &PyClass_Type; +#else + metaclass = &PyType_Type; +#endif + } + Py_INCREF((PyObject*) metaclass); + return (PyObject*) metaclass; +} + +/* Py3ClassCreate */ + static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, + PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { + PyObject *ns; + if (metaclass) { + PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); + if (prep) { + PyObject *pargs = PyTuple_Pack(2, name, bases); + if (unlikely(!pargs)) { + Py_DECREF(prep); + return NULL; + } + ns = PyObject_Call(prep, pargs, mkw); + Py_DECREF(prep); + Py_DECREF(pargs); + } else { + if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + PyErr_Clear(); + ns = PyDict_New(); + } + } else { + ns = PyDict_New(); + } + if (unlikely(!ns)) + return NULL; + if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; + if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; + if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; + return ns; +bad: + Py_DECREF(ns); + return NULL; +} +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, + PyObject *dict, PyObject *mkw, + int calculate_metaclass, int allow_py2_metaclass) { + PyObject *result, *margs; + PyObject *owned_metaclass = NULL; + if (allow_py2_metaclass) { + owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); + if (owned_metaclass) { + metaclass = owned_metaclass; + } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { + PyErr_Clear(); + } else { + return NULL; + } + } + if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { + metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); + Py_XDECREF(owned_metaclass); + if (unlikely(!metaclass)) + return NULL; + owned_metaclass = metaclass; + } + margs = PyTuple_Pack(3, name, bases, dict); + if (unlikely(!margs)) { + result = NULL; + } else { + result = PyObject_Call(metaclass, margs, mkw); + Py_DECREF(margs); + } + Py_XDECREF(owned_metaclass); + return result; +} + +/* FetchCommonType */ + static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } +done: + Py_DECREF(fake_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + +/* CythonFunction */ + static PyObject * +__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) +{ + if (unlikely(op->func_doc == NULL)) { + if (op->func.m_ml->ml_doc) { +#if PY_MAJOR_VERSION >= 3 + op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); +#else + op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); +#endif + if (unlikely(op->func_doc == NULL)) + return NULL; + } else { + Py_INCREF(Py_None); + return Py_None; + } + } + Py_INCREF(op->func_doc); + return op->func_doc; +} +static int +__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp = op->func_doc; + if (value == NULL) { + value = Py_None; + } + Py_INCREF(value); + op->func_doc = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) +{ + if (unlikely(op->func_name == NULL)) { +#if PY_MAJOR_VERSION >= 3 + op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); +#else + op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); +#endif + if (unlikely(op->func_name == NULL)) + return NULL; + } + Py_INCREF(op->func_name); + return op->func_name; +} +static int +__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) +{ + Py_INCREF(op->func_qualname); + return op->func_qualname; +} +static int +__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = op->func_qualname; + Py_INCREF(value); + op->func_qualname = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) +{ + PyObject *self; + self = m->func_closure; + if (self == NULL) + self = Py_None; + Py_INCREF(self); + return self; +} +static PyObject * +__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) +{ + if (unlikely(op->func_dict == NULL)) { + op->func_dict = PyDict_New(); + if (unlikely(op->func_dict == NULL)) + return NULL; + } + Py_INCREF(op->func_dict); + return op->func_dict; +} +static int +__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; + if (unlikely(value == NULL)) { + PyErr_SetString(PyExc_TypeError, + "function's dictionary may not be deleted"); + return -1; + } + if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "setting function's dictionary to a non-dict"); + return -1; + } + tmp = op->func_dict; + Py_INCREF(value); + op->func_dict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) +{ + Py_INCREF(op->func_globals); + return op->func_globals; +} +static PyObject * +__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) +{ + Py_INCREF(Py_None); + return Py_None; +} +static PyObject * +__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) +{ + PyObject* result = (op->func_code) ? op->func_code : Py_None; + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { + int result = 0; + PyObject *res = op->defaults_getter((PyObject *) op); + if (unlikely(!res)) + return -1; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + op->defaults_tuple = PyTuple_GET_ITEM(res, 0); + Py_INCREF(op->defaults_tuple); + op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); + Py_INCREF(op->defaults_kwdict); + #else + op->defaults_tuple = PySequence_ITEM(res, 0); + if (unlikely(!op->defaults_tuple)) result = -1; + else { + op->defaults_kwdict = PySequence_ITEM(res, 1); + if (unlikely(!op->defaults_kwdict)) result = -1; + } + #endif + Py_DECREF(res); + return result; +} +static int +__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyTuple_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__defaults__ must be set to a tuple object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_tuple; + op->defaults_tuple = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { + PyObject* result = op->defaults_tuple; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_tuple; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__kwdefaults__ must be set to a dict object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_kwdict; + op->defaults_kwdict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { + PyObject* result = op->defaults_kwdict; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_kwdict; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { + PyObject* tmp; + if (!value || value == Py_None) { + value = NULL; + } else if (!PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__annotations__ must be set to a dict object"); + return -1; + } + Py_XINCREF(value); + tmp = op->func_annotations; + op->func_annotations = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { + PyObject* result = op->func_annotations; + if (unlikely(!result)) { + result = PyDict_New(); + if (unlikely(!result)) return NULL; + op->func_annotations = result; + } + Py_INCREF(result); + return result; +} +static PyGetSetDef __pyx_CyFunction_getsets[] = { + {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, + {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, + {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, + {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, + {0, 0, 0, 0, 0} +}; +static PyMemberDef __pyx_CyFunction_members[] = { + {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, + {0, 0, 0, 0, 0} +}; +static PyObject * +__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromString(m->func.m_ml->ml_name); +#else + return PyString_FromString(m->func.m_ml->ml_name); +#endif +} +static PyMethodDef __pyx_CyFunction_methods[] = { + {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, + {0, 0, 0, 0} +}; +#if PY_VERSION_HEX < 0x030500A0 +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) +#else +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) +#endif +static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); + if (op == NULL) + return NULL; + op->flags = flags; + __Pyx_CyFunction_weakreflist(op) = NULL; + op->func.m_ml = ml; + op->func.m_self = (PyObject *) op; + Py_XINCREF(closure); + op->func_closure = closure; + Py_XINCREF(module); + op->func.m_module = module; + op->func_dict = NULL; + op->func_name = NULL; + Py_INCREF(qualname); + op->func_qualname = qualname; + op->func_doc = NULL; + op->func_classobj = NULL; + op->func_globals = globals; + Py_INCREF(op->func_globals); + Py_XINCREF(code); + op->func_code = code; + op->defaults_pyobjects = 0; + op->defaults = NULL; + op->defaults_tuple = NULL; + op->defaults_kwdict = NULL; + op->defaults_getter = NULL; + op->func_annotations = NULL; + PyObject_GC_Track(op); + return (PyObject *) op; +} +static int +__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) +{ + Py_CLEAR(m->func_closure); + Py_CLEAR(m->func.m_module); + Py_CLEAR(m->func_dict); + Py_CLEAR(m->func_name); + Py_CLEAR(m->func_qualname); + Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); + Py_CLEAR(m->func_code); + Py_CLEAR(m->func_classobj); + Py_CLEAR(m->defaults_tuple); + Py_CLEAR(m->defaults_kwdict); + Py_CLEAR(m->func_annotations); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_XDECREF(pydefaults[i]); + PyObject_Free(m->defaults); + m->defaults = NULL; + } + return 0; +} +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + if (__Pyx_CyFunction_weakreflist(m) != NULL) + PyObject_ClearWeakRefs((PyObject *) m); + __Pyx_CyFunction_clear(m); + PyObject_GC_Del(m); +} +static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) +{ + Py_VISIT(m->func_closure); + Py_VISIT(m->func.m_module); + Py_VISIT(m->func_dict); + Py_VISIT(m->func_name); + Py_VISIT(m->func_qualname); + Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); + Py_VISIT(m->func_code); + Py_VISIT(m->func_classobj); + Py_VISIT(m->defaults_tuple); + Py_VISIT(m->defaults_kwdict); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_VISIT(pydefaults[i]); + } + return 0; +} +static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { + Py_INCREF(func); + return func; + } + if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { + if (type == NULL) + type = (PyObject *)(Py_TYPE(obj)); + return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); + } + if (obj == Py_None) + obj = NULL; + return __Pyx_PyMethod_New(func, obj, type); +} +static PyObject* +__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromFormat("<cyfunction %U at %p>", + op->func_qualname, (void *)op); +#else + return PyString_FromFormat("<cyfunction %s at %p>", + PyString_AsString(op->func_qualname), (void *)op); +#endif +} +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = f->m_ml->ml_meth; + Py_ssize_t size; + switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + case METH_VARARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 0)) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 1)) { + PyObject *result, *arg0 = PySequence_ITEM(arg, 0); + if (unlikely(!arg0)) return NULL; + result = (*meth)(self, arg0); + Py_DECREF(arg0); + return result; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags in " + "__Pyx_CyFunction_Call. METH_OLDARGS is no " + "longer supported!"); + return NULL; + } + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; +} +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; +} +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + "cython_function_or_method", + sizeof(__pyx_CyFunctionObject), + 0, + (destructor) __Pyx_CyFunction_dealloc, + 0, + 0, + 0, +#if PY_MAJOR_VERSION < 3 + 0, +#else + 0, +#endif + (reprfunc) __Pyx_CyFunction_repr, + 0, + 0, + 0, + 0, + __Pyx_CyFunction_CallAsMethod, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + 0, + (traverseproc) __Pyx_CyFunction_traverse, + (inquiry) __Pyx_CyFunction_clear, + 0, +#if PY_VERSION_HEX < 0x030500A0 + offsetof(__pyx_CyFunctionObject, func_weakreflist), +#else + offsetof(PyCFunctionObject, m_weakreflist), +#endif + 0, + 0, + __pyx_CyFunction_methods, + __pyx_CyFunction_members, + __pyx_CyFunction_getsets, + 0, + 0, + __Pyx_CyFunction_descr_get, + 0, + offsetof(__pyx_CyFunctionObject, func_dict), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +}; +static int __pyx_CyFunction_init(void) { + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); + if (__pyx_CyFunctionType == NULL) { + return -1; + } + return 0; +} +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults = PyObject_Malloc(size); + if (!m->defaults) + return PyErr_NoMemory(); + memset(m->defaults, 0, size); + m->defaults_pyobjects = pyobjects; + return m->defaults; +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_kwdict = dict; + Py_INCREF(dict); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->func_annotations = dict; + Py_INCREF(dict); +} + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *x) { + const unsigned short neg_one = (unsigned short) -1, const_zero = (unsigned short) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(unsigned short) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(unsigned short, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (unsigned short) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned short) 0; + case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, digits[0]) + case 2: + if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) >= 2 * PyLong_SHIFT) { + return (unsigned short) (((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) >= 3 * PyLong_SHIFT) { + return (unsigned short) (((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) >= 4 * PyLong_SHIFT) { + return (unsigned short) (((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned short) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(unsigned short) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned short) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned short) 0; + case -1: __PYX_VERIFY_RETURN_INT(unsigned short, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, +digits[0]) + case -2: + if (8 * sizeof(unsigned short) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { + return (unsigned short) (((unsigned short)-1)*(((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { + return (unsigned short) ((((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { + return (unsigned short) (((unsigned short)-1)*(((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { + return (unsigned short) ((((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) { + return (unsigned short) (((unsigned short)-1)*(((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) { + return (unsigned short) ((((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]))); + } + } + break; + } +#endif + if (sizeof(unsigned short) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned short, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned short) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned short, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + unsigned short val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (unsigned short) -1; + } + } else { + unsigned short val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (unsigned short) -1; + val = __Pyx_PyInt_As_unsigned_short(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned short"); + return (unsigned short) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned short"); + return (unsigned short) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +#endif + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } + #else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } + #endif +#else + res = PyNumber_Int(x); +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/python/gevent/gevent.ares.h b/python/gevent/gevent.ares.h new file mode 100644 index 0000000..25ba041 --- /dev/null +++ b/python/gevent/gevent.ares.h @@ -0,0 +1,48 @@ +/* Generated by Cython 0.25.2 */ + +#ifndef __PYX_HAVE__gevent__ares +#define __PYX_HAVE__gevent__ares + +struct PyGeventAresChannelObject; + +/* "gevent/ares.pyx":245 + * + * + * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: # <<<<<<<<<<<<<< + * + * cdef public object loop + */ +struct PyGeventAresChannelObject { + PyObject_HEAD + struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtab; + PyObject *loop; + struct ares_channeldata *channel; + PyObject *_watchers; + PyObject *_timer; +}; + +#ifndef __PYX_HAVE_API__gevent__ares + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#ifndef DL_IMPORT + #define DL_IMPORT(_T) _T +#endif + +__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyGeventAresChannel_Type; + +#endif /* !__PYX_HAVE_API__gevent__ares */ + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initares(void); +#else +PyMODINIT_FUNC PyInit_ares(void); +#endif + +#endif /* !__PYX_HAVE__gevent__ares */ diff --git a/python/gevent/greenlet.py b/python/gevent/greenlet.py new file mode 100644 index 0000000..1378dd7 --- /dev/null +++ b/python/gevent/greenlet.py @@ -0,0 +1,744 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +from __future__ import absolute_import +import sys +from greenlet import greenlet +from gevent._compat import PY3 +from gevent._compat import PYPY +from gevent._compat import reraise +from gevent._util import Lazy +from gevent._tblib import dump_traceback +from gevent._tblib import load_traceback +from gevent.hub import GreenletExit +from gevent.hub import InvalidSwitchError +from gevent.hub import Waiter +from gevent.hub import get_hub +from gevent.hub import getcurrent +from gevent.hub import iwait +from gevent.hub import wait +from gevent.timeout import Timeout +from collections import deque + + +__all__ = [ + 'Greenlet', + 'joinall', + 'killall', +] + + +if PYPY: + import _continuation # pylint:disable=import-error + _continulet = _continuation.continulet + + +class SpawnedLink(object): + """A wrapper around link that calls it in another greenlet. + + Can be called only from main loop. + """ + __slots__ = ['callback'] + + def __init__(self, callback): + if not callable(callback): + raise TypeError("Expected callable: %r" % (callback, )) + self.callback = callback + + def __call__(self, source): + g = greenlet(self.callback, get_hub()) + g.switch(source) + + def __hash__(self): + return hash(self.callback) + + def __eq__(self, other): + return self.callback == getattr(other, 'callback', other) + + def __str__(self): + return str(self.callback) + + def __repr__(self): + return repr(self.callback) + + def __getattr__(self, item): + assert item != 'callback' + return getattr(self.callback, item) + + +class SuccessSpawnedLink(SpawnedLink): + """A wrapper around link that calls it in another greenlet only if source succeed. + + Can be called only from main loop. + """ + __slots__ = [] + + def __call__(self, source): + if source.successful(): + return SpawnedLink.__call__(self, source) + + +class FailureSpawnedLink(SpawnedLink): + """A wrapper around link that calls it in another greenlet only if source failed. + + Can be called only from main loop. + """ + __slots__ = [] + + def __call__(self, source): + if not source.successful(): + return SpawnedLink.__call__(self, source) + +class Greenlet(greenlet): + """A light-weight cooperatively-scheduled execution unit. + """ + # pylint:disable=too-many-public-methods,too-many-instance-attributes + + value = None + _exc_info = () + _notifier = None + + #: An event, such as a timer or a callback that fires. It is established in + #: start() and start_later() as those two objects, respectively. + #: Once this becomes non-None, the Greenlet cannot be started again. Conversely, + #: kill() and throw() check for non-None to determine if this object has ever been + #: scheduled for starting. A placeholder _dummy_event is assigned by them to prevent + #: the greenlet from being started in the future, if necessary. + _start_event = None + args = () + _kwargs = None + + def __init__(self, run=None, *args, **kwargs): + """ + Greenlet constructor. + + :param args: The arguments passed to the ``run`` function. + :param kwargs: The keyword arguments passed to the ``run`` function. + :keyword run: The callable object to run. If not given, this object's + `_run` method will be invoked (typically defined by subclasses). + + .. versionchanged:: 1.1b1 + The ``run`` argument to the constructor is now verified to be a callable + object. Previously, passing a non-callable object would fail after the greenlet + was spawned. + """ + # greenlet.greenlet(run=None, parent=None) + # Calling it with both positional arguments instead of a keyword + # argument (parent=get_hub()) speeds up creation of this object ~30%: + # python -m timeit -s 'import gevent' 'gevent.Greenlet()' + # Python 3.5: 2.70usec with keywords vs 1.94usec with positional + # Python 3.4: 2.32usec with keywords vs 1.74usec with positional + # Python 3.3: 2.55usec with keywords vs 1.92usec with positional + # Python 2.7: 1.73usec with keywords vs 1.40usec with positional + greenlet.__init__(self, None, get_hub()) + + if run is not None: + self._run = run + + # If they didn't pass a callable at all, then they must + # already have one. Note that subclassing to override the run() method + # itself has never been documented or supported. + if not callable(self._run): + raise TypeError("The run argument or self._run must be callable") + + if args: + self.args = args + if kwargs: + self._kwargs = kwargs + + @property + def kwargs(self): + return self._kwargs or {} + + @Lazy + def _links(self): + return deque() + + def _has_links(self): + return '_links' in self.__dict__ and self._links + + def _raise_exception(self): + reraise(*self.exc_info) + + @property + def loop(self): + # needed by killall + return self.parent.loop + + def __bool__(self): + return self._start_event is not None and self._exc_info is Greenlet._exc_info + __nonzero__ = __bool__ + + ### Lifecycle + + if PYPY: + # oops - pypy's .dead relies on __nonzero__ which we overriden above + @property + def dead(self): + if self._greenlet__main: + return False + if self.__start_cancelled_by_kill or self.__started_but_aborted: + return True + + return self._greenlet__started and not _continulet.is_pending(self) + else: + @property + def dead(self): + return self.__start_cancelled_by_kill or self.__started_but_aborted or greenlet.dead.__get__(self) + + @property + def __never_started_or_killed(self): + return self._start_event is None + + @property + def __start_pending(self): + return (self._start_event is not None + and (self._start_event.pending or getattr(self._start_event, 'active', False))) + + @property + def __start_cancelled_by_kill(self): + return self._start_event is _cancelled_start_event + + @property + def __start_completed(self): + return self._start_event is _start_completed_event + + @property + def __started_but_aborted(self): + return (not self.__never_started_or_killed # we have been started or killed + and not self.__start_cancelled_by_kill # we weren't killed, so we must have been started + and not self.__start_completed # the start never completed + and not self.__start_pending) # and we're not pending, so we must have been aborted + + def __cancel_start(self): + if self._start_event is None: + # prevent self from ever being started in the future + self._start_event = _cancelled_start_event + # cancel any pending start event + # NOTE: If this was a real pending start event, this will leave a + # "dangling" callback/timer object in the hub.loop.callbacks list; + # depending on where we are in the event loop, it may even be in a local + # variable copy of that list (in _run_callbacks). This isn't a problem, + # except for the leak-tests. + self._start_event.stop() + + def __handle_death_before_start(self, *args): + # args is (t, v, tb) or simply t or v + if self._exc_info is Greenlet._exc_info and self.dead: + # the greenlet was never switched to before and it will never be, _report_error was not called + # the result was not set and the links weren't notified. let's do it here. + # checking that self.dead is true is essential, because throw() does not necessarily kill the greenlet + # (if the exception raised by throw() is caught somewhere inside the greenlet). + if len(args) == 1: + arg = args[0] + #if isinstance(arg, type): + if type(arg) is type(Exception): + args = (arg, arg(), None) + else: + args = (type(arg), arg, None) + elif not args: + args = (GreenletExit, GreenletExit(), None) + self._report_error(args) + + @property + def started(self): + # DEPRECATED + return bool(self) + + def ready(self): + """ + Return a true value if and only if the greenlet has finished + execution. + + .. versionchanged:: 1.1 + This function is only guaranteed to return true or false *values*, not + necessarily the literal constants ``True`` or ``False``. + """ + return self.dead or self._exc_info + + def successful(self): + """ + Return a true value if and only if the greenlet has finished execution + successfully, that is, without raising an error. + + .. tip:: A greenlet that has been killed with the default + :class:`GreenletExit` exception is considered successful. + That is, ``GreenletExit`` is not considered an error. + + .. note:: This function is only guaranteed to return true or false *values*, + not necessarily the literal constants ``True`` or ``False``. + """ + return self._exc_info and self._exc_info[1] is None + + def __repr__(self): + classname = self.__class__.__name__ + result = '<%s at %s' % (classname, hex(id(self))) + formatted = self._formatinfo() + if formatted: + result += ': ' + formatted + return result + '>' + + _formatted_info = None + + def _formatinfo(self): + info = self._formatted_info + if info is not None: + return info + + try: + result = getfuncname(self.__dict__['_run']) + except Exception: # pylint:disable=broad-except + # Don't cache + return '' + + args = [] + if self.args: + args = [repr(x)[:50] for x in self.args] + if self._kwargs: + args.extend(['%s=%s' % (key, repr(value)[:50]) for (key, value) in self._kwargs.items()]) + if args: + result += '(' + ', '.join(args) + ')' + # it is important to save the result here, because once the greenlet exits '_run' attribute will be removed + self._formatted_info = result + return result + + @property + def exception(self): + """Holds the exception instance raised by the function if the greenlet has finished with an error. + Otherwise ``None``. + """ + return self._exc_info[1] if self._exc_info else None + + @property + def exc_info(self): + """ + Holds the exc_info three-tuple raised by the function if the + greenlet finished with an error. Otherwise a false value. + + .. note:: This is a provisional API and may change. + + .. versionadded:: 1.1 + """ + e = self._exc_info + if e and e[0] is not None: + return (e[0], e[1], load_traceback(e[2])) + + def throw(self, *args): + """Immediatelly switch into the greenlet and raise an exception in it. + + Should only be called from the HUB, otherwise the current greenlet is left unscheduled forever. + To raise an exception in a safe manner from any greenlet, use :meth:`kill`. + + If a greenlet was started but never switched to yet, then also + a) cancel the event that will start it + b) fire the notifications as if an exception was raised in a greenlet + """ + self.__cancel_start() + + try: + if not self.dead: + # Prevent switching into a greenlet *at all* if we had never + # started it. Usually this is the same thing that happens by throwing, + # but if this is done from the hub with nothing else running, prevents a + # LoopExit. + greenlet.throw(self, *args) + finally: + self.__handle_death_before_start(*args) + + def start(self): + """Schedule the greenlet to run in this loop iteration""" + if self._start_event is None: + self._start_event = self.parent.loop.run_callback(self.switch) + + def start_later(self, seconds): + """Schedule the greenlet to run in the future loop iteration *seconds* later""" + if self._start_event is None: + self._start_event = self.parent.loop.timer(seconds) + self._start_event.start(self.switch) + + @classmethod + def spawn(cls, *args, **kwargs): + """ + Create a new :class:`Greenlet` object and schedule it to run ``function(*args, **kwargs)``. + This can be used as ``gevent.spawn`` or ``Greenlet.spawn``. + + The arguments are passed to :meth:`Greenlet.__init__`. + + .. versionchanged:: 1.1b1 + If a *function* is given that is not callable, immediately raise a :exc:`TypeError` + instead of spawning a greenlet that will raise an uncaught TypeError. + """ + g = cls(*args, **kwargs) + g.start() + return g + + @classmethod + def spawn_later(cls, seconds, *args, **kwargs): + """ + Create and return a new Greenlet object scheduled to run ``function(*args, **kwargs)`` + in the future loop iteration *seconds* later. This can be used as ``Greenlet.spawn_later`` + or ``gevent.spawn_later``. + + The arguments are passed to :meth:`Greenlet.__init__`. + + .. versionchanged:: 1.1b1 + If an argument that's meant to be a function (the first argument in *args*, or the ``run`` keyword ) + is given to this classmethod (and not a classmethod of a subclass), + it is verified to be callable. Previously, the spawned greenlet would have failed + when it started running. + """ + if cls is Greenlet and not args and 'run' not in kwargs: + raise TypeError("") + g = cls(*args, **kwargs) + g.start_later(seconds) + return g + + def kill(self, exception=GreenletExit, block=True, timeout=None): + """ + Raise the ``exception`` in the greenlet. + + If ``block`` is ``True`` (the default), wait until the greenlet dies or the optional timeout expires. + If block is ``False``, the current greenlet is not unscheduled. + + The function always returns ``None`` and never raises an error. + + .. note:: + + Depending on what this greenlet is executing and the state + of the event loop, the exception may or may not be raised + immediately when this greenlet resumes execution. It may + be raised on a subsequent green call, or, if this greenlet + exits before making such a call, it may not be raised at + all. As of 1.1, an example where the exception is raised + later is if this greenlet had called :func:`sleep(0) + <gevent.sleep>`; an example where the exception is raised + immediately is if this greenlet had called + :func:`sleep(0.1) <gevent.sleep>`. + + .. caution:: + + Use care when killing greenlets. If the code executing is not + exception safe (e.g., makes proper use of ``finally``) then an + unexpected exception could result in corrupted state. + + See also :func:`gevent.kill`. + + :keyword type exception: The type of exception to raise in the greenlet. The default + is :class:`GreenletExit`, which indicates a :meth:`successful` completion + of the greenlet. + + .. versionchanged:: 0.13.0 + *block* is now ``True`` by default. + .. versionchanged:: 1.1a2 + If this greenlet had never been switched to, killing it will prevent it from ever being switched to. + """ + self.__cancel_start() + + if self.dead: + self.__handle_death_before_start(exception) + else: + waiter = Waiter() if block else None + self.parent.loop.run_callback(_kill, self, exception, waiter) + if block: + waiter.get() + self.join(timeout) + # it should be OK to use kill() in finally or kill a greenlet from more than one place; + # thus it should not raise when the greenlet is already killed (= not started) + + def get(self, block=True, timeout=None): + """Return the result the greenlet has returned or re-raise the exception it has raised. + + If block is ``False``, raise :class:`gevent.Timeout` if the greenlet is still alive. + If block is ``True``, unschedule the current greenlet until the result is available + or the timeout expires. In the latter case, :class:`gevent.Timeout` is raised. + """ + if self.ready(): + if self.successful(): + return self.value + self._raise_exception() + if not block: + raise Timeout() + + switch = getcurrent().switch + self.rawlink(switch) + try: + t = Timeout._start_new_or_dummy(timeout) + try: + result = self.parent.switch() + if result is not self: + raise InvalidSwitchError('Invalid switch into Greenlet.get(): %r' % (result, )) + finally: + t.cancel() + except: + # unlinking in 'except' instead of finally is an optimization: + # if switch occurred normally then link was already removed in _notify_links + # and there's no need to touch the links set. + # Note, however, that if "Invalid switch" assert was removed and invalid switch + # did happen, the link would remain, causing another invalid switch later in this greenlet. + self.unlink(switch) + raise + + if self.ready(): + if self.successful(): + return self.value + self._raise_exception() + + def join(self, timeout=None): + """Wait until the greenlet finishes or *timeout* expires. + Return ``None`` regardless. + """ + if self.ready(): + return + + switch = getcurrent().switch + self.rawlink(switch) + try: + t = Timeout._start_new_or_dummy(timeout) + try: + result = self.parent.switch() + if result is not self: + raise InvalidSwitchError('Invalid switch into Greenlet.join(): %r' % (result, )) + finally: + t.cancel() + except Timeout as ex: + self.unlink(switch) + if ex is not t: + raise + except: + self.unlink(switch) + raise + + def _report_result(self, result): + self._exc_info = (None, None, None) + self.value = result + if self._has_links() and not self._notifier: + self._notifier = self.parent.loop.run_callback(self._notify_links) + + def _report_error(self, exc_info): + if isinstance(exc_info[1], GreenletExit): + self._report_result(exc_info[1]) + return + + self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2]) + + if self._has_links() and not self._notifier: + self._notifier = self.parent.loop.run_callback(self._notify_links) + + try: + self.parent.handle_error(self, *exc_info) + finally: + del exc_info + + def run(self): + try: + self.__cancel_start() + self._start_event = _start_completed_event + + try: + result = self._run(*self.args, **self.kwargs) + except: # pylint:disable=bare-except + self._report_error(sys.exc_info()) + return + self._report_result(result) + finally: + self.__dict__.pop('_run', None) + self.__dict__.pop('args', None) + self.__dict__.pop('kwargs', None) + + def _run(self): + """Subclasses may override this method to take any number of arguments and keyword arguments. + + .. versionadded:: 1.1a3 + Previously, if no callable object was passed to the constructor, the spawned greenlet would + later fail with an AttributeError. + """ + # We usually override this in __init__ + # pylint: disable=method-hidden + return + + def rawlink(self, callback): + """Register a callable to be executed when the greenlet finishes execution. + + The *callback* will be called with this instance as an argument. + + .. caution:: The callable will be called in the HUB greenlet. + """ + if not callable(callback): + raise TypeError('Expected callable: %r' % (callback, )) + self._links.append(callback) # pylint:disable=no-member + if self.ready() and self._links and not self._notifier: + self._notifier = self.parent.loop.run_callback(self._notify_links) + + def link(self, callback, SpawnedLink=SpawnedLink): + """ + Link greenlet's completion to a callable. + + The *callback* will be called with this instance as an + argument once this greenlet is dead. A callable is called in + its own :class:`greenlet.greenlet` (*not* a + :class:`Greenlet`). + """ + # XXX: Is the redefinition of SpawnedLink supposed to just be an + # optimization, or do people use it? It's not documented + # pylint:disable=redefined-outer-name + self.rawlink(SpawnedLink(callback)) + + def unlink(self, callback): + """Remove the callback set by :meth:`link` or :meth:`rawlink`""" + try: + self._links.remove(callback) # pylint:disable=no-member + except ValueError: + pass + + def link_value(self, callback, SpawnedLink=SuccessSpawnedLink): + """ + Like :meth:`link` but *callback* is only notified when the greenlet + has completed successfully. + """ + # pylint:disable=redefined-outer-name + self.link(callback, SpawnedLink=SpawnedLink) + + def link_exception(self, callback, SpawnedLink=FailureSpawnedLink): + """Like :meth:`link` but *callback* is only notified when the greenlet dies because of an unhandled exception.""" + # pylint:disable=redefined-outer-name + self.link(callback, SpawnedLink=SpawnedLink) + + def _notify_links(self): + while self._links: + link = self._links.popleft() # pylint:disable=no-member + try: + link(self) + except: # pylint:disable=bare-except + self.parent.handle_error((link, self), *sys.exc_info()) + + +class _dummy_event(object): + pending = False + active = False + + def stop(self): + pass + + def start(self, cb): # pylint:disable=unused-argument + raise AssertionError("Cannot start the dummy event") + + +_cancelled_start_event = _dummy_event() +_start_completed_event = _dummy_event() +del _dummy_event + + +def _kill(glet, exception, waiter): + try: + glet.throw(exception) + except: # pylint:disable=bare-except + # XXX do we need this here? + glet.parent.handle_error(glet, *sys.exc_info()) + if waiter is not None: + waiter.switch() + + +def joinall(greenlets, timeout=None, raise_error=False, count=None): + """ + Wait for the ``greenlets`` to finish. + + :param greenlets: A sequence (supporting :func:`len`) of greenlets to wait for. + :keyword float timeout: If given, the maximum number of seconds to wait. + :return: A sequence of the greenlets that finished before the timeout (if any) + expired. + """ + if not raise_error: + return wait(greenlets, timeout=timeout, count=count) + + done = [] + for obj in iwait(greenlets, timeout=timeout, count=count): + if getattr(obj, 'exception', None) is not None: + if hasattr(obj, '_raise_exception'): + obj._raise_exception() + else: + raise obj.exception + done.append(obj) + return done + + +def _killall3(greenlets, exception, waiter): + diehards = [] + for g in greenlets: + if not g.dead: + try: + g.throw(exception) + except: # pylint:disable=bare-except + g.parent.handle_error(g, *sys.exc_info()) + if not g.dead: + diehards.append(g) + waiter.switch(diehards) + + +def _killall(greenlets, exception): + for g in greenlets: + if not g.dead: + try: + g.throw(exception) + except: # pylint:disable=bare-except + g.parent.handle_error(g, *sys.exc_info()) + + +def killall(greenlets, exception=GreenletExit, block=True, timeout=None): + """ + Forceably terminate all the ``greenlets`` by causing them to raise ``exception``. + + .. caution:: Use care when killing greenlets. If they are not prepared for exceptions, + this could result in corrupted state. + + :param greenlets: A **bounded** iterable of the non-None greenlets to terminate. + *All* the items in this iterable must be greenlets that belong to the same thread. + :keyword exception: The exception to raise in the greenlets. By default this is + :class:`GreenletExit`. + :keyword bool block: If True (the default) then this function only returns when all the + greenlets are dead; the current greenlet is unscheduled during that process. + If greenlets ignore the initial exception raised in them, + then they will be joined (with :func:`gevent.joinall`) and allowed to die naturally. + If False, this function returns immediately and greenlets will raise + the exception asynchronously. + :keyword float timeout: A time in seconds to wait for greenlets to die. If given, it is + only honored when ``block`` is True. + :raise Timeout: If blocking and a timeout is given that elapses before + all the greenlets are dead. + + .. versionchanged:: 1.1a2 + *greenlets* can be any iterable of greenlets, like an iterator or a set. + Previously it had to be a list or tuple. + """ + # support non-indexable containers like iterators or set objects + greenlets = list(greenlets) + if not greenlets: + return + loop = greenlets[0].loop + if block: + waiter = Waiter() + loop.run_callback(_killall3, greenlets, exception, waiter) + t = Timeout._start_new_or_dummy(timeout) + try: + alive = waiter.get() + if alive: + joinall(alive, raise_error=False) + finally: + t.cancel() + else: + loop.run_callback(_killall, greenlets, exception) + + +if PY3: + _meth_self = "__self__" +else: + _meth_self = "im_self" + + +def getfuncname(func): + if not hasattr(func, _meth_self): + try: + funcname = func.__name__ + except AttributeError: + pass + else: + if funcname != '<lambda>': + return funcname + return repr(func) diff --git a/python/gevent/hub.py b/python/gevent/hub.py new file mode 100644 index 0000000..001cd06 --- /dev/null +++ b/python/gevent/hub.py @@ -0,0 +1,1052 @@ +# Copyright (c) 2009-2015 Denis Bilenko. See LICENSE for details. +""" +Event-loop hub. +""" +from __future__ import absolute_import +# XXX: FIXME: Refactor to make this smaller +# pylint:disable=too-many-lines +from functools import partial as _functools_partial +import os +import sys +import traceback + +from greenlet import greenlet as RawGreenlet, getcurrent, GreenletExit + + +__all__ = [ + 'getcurrent', + 'GreenletExit', + 'spawn_raw', + 'sleep', + 'kill', + 'signal', + 'reinit', + 'get_hub', + 'Hub', + 'Waiter', +] + +from gevent._compat import string_types +from gevent._compat import xrange +from gevent._util import _NONE +from gevent._util import readproperty + +if sys.version_info[0] <= 2: + import thread # pylint:disable=import-error +else: + import _thread as thread # python 2 pylint:disable=import-error + +# These must be the "real" native thread versions, +# not monkey-patched. +threadlocal = thread._local + + +class _threadlocal(threadlocal): + + def __init__(self): + # Use a class with an initializer so that we can test + # for 'is None' instead of catching AttributeError, making + # the code cleaner and possibly solving some corner cases + # (like #687) + threadlocal.__init__(self) + self.Hub = None + self.loop = None + self.hub = None + +_threadlocal = _threadlocal() + +get_ident = thread.get_ident +MAIN_THREAD = get_ident() + + + + +class LoopExit(Exception): + """ + Exception thrown when the hub finishes running. + + In a normal application, this is never thrown or caught + explicitly. The internal implementation of functions like + :func:`join` and :func:`joinall` may catch it, but user code + generally should not. + + .. caution:: + Errors in application programming can also lead to this exception being + raised. Some examples include (but are not limited too): + + - greenlets deadlocking on a lock; + - using a socket or other gevent object with native thread + affinity from a different thread + + """ + pass + + +class BlockingSwitchOutError(AssertionError): + pass + + +class InvalidSwitchError(AssertionError): + pass + + +class ConcurrentObjectUseError(AssertionError): + # raised when an object is used (waited on) by two greenlets + # independently, meaning the object was entered into a blocking + # state by one greenlet and then another while still blocking in the + # first one + pass + + +def spawn_raw(function, *args, **kwargs): + """ + Create a new :class:`greenlet.greenlet` object and schedule it to + run ``function(*args, **kwargs)``. + + This returns a raw :class:`~greenlet.greenlet` which does not have all the useful + methods that :class:`gevent.Greenlet` has. Typically, applications + should prefer :func:`~gevent.spawn`, but this method may + occasionally be useful as an optimization if there are many + greenlets involved. + + .. versionchanged:: 1.1b1 + If *function* is not callable, immediately raise a :exc:`TypeError` + instead of spawning a greenlet that will raise an uncaught TypeError. + + .. versionchanged:: 1.1rc2 + Accept keyword arguments for ``function`` as previously (incorrectly) + documented. Note that this may incur an additional expense. + + .. versionchanged:: 1.1a3 + Verify that ``function`` is callable, raising a TypeError if not. Previously, + the spawned greenlet would have failed the first time it was switched to. + """ + if not callable(function): + raise TypeError("function must be callable") + hub = get_hub() + + # The callback class object that we use to run this doesn't + # accept kwargs (and those objects are heavily used, as well as being + # implemented twice in core.ppyx and corecffi.py) so do it with a partial + if kwargs: + function = _functools_partial(function, *args, **kwargs) + g = RawGreenlet(function, hub) + hub.loop.run_callback(g.switch) + else: + g = RawGreenlet(function, hub) + hub.loop.run_callback(g.switch, *args) + return g + + +def sleep(seconds=0, ref=True): + """ + Put the current greenlet to sleep for at least *seconds*. + + *seconds* may be specified as an integer, or a float if fractional + seconds are desired. + + .. tip:: In the current implementation, a value of 0 (the default) + means to yield execution to any other runnable greenlets, but + this greenlet may be scheduled again before the event loop + cycles (in an extreme case, a greenlet that repeatedly sleeps + with 0 can prevent greenlets that are ready to do I/O from + being scheduled for some (small) period of time); a value greater than + 0, on the other hand, will delay running this greenlet until + the next iteration of the loop. + + If *ref* is False, the greenlet running ``sleep()`` will not prevent :func:`gevent.wait` + from exiting. + + .. seealso:: :func:`idle` + """ + hub = get_hub() + loop = hub.loop + if seconds <= 0: + waiter = Waiter() + loop.run_callback(waiter.switch) + waiter.get() + else: + hub.wait(loop.timer(seconds, ref=ref)) + + +def idle(priority=0): + """ + Cause the calling greenlet to wait until the event loop is idle. + + Idle is defined as having no other events of the same or higher + *priority* pending. That is, as long as sockets, timeouts or even + signals of the same or higher priority are being processed, the loop + is not idle. + + .. seealso:: :func:`sleep` + """ + hub = get_hub() + watcher = hub.loop.idle() + if priority: + watcher.priority = priority + hub.wait(watcher) + + +def kill(greenlet, exception=GreenletExit): + """ + Kill greenlet asynchronously. The current greenlet is not unscheduled. + + .. note:: + + The method :meth:`Greenlet.kill` method does the same and + more (and the same caveats listed there apply here). However, the MAIN + greenlet - the one that exists initially - does not have a + ``kill()`` method, and neither do any created with :func:`spawn_raw`, + so you have to use this function. + + .. caution:: Use care when killing greenlets. If they are not prepared for + exceptions, this could result in corrupted state. + + .. versionchanged:: 1.1a2 + If the ``greenlet`` has a :meth:`kill <Greenlet.kill>` method, calls it. This prevents a + greenlet from being switched to for the first time after it's been + killed but not yet executed. + """ + if not greenlet.dead: + if hasattr(greenlet, 'kill'): + # dealing with gevent.greenlet.Greenlet. Use it, especially + # to avoid allowing one to be switched to for the first time + # after it's been killed + greenlet.kill(exception=exception, block=False) + else: + get_hub().loop.run_callback(greenlet.throw, exception) + + +class signal(object): + """ + Call the *handler* with the *args* and *kwargs* when the process + receives the signal *signalnum*. + + The *handler* will be run in a new greenlet when the signal is delivered. + + This returns an object with the useful method ``cancel``, which, when called, + will prevent future deliveries of *signalnum* from calling *handler*. + + .. note:: + + This may not operate correctly with SIGCHLD if libev child watchers + are used (as they are by default with os.fork). + + .. versionchanged:: 1.2a1 + The ``handler`` argument is required to be callable at construction time. + """ + + # XXX: This is manually documented in gevent.rst while it is aliased in + # the gevent module. + + greenlet_class = None + + def __init__(self, signalnum, handler, *args, **kwargs): + if not callable(handler): + raise TypeError("signal handler must be callable.") + + self.hub = get_hub() + self.watcher = self.hub.loop.signal(signalnum, ref=False) + self.watcher.start(self._start) + self.handler = handler + self.args = args + self.kwargs = kwargs + if self.greenlet_class is None: + from gevent import Greenlet + self.greenlet_class = Greenlet + + def _get_ref(self): + return self.watcher.ref + + def _set_ref(self, value): + self.watcher.ref = value + + ref = property(_get_ref, _set_ref) + del _get_ref, _set_ref + + def cancel(self): + self.watcher.stop() + + def _start(self): + try: + greenlet = self.greenlet_class(self.handle) + greenlet.switch() + except: # pylint:disable=bare-except + self.hub.handle_error(None, *sys._exc_info()) # pylint:disable=no-member + + def handle(self): + try: + self.handler(*self.args, **self.kwargs) + except: # pylint:disable=bare-except + self.hub.handle_error(None, *sys.exc_info()) + + +def reinit(): + """ + Prepare the gevent hub to run in a new (forked) process. + + This should be called *immediately* after :func:`os.fork` in the + child process. This is done automatically by + :func:`gevent.os.fork` or if the :mod:`os` module has been + monkey-patched. If this function is not called in a forked + process, symptoms may include hanging of functions like + :func:`socket.getaddrinfo`, and the hub's threadpool is unlikely + to work. + + .. note:: Registered fork watchers may or may not run before + this function (and thus ``gevent.os.fork``) return. If they have + not run, they will run "soon", after an iteration of the event loop. + You can force this by inserting a few small (but non-zero) calls to :func:`sleep` + after fork returns. (As of gevent 1.1 and before, fork watchers will + not have run, but this may change in the future.) + + .. note:: This function may be removed in a future major release + if the fork process can be more smoothly managed. + + .. warning:: See remarks in :func:`gevent.os.fork` about greenlets + and libev watchers in the child process. + """ + # The loop reinit function in turn calls libev's ev_loop_fork + # function. + hub = _get_hub() + + if hub is not None: + # Note that we reinit the existing loop, not destroy it. + # See https://github.com/gevent/gevent/issues/200. + hub.loop.reinit() + # libev's fork watchers are slow to fire because the only fire + # at the beginning of a loop; due to our use of callbacks that + # run at the end of the loop, that may be too late. The + # threadpool and resolvers depend on the fork handlers being + # run (specifically, the threadpool will fail in the forked + # child if there were any threads in it, which there will be + # if the resolver_thread was in use (the default) before the + # fork.) + # + # If the forked process wants to use the threadpool or + # resolver immediately (in a queued callback), it would hang. + # + # The below is a workaround. Fortunately, both of these + # methods are idempotent and can be called multiple times + # following a fork if the suddenly started working, or were + # already working on some platforms. Other threadpools and fork handlers + # will be called at an arbitrary time later ('soon') + if hasattr(hub.threadpool, '_on_fork'): + hub.threadpool._on_fork() + # resolver_ares also has a fork watcher that's not firing + if hasattr(hub.resolver, '_on_fork'): + hub.resolver._on_fork() + + # TODO: We'd like to sleep for a non-zero amount of time to force the loop to make a + # pass around before returning to this greenlet. That will allow any + # user-provided fork watchers to run. (Two calls are necessary.) HOWEVER, if + # we do this, certain tests that heavily mix threads and forking, + # like 2.7/test_threading:test_reinit_tls_after_fork, fail. It's not immediately clear + # why. + #sleep(0.00001) + #sleep(0.00001) + + +def get_hub_class(): + """Return the type of hub to use for the current thread. + + If there's no type of hub for the current thread yet, 'gevent.hub.Hub' is used. + """ + hubtype = _threadlocal.Hub + if hubtype is None: + hubtype = _threadlocal.Hub = Hub + return hubtype + + +def get_hub(*args, **kwargs): + """ + Return the hub for the current thread. + + If a hub does not exist in the current thread, a new one is + created of the type returned by :func:`get_hub_class`. + """ + hub = _threadlocal.hub + if hub is None: + hubtype = get_hub_class() + hub = _threadlocal.hub = hubtype(*args, **kwargs) + return hub + + +def _get_hub(): + """Return the hub for the current thread. + + Return ``None`` if no hub has been created yet. + """ + return _threadlocal.hub + + +def set_hub(hub): + _threadlocal.hub = hub + + +def _import(path): + # pylint:disable=too-many-branches + if isinstance(path, list): + if not path: + raise ImportError('Cannot import from empty list: %r' % (path, )) + + for item in path[:-1]: + try: + return _import(item) + except ImportError: + pass + + return _import(path[-1]) + + if not isinstance(path, string_types): + return path + + if '.' not in path: + raise ImportError("Cannot import %r (required format: [path/][package.]module.class)" % path) + + if '/' in path: + package_path, path = path.rsplit('/', 1) + sys.path = [package_path] + sys.path + else: + package_path = None + + try: + module, item = path.rsplit('.', 1) + x = __import__(module) + for attr in path.split('.')[1:]: + oldx = x + x = getattr(x, attr, _NONE) + if x is _NONE: + raise ImportError('Cannot import %r from %r' % (attr, oldx)) + return x + finally: + try: + sys.path.remove(package_path) + except ValueError: + pass + + +def config(default, envvar): + result = os.environ.get(envvar) or default # absolute import gets confused pylint: disable=no-member + if isinstance(result, string_types): + return result.split(',') + return result + + +def resolver_config(default, envvar): + result = config(default, envvar) + return [_resolvers.get(x, x) for x in result] + + +_resolvers = {'ares': 'gevent.resolver_ares.Resolver', + 'thread': 'gevent.resolver_thread.Resolver', + 'block': 'gevent.socket.BlockingResolver'} + + +_DEFAULT_LOOP_CLASS = 'gevent.core.loop' + + +class Hub(RawGreenlet): + """A greenlet that runs the event loop. + + It is created automatically by :func:`get_hub`. + + **Switching** + + Every time this greenlet (i.e., the event loop) is switched *to*, if + the current greenlet has a ``switch_out`` method, it will be called. This + allows a greenlet to take some cleanup actions before yielding control. This method + should not call any gevent blocking functions. + """ + + #: If instances of these classes are raised into the event loop, + #: they will be propagated out to the main greenlet (where they will + #: usually be caught by Python itself) + SYSTEM_ERROR = (KeyboardInterrupt, SystemExit, SystemError) + + #: Instances of these classes are not considered to be errors and + #: do not get logged/printed when raised by the event loop. + NOT_ERROR = (GreenletExit, SystemExit) + + loop_class = config(_DEFAULT_LOOP_CLASS, 'GEVENT_LOOP') + # For the standard class, go ahead and import it when this class + # is defined. This is no loss of generality because the envvar is + # only read when this class is defined, and we know that the + # standard class will be available. This can solve problems with + # the class being imported from multiple threads at once, leading + # to one of the imports failing. Only do this for the object we + # need in the constructor, as the rest of the factories are + # themselves handled lazily. See #687. (People using a custom loop_class + # can probably manage to get_hub() from the main thread or otherwise import + # that loop_class themselves.) + if loop_class == [_DEFAULT_LOOP_CLASS]: + loop_class = [_import(loop_class)] + + resolver_class = ['gevent.resolver_thread.Resolver', + 'gevent.resolver_ares.Resolver', + 'gevent.socket.BlockingResolver'] + #: The class or callable object, or the name of a factory function or class, + #: that will be used to create :attr:`resolver`. By default, configured according to + #: :doc:`dns`. If a list, a list of objects in preference order. + resolver_class = resolver_config(resolver_class, 'GEVENT_RESOLVER') + threadpool_class = config('gevent.threadpool.ThreadPool', 'GEVENT_THREADPOOL') + backend = config(None, 'GEVENT_BACKEND') + threadpool_size = 10 + + # using pprint.pformat can override custom __repr__ methods on dict/list + # subclasses, which can be a security concern + format_context = 'pprint.saferepr' + + + def __init__(self, loop=None, default=None): + RawGreenlet.__init__(self) + if hasattr(loop, 'run'): + if default is not None: + raise TypeError("Unexpected argument: default") + self.loop = loop + elif _threadlocal.loop is not None: + # Reuse a loop instance previously set by + # destroying a hub without destroying the associated + # loop. See #237 and #238. + self.loop = _threadlocal.loop + else: + if default is None and get_ident() != MAIN_THREAD: + default = False + loop_class = _import(self.loop_class) + if loop is None: + loop = self.backend + self.loop = loop_class(flags=loop, default=default) + self._resolver = None + self._threadpool = None + self.format_context = _import(self.format_context) + + def __repr__(self): + if self.loop is None: + info = 'destroyed' + else: + try: + info = self.loop._format() + except Exception as ex: # pylint:disable=broad-except + info = str(ex) or repr(ex) or 'error' + result = '<%s at 0x%x %s' % (self.__class__.__name__, id(self), info) + if self._resolver is not None: + result += ' resolver=%r' % self._resolver + if self._threadpool is not None: + result += ' threadpool=%r' % self._threadpool + return result + '>' + + def handle_error(self, context, type, value, tb): + """ + Called by the event loop when an error occurs. The arguments + type, value, and tb are the standard tuple returned by :func:`sys.exc_info`. + + Applications can set a property on the hub with this same signature + to override the error handling provided by this class. + + Errors that are :attr:`system errors <SYSTEM_ERROR>` are passed + to :meth:`handle_system_error`. + + :param context: If this is ``None``, indicates a system error that + should generally result in exiting the loop and being thrown to the + parent greenlet. + """ + if isinstance(value, str): + # Cython can raise errors where the value is a plain string + # e.g., AttributeError, "_semaphore.Semaphore has no attr", <traceback> + value = type(value) + if not issubclass(type, self.NOT_ERROR): + self.print_exception(context, type, value, tb) + if context is None or issubclass(type, self.SYSTEM_ERROR): + self.handle_system_error(type, value) + + def handle_system_error(self, type, value): + current = getcurrent() + if current is self or current is self.parent or self.loop is None: + self.parent.throw(type, value) + else: + # in case system error was handled and life goes on + # switch back to this greenlet as well + cb = None + try: + cb = self.loop.run_callback(current.switch) + except: # pylint:disable=bare-except + traceback.print_exc(file=self.exception_stream) + try: + self.parent.throw(type, value) + finally: + if cb is not None: + cb.stop() + + @readproperty + def exception_stream(self): + """ + The stream to which exceptions will be written. + Defaults to ``sys.stderr`` unless assigned to. + + .. versionadded:: 1.2a1 + """ + # Unwrap any FileObjectThread we have thrown around sys.stderr + # (because it can't be used in the hub). Tricky because we are + # called in error situations when it's not safe to import. + stderr = sys.stderr + if type(stderr).__name__ == 'FileObjectThread': + stderr = stderr.io # pylint:disable=no-member + return stderr + + def print_exception(self, context, type, value, tb): + # Python 3 does not gracefully handle None value or tb in + # traceback.print_exception() as previous versions did. + # pylint:disable=no-member + errstream = self.exception_stream + + if value is None: + errstream.write('%s\n' % type.__name__) + else: + traceback.print_exception(type, value, tb, file=errstream) + del tb + + try: + import time + errstream.write(time.ctime()) + errstream.write(' ' if context is not None else '\n') + except: # pylint:disable=bare-except + # Possible not safe to import under certain + # error conditions in Python 2 + pass + + if context is not None: + if not isinstance(context, str): + try: + context = self.format_context(context) + except: # pylint:disable=bare-except + traceback.print_exc(file=self.exception_stream) + context = repr(context) + errstream.write('%s failed with %s\n\n' % (context, getattr(type, '__name__', 'exception'), )) + + def switch(self): + switch_out = getattr(getcurrent(), 'switch_out', None) + if switch_out is not None: + switch_out() + return RawGreenlet.switch(self) + + def switch_out(self): + raise BlockingSwitchOutError('Impossible to call blocking function in the event loop callback') + + def wait(self, watcher): + """ + Wait until the *watcher* (which should not be started) is ready. + + The current greenlet will be unscheduled during this time. + + .. seealso:: :class:`gevent.core.io`, :class:`gevent.core.timer`, + :class:`gevent.core.signal`, :class:`gevent.core.idle`, :class:`gevent.core.prepare`, + :class:`gevent.core.check`, :class:`gevent.core.fork`, :class:`gevent.core.async`, + :class:`gevent.core.child`, :class:`gevent.core.stat` + + """ + waiter = Waiter() + unique = object() + watcher.start(waiter.switch, unique) + try: + result = waiter.get() + if result is not unique: + raise InvalidSwitchError('Invalid switch into %s: %r (expected %r)' % (getcurrent(), result, unique)) + finally: + watcher.stop() + + def cancel_wait(self, watcher, error): + """ + Cancel an in-progress call to :meth:`wait` by throwing the given *error* + in the waiting greenlet. + """ + if watcher.callback is not None: + self.loop.run_callback(self._cancel_wait, watcher, error) + + def _cancel_wait(self, watcher, error): + if watcher.active: + switch = watcher.callback + if switch is not None: + greenlet = getattr(switch, '__self__', None) + if greenlet is not None: + greenlet.throw(error) + + def run(self): + """ + Entry-point to running the loop. This method is called automatically + when the hub greenlet is scheduled; do not call it directly. + + :raises LoopExit: If the loop finishes running. This means + that there are no other scheduled greenlets, and no active + watchers or servers. In some situations, this indicates a + programming error. + """ + assert self is getcurrent(), 'Do not call Hub.run() directly' + while True: + loop = self.loop + loop.error_handler = self + try: + loop.run() + finally: + loop.error_handler = None # break the refcount cycle + self.parent.throw(LoopExit('This operation would block forever', self)) + # this function must never return, as it will cause switch() in the parent greenlet + # to return an unexpected value + # It is still possible to kill this greenlet with throw. However, in that case + # switching to it is no longer safe, as switch will return immediatelly + + def join(self, timeout=None): + """Wait for the event loop to finish. Exits only when there are + no more spawned greenlets, started servers, active timeouts or watchers. + + If *timeout* is provided, wait no longer for the specified number of seconds. + + Returns True if exited because the loop finished execution. + Returns False if exited because of timeout expired. + """ + assert getcurrent() is self.parent, "only possible from the MAIN greenlet" + if self.dead: + return True + + waiter = Waiter() + + if timeout is not None: + timeout = self.loop.timer(timeout, ref=False) + timeout.start(waiter.switch) + + try: + try: + waiter.get() + except LoopExit: + return True + finally: + if timeout is not None: + timeout.stop() + return False + + def destroy(self, destroy_loop=None): + if self._resolver is not None: + self._resolver.close() + del self._resolver + if self._threadpool is not None: + self._threadpool.kill() + del self._threadpool + if destroy_loop is None: + destroy_loop = not self.loop.default + if destroy_loop: + if _threadlocal.loop is self.loop: + # Don't let anyone try to reuse this + _threadlocal.loop = None + self.loop.destroy() + else: + # Store in case another hub is created for this + # thread. + _threadlocal.loop = self.loop + + self.loop = None + if _threadlocal.hub is self: + _threadlocal.hub = None + + def _get_resolver(self): + if self._resolver is None: + if self.resolver_class is not None: + self.resolver_class = _import(self.resolver_class) + self._resolver = self.resolver_class(hub=self) + return self._resolver + + def _set_resolver(self, value): + self._resolver = value + + def _del_resolver(self): + del self._resolver + + resolver = property(_get_resolver, _set_resolver, _del_resolver) + + def _get_threadpool(self): + if self._threadpool is None: + if self.threadpool_class is not None: + self.threadpool_class = _import(self.threadpool_class) + self._threadpool = self.threadpool_class(self.threadpool_size, hub=self) + return self._threadpool + + def _set_threadpool(self, value): + self._threadpool = value + + def _del_threadpool(self): + del self._threadpool + + threadpool = property(_get_threadpool, _set_threadpool, _del_threadpool) + + +class Waiter(object): + """ + A low level communication utility for greenlets. + + Waiter is a wrapper around greenlet's ``switch()`` and ``throw()`` calls that makes them somewhat safer: + + * switching will occur only if the waiting greenlet is executing :meth:`get` method currently; + * any error raised in the greenlet is handled inside :meth:`switch` and :meth:`throw` + * if :meth:`switch`/:meth:`throw` is called before the receiver calls :meth:`get`, then :class:`Waiter` + will store the value/exception. The following :meth:`get` will return the value/raise the exception. + + The :meth:`switch` and :meth:`throw` methods must only be called from the :class:`Hub` greenlet. + The :meth:`get` method must be called from a greenlet other than :class:`Hub`. + + >>> result = Waiter() + >>> timer = get_hub().loop.timer(0.1) + >>> timer.start(result.switch, 'hello from Waiter') + >>> result.get() # blocks for 0.1 seconds + 'hello from Waiter' + + If switch is called before the greenlet gets a chance to call :meth:`get` then + :class:`Waiter` stores the value. + + >>> result = Waiter() + >>> timer = get_hub().loop.timer(0.1) + >>> timer.start(result.switch, 'hi from Waiter') + >>> sleep(0.2) + >>> result.get() # returns immediatelly without blocking + 'hi from Waiter' + + .. warning:: + + This a limited and dangerous way to communicate between + greenlets. It can easily leave a greenlet unscheduled forever + if used incorrectly. Consider using safer classes such as + :class:`gevent.event.Event`, :class:`gevent.event.AsyncResult`, + or :class:`gevent.queue.Queue`. + """ + + __slots__ = ['hub', 'greenlet', 'value', '_exception'] + + def __init__(self, hub=None): + if hub is None: + self.hub = get_hub() + else: + self.hub = hub + self.greenlet = None + self.value = None + self._exception = _NONE + + def clear(self): + self.greenlet = None + self.value = None + self._exception = _NONE + + def __str__(self): + if self._exception is _NONE: + return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet) + if self._exception is None: + return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value) + return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info) + + def ready(self): + """Return true if and only if it holds a value or an exception""" + return self._exception is not _NONE + + def successful(self): + """Return true if and only if it is ready and holds a value""" + return self._exception is None + + @property + def exc_info(self): + "Holds the exception info passed to :meth:`throw` if :meth:`throw` was called. Otherwise ``None``." + if self._exception is not _NONE: + return self._exception + + def switch(self, value=None): + """Switch to the greenlet if one's available. Otherwise store the value.""" + greenlet = self.greenlet + if greenlet is None: + self.value = value + self._exception = None + else: + assert getcurrent() is self.hub, "Can only use Waiter.switch method from the Hub greenlet" + switch = greenlet.switch + try: + switch(value) + except: # pylint:disable=bare-except + self.hub.handle_error(switch, *sys.exc_info()) + + def switch_args(self, *args): + return self.switch(args) + + def throw(self, *throw_args): + """Switch to the greenlet with the exception. If there's no greenlet, store the exception.""" + greenlet = self.greenlet + if greenlet is None: + self._exception = throw_args + else: + assert getcurrent() is self.hub, "Can only use Waiter.switch method from the Hub greenlet" + throw = greenlet.throw + try: + throw(*throw_args) + except: # pylint:disable=bare-except + self.hub.handle_error(throw, *sys.exc_info()) + + def get(self): + """If a value/an exception is stored, return/raise it. Otherwise until switch() or throw() is called.""" + if self._exception is not _NONE: + if self._exception is None: + return self.value + else: + getcurrent().throw(*self._exception) + else: + if self.greenlet is not None: + raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, )) + self.greenlet = getcurrent() + try: + return self.hub.switch() + finally: + self.greenlet = None + + def __call__(self, source): + if source.exception is None: + self.switch(source.value) + else: + self.throw(source.exception) + + # can also have a debugging version, that wraps the value in a tuple (self, value) in switch() + # and unwraps it in wait() thus checking that switch() was indeed called + + +class _MultipleWaiter(Waiter): + """ + An internal extension of Waiter that can be used if multiple objects + must be waited on, and there is a chance that in between waits greenlets + might be switched out. All greenlets that switch to this waiter + will have their value returned. + + This does not handle exceptions or throw methods. + """ + __slots__ = ['_values'] + + def __init__(self, *args, **kwargs): + Waiter.__init__(self, *args, **kwargs) + # we typically expect a relatively small number of these to be outstanding. + # since we pop from the left, a deque might be slightly + # more efficient, but since we're in the hub we avoid imports if + # we can help it to better support monkey-patching, and delaying the import + # here can be impractical (see https://github.com/gevent/gevent/issues/652) + self._values = list() + + def switch(self, value): # pylint:disable=signature-differs + self._values.append(value) + Waiter.switch(self, True) + + def get(self): + if not self._values: + Waiter.get(self) + Waiter.clear(self) + + return self._values.pop(0) + + +def iwait(objects, timeout=None, count=None): + """ + Iteratively yield *objects* as they are ready, until all (or *count*) are ready + or *timeout* expired. + + :param objects: A sequence (supporting :func:`len`) containing objects + implementing the wait protocol (rawlink() and unlink()). + :keyword int count: If not `None`, then a number specifying the maximum number + of objects to wait for. If ``None`` (the default), all objects + are waited for. + :keyword float timeout: If given, specifies a maximum number of seconds + to wait. If the timeout expires before the desired waited-for objects + are available, then this method returns immediately. + + .. seealso:: :func:`wait` + + .. versionchanged:: 1.1a1 + Add the *count* parameter. + .. versionchanged:: 1.1a2 + No longer raise :exc:`LoopExit` if our caller switches greenlets + in between items yielded by this function. + """ + # QQQ would be nice to support iterable here that can be generated slowly (why?) + if objects is None: + yield get_hub().join(timeout=timeout) + return + + count = len(objects) if count is None else min(count, len(objects)) + waiter = _MultipleWaiter() + switch = waiter.switch + + if timeout is not None: + timer = get_hub().loop.timer(timeout, priority=-1) + timer.start(switch, _NONE) + + try: + for obj in objects: + obj.rawlink(switch) + + for _ in xrange(count): + item = waiter.get() + waiter.clear() + if item is _NONE: + return + yield item + finally: + if timeout is not None: + timer.stop() + for aobj in objects: + unlink = getattr(aobj, 'unlink', None) + if unlink: + try: + unlink(switch) + except: # pylint:disable=bare-except + traceback.print_exc() + + +def wait(objects=None, timeout=None, count=None): + """ + Wait for ``objects`` to become ready or for event loop to finish. + + If ``objects`` is provided, it must be a list containing objects + implementing the wait protocol (rawlink() and unlink() methods): + + - :class:`gevent.Greenlet` instance + - :class:`gevent.event.Event` instance + - :class:`gevent.lock.Semaphore` instance + - :class:`gevent.subprocess.Popen` instance + + If ``objects`` is ``None`` (the default), ``wait()`` blocks until + the current event loop has nothing to do (or until ``timeout`` passes): + + - all greenlets have finished + - all servers were stopped + - all event loop watchers were stopped. + + If ``count`` is ``None`` (the default), wait for all ``objects`` + to become ready. + + If ``count`` is a number, wait for (up to) ``count`` objects to become + ready. (For example, if count is ``1`` then the function exits + when any object in the list is ready). + + If ``timeout`` is provided, it specifies the maximum number of + seconds ``wait()`` will block. + + Returns the list of ready objects, in the order in which they were + ready. + + .. seealso:: :func:`iwait` + """ + if objects is None: + return get_hub().join(timeout=timeout) + return list(iwait(objects, timeout, count)) + + +class linkproxy(object): + __slots__ = ['callback', 'obj'] + + def __init__(self, callback, obj): + self.callback = callback + self.obj = obj + + def __call__(self, *args): + callback = self.callback + obj = self.obj + self.callback = None + self.obj = None + callback(obj) diff --git a/python/gevent/libev/__init__.py b/python/gevent/libev/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/python/gevent/libev/__init__.py diff --git a/python/gevent/libev/_corecffi_build.py b/python/gevent/libev/_corecffi_build.py new file mode 100644 index 0000000..a6025fc --- /dev/null +++ b/python/gevent/libev/_corecffi_build.py @@ -0,0 +1,75 @@ +# pylint: disable=no-member + +# This module is only used to create and compile the gevent._corecffi module; +# nothing should be directly imported from it except `ffi`, which should only be +# used for `ffi.compile()`; programs should import gevent._corecfffi. +# However, because we are using "out-of-line" mode, it is necessary to examine +# this file to know what functions are created and available on the generated +# module. +from __future__ import absolute_import, print_function +import sys +import os +import os.path # pylint:disable=no-name-in-module +import struct + +__all__ = [] + + +def system_bits(): + return struct.calcsize('P') * 8 + + +def st_nlink_type(): + if sys.platform == "darwin" or sys.platform.startswith("freebsd"): + return "short" + if system_bits() == 32: + return "unsigned long" + return "long long" + + +from cffi import FFI +ffi = FFI() + +thisdir = os.path.dirname(os.path.abspath(__file__)) +def read_source(name): + with open(os.path.join(thisdir, name), 'r') as f: + return f.read() + +_cdef = read_source('_corecffi_cdef.c') +_source = read_source('_corecffi_source.c') + +_cdef = _cdef.replace('#define GEVENT_ST_NLINK_T int', '') +_cdef = _cdef.replace('#define GEVENT_STRUCT_DONE int', '') +_cdef = _cdef.replace('GEVENT_ST_NLINK_T', st_nlink_type()) +_cdef = _cdef.replace("GEVENT_STRUCT_DONE _;", '...;') + + +if sys.platform.startswith('win'): + # We must have the vfd_open, etc, functions on + # Windows. But on other platforms, going through + # CFFI to just return the file-descriptor is slower + # than just doing it in Python, so we check for and + # workaround their absence in corecffi.py + _cdef += """ +typedef int... vfd_socket_t; +int vfd_open(vfd_socket_t); +vfd_socket_t vfd_get(int); +void vfd_free(int); +""" + + + +include_dirs = [ + thisdir, # libev_vfd.h + os.path.abspath(os.path.join(thisdir, '..', '..', '..', 'deps', 'libev')), +] +ffi.cdef(_cdef) +ffi.set_source('gevent.libev._corecffi', _source, include_dirs=include_dirs) + +if __name__ == '__main__': + # XXX: Note, on Windows, we would need to specify the external libraries + # that should be linked in, such as ws2_32 and (because libev_vfd.h makes + # Python.h calls) the proper Python library---at least for PyPy. I never got + # that to work though, and calling python functions is strongly discouraged + # from CFFI code. + ffi.compile() diff --git a/python/gevent/libev/_corecffi_cdef.c b/python/gevent/libev/_corecffi_cdef.c new file mode 100644 index 0000000..d212887 --- /dev/null +++ b/python/gevent/libev/_corecffi_cdef.c @@ -0,0 +1,226 @@ +/* libev interface */ + +#define EV_MINPRI ... +#define EV_MAXPRI ... + +#define EV_VERSION_MAJOR ... +#define EV_VERSION_MINOR ... + +#define EV_UNDEF ... +#define EV_NONE ... +#define EV_READ ... +#define EV_WRITE ... +#define EV__IOFDSET ... +#define EV_TIMER ... +#define EV_PERIODIC ... +#define EV_SIGNAL ... +#define EV_CHILD ... +#define EV_STAT ... +#define EV_IDLE ... +#define EV_PREPARE ... +#define EV_CHECK ... +#define EV_EMBED ... +#define EV_FORK ... +#define EV_CLEANUP ... +#define EV_ASYNC ... +#define EV_CUSTOM ... +#define EV_ERROR ... + +#define EVFLAG_AUTO ... +#define EVFLAG_NOENV ... +#define EVFLAG_FORKCHECK ... +#define EVFLAG_NOINOTIFY ... +#define EVFLAG_SIGNALFD ... +#define EVFLAG_NOSIGMASK ... + +#define EVBACKEND_SELECT ... +#define EVBACKEND_POLL ... +#define EVBACKEND_EPOLL ... +#define EVBACKEND_KQUEUE ... +#define EVBACKEND_DEVPOLL ... +#define EVBACKEND_PORT ... +/* #define EVBACKEND_IOCP ... */ + +#define EVBACKEND_ALL ... +#define EVBACKEND_MASK ... + +#define EVRUN_NOWAIT ... +#define EVRUN_ONCE ... + +#define EVBREAK_CANCEL ... +#define EVBREAK_ONE ... +#define EVBREAK_ALL ... + +/* markers for the CFFI parser. Replaced when the string is read. */ +#define GEVENT_STRUCT_DONE int +#define GEVENT_ST_NLINK_T int + +struct ev_loop { + int backend_fd; + int activecnt; + GEVENT_STRUCT_DONE _; +}; + +// Watcher types +// base for all watchers +struct ev_watcher{ + GEVENT_STRUCT_DONE _; +}; + +struct ev_io { + int fd; + int events; + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_timer { + double at; + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_signal { + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_idle { + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_prepare { + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_check { + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_fork { + void* data; + GEVENT_STRUCT_DONE _; +}; +struct ev_async { + void* data; + GEVENT_STRUCT_DONE _; +}; + +struct ev_child { + int pid; + int rpid; + int rstatus; + void* data; + GEVENT_STRUCT_DONE _; +}; + +struct stat { + GEVENT_ST_NLINK_T st_nlink; + GEVENT_STRUCT_DONE _; +}; + +struct ev_stat { + struct stat attr; + const char* path; + struct stat prev; + double interval; + void* data; + GEVENT_STRUCT_DONE _; +}; + +typedef double ev_tstamp; + +int ev_version_major(); +int ev_version_minor(); + +unsigned int ev_supported_backends (void); +unsigned int ev_recommended_backends (void); +unsigned int ev_embeddable_backends (void); + +ev_tstamp ev_time (void); +void ev_set_syserr_cb(void *); + +int ev_priority(void*); +void ev_set_priority(void*, int); + +int ev_is_pending(void*); +int ev_is_active(void*); +void ev_io_init(struct ev_io*, void* callback, int fd, int events); +void ev_io_start(struct ev_loop*, struct ev_io*); +void ev_io_stop(struct ev_loop*, struct ev_io*); +void ev_feed_event(struct ev_loop*, void*, int); + +void ev_timer_init(struct ev_timer*, void *callback, double, double); +void ev_timer_start(struct ev_loop*, struct ev_timer*); +void ev_timer_stop(struct ev_loop*, struct ev_timer*); +void ev_timer_again(struct ev_loop*, struct ev_timer*); + +void ev_signal_init(struct ev_signal*, void* callback, int); +void ev_signal_start(struct ev_loop*, struct ev_signal*); +void ev_signal_stop(struct ev_loop*, struct ev_signal*); + +void ev_idle_init(struct ev_idle*, void* callback); +void ev_idle_start(struct ev_loop*, struct ev_idle*); +void ev_idle_stop(struct ev_loop*, struct ev_idle*); + +void ev_prepare_init(struct ev_prepare*, void* callback); +void ev_prepare_start(struct ev_loop*, struct ev_prepare*); +void ev_prepare_stop(struct ev_loop*, struct ev_prepare*); + +void ev_check_init(struct ev_check*, void* callback); +void ev_check_start(struct ev_loop*, struct ev_check*); +void ev_check_stop(struct ev_loop*, struct ev_check*); + +void ev_fork_init(struct ev_fork*, void* callback); +void ev_fork_start(struct ev_loop*, struct ev_fork*); +void ev_fork_stop(struct ev_loop*, struct ev_fork*); + +void ev_async_init(struct ev_async*, void* callback); +void ev_async_start(struct ev_loop*, struct ev_async*); +void ev_async_stop(struct ev_loop*, struct ev_async*); +void ev_async_send(struct ev_loop*, struct ev_async*); +int ev_async_pending(struct ev_async*); + +void ev_child_init(struct ev_child*, void* callback, int, int); +void ev_child_start(struct ev_loop*, struct ev_child*); +void ev_child_stop(struct ev_loop*, struct ev_child*); + +void ev_stat_init(struct ev_stat*, void* callback, char*, double); +void ev_stat_start(struct ev_loop*, struct ev_stat*); +void ev_stat_stop(struct ev_loop*, struct ev_stat*); + +struct ev_loop *ev_default_loop (unsigned int flags); +struct ev_loop* ev_loop_new(unsigned int flags); +void ev_loop_destroy(struct ev_loop*); +void ev_loop_fork(struct ev_loop*); +int ev_is_default_loop (struct ev_loop *); +unsigned int ev_iteration(struct ev_loop*); +unsigned int ev_depth(struct ev_loop*); +unsigned int ev_backend(struct ev_loop*); +void ev_verify(struct ev_loop*); +void ev_run(struct ev_loop*, int flags); + +ev_tstamp ev_now (struct ev_loop *); +void ev_now_update (struct ev_loop *); /* update event loop time */ +void ev_ref(struct ev_loop*); +void ev_unref(struct ev_loop*); +void ev_break(struct ev_loop*, int); +unsigned int ev_pending_count(struct ev_loop*); + +struct ev_loop* gevent_ev_default_loop(unsigned int flags); +void gevent_install_sigchld_handler(); +void gevent_reset_sigchld_handler(); + +void (*gevent_noop)(struct ev_loop *_loop, struct ev_timer *w, int revents); +void ev_sleep (ev_tstamp delay); /* sleep for a while */ + +/* gevent callbacks */ +static int (*python_callback)(void* handle, int revents); +static void (*python_handle_error)(void* handle, int revents); +static void (*python_stop)(void* handle); + +/* + * We use a single C callback for every watcher type, which in turn calls the + * Python callbacks. The ev_watcher pointer type can be used for every watcher type + * because they all start with the same members---libev itself relies on this. Each + * watcher types has a 'void* data' that stores the CFFI handle to the Python watcher + * object. + */ +static void _gevent_generic_callback(struct ev_loop* loop, struct ev_watcher* watcher, int revents); diff --git a/python/gevent/libev/_corecffi_source.c b/python/gevent/libev/_corecffi_source.c new file mode 100644 index 0000000..d179ce6 --- /dev/null +++ b/python/gevent/libev/_corecffi_source.c @@ -0,0 +1,45 @@ +// passed to the real C compiler +#define LIBEV_EMBED 1 + +#ifdef _WIN32 +#define EV_STANDALONE 1 +#include "libev_vfd.h" +#endif + + +#include "libev.h" + +static void +_gevent_noop(struct ev_loop *_loop, struct ev_timer *w, int revents) { } + +void (*gevent_noop)(struct ev_loop *, struct ev_timer *, int) = &_gevent_noop; +static int (*python_callback)(void* handle, int revents); +static void (*python_handle_error)(void* handle, int revents); +static void (*python_stop)(void* handle); + +static void _gevent_generic_callback(struct ev_loop* loop, + struct ev_watcher* watcher, + int revents) +{ + void* handle = watcher->data; + int cb_result = python_callback(handle, revents); + switch(cb_result) { + case -1: + // in case of exception, call self.loop.handle_error; + // this function is also responsible for stopping the watcher + // and allowing memory to be freed + python_handle_error(handle, revents); + break; + case 0: + // Code to stop the event. Note that if python_callback + // has disposed of the last reference to the handle, + // `watcher` could now be invalid/disposed memory! + if (!ev_is_active(watcher)) { + python_stop(handle); + } + break; + default: + assert(cb_result == 1); + // watcher is already stopped and dead, nothing to do. + } +} diff --git a/python/gevent/libev/callbacks.c b/python/gevent/libev/callbacks.c new file mode 100644 index 0000000..f65c67f --- /dev/null +++ b/python/gevent/libev/callbacks.c @@ -0,0 +1,225 @@ +/* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */ +#ifdef Py_PYTHON_H + +/* the name changes depending on our file layout and --module-name option */ +#define _GEVENTLOOP struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop + + +static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context) { + PyThreadState *tstate; + PyObject *type, *value, *traceback, *result; + tstate = PyThreadState_GET(); + type = tstate->curexc_type; + if (!type) + return; + value = tstate->curexc_value; + traceback = tstate->curexc_traceback; + if (!value) value = Py_None; + if (!traceback) traceback = Py_None; + + Py_INCREF(type); + Py_INCREF(value); + Py_INCREF(traceback); + + PyErr_Clear(); + + result = ((_GEVENTLOOP *)loop->__pyx_vtab)->handle_error(loop, context, type, value, traceback, 0); + + if (result) { + Py_DECREF(result); + } + else { + PyErr_Print(); + PyErr_Clear(); + } + + Py_DECREF(type); + Py_DECREF(value); + Py_DECREF(traceback); +} + + +static CYTHON_INLINE void gevent_check_signals(struct PyGeventLoopObject* loop) { + if (!ev_is_default_loop(loop->_ptr)) { + /* only reporting signals on the default loop */ + return; + } + PyErr_CheckSignals(); + if (PyErr_Occurred()) gevent_handle_error(loop, Py_None); +} + +#define GET_OBJECT(PY_TYPE, EV_PTR, MEMBER) \ + ((struct PY_TYPE *)(((char *)EV_PTR) - offsetof(struct PY_TYPE, MEMBER))) + + +#ifdef WITH_THREAD +#define GIL_DECLARE PyGILState_STATE ___save +#define GIL_ENSURE ___save = PyGILState_Ensure(); +#define GIL_RELEASE PyGILState_Release(___save); +#else +#define GIL_DECLARE +#define GIL_ENSURE +#define GIL_RELEASE +#endif + + +static void gevent_stop(PyObject* watcher, struct PyGeventLoopObject* loop) { + PyObject *result, *method; + int error; + error = 1; + method = PyObject_GetAttrString(watcher, "stop"); + if (method) { + result = PyObject_Call(method, __pyx_empty_tuple, NULL); + if (result) { + Py_DECREF(result); + error = 0; + } + Py_DECREF(method); + } + if (error) { + gevent_handle_error(loop, watcher); + } +} + + +static void gevent_callback(struct PyGeventLoopObject* loop, PyObject* callback, PyObject* args, PyObject* watcher, void *c_watcher, int revents) { + GIL_DECLARE; + PyObject *result, *py_events; + long length; + py_events = 0; + GIL_ENSURE; + Py_INCREF(loop); + Py_INCREF(callback); + Py_INCREF(args); + Py_INCREF(watcher); + gevent_check_signals(loop); + if (args == Py_None) { + args = __pyx_empty_tuple; + } + length = PyTuple_Size(args); + if (length < 0) { + gevent_handle_error(loop, watcher); + goto end; + } + if (length > 0 && PyTuple_GET_ITEM(args, 0) == GEVENT_CORE_EVENTS) { + py_events = PyInt_FromLong(revents); + if (!py_events) { + gevent_handle_error(loop, watcher); + goto end; + } + PyTuple_SET_ITEM(args, 0, py_events); + } + else { + py_events = NULL; + } + result = PyObject_Call(callback, args, NULL); + if (result) { + Py_DECREF(result); + } + else { + gevent_handle_error(loop, watcher); + if (revents & (EV_READ|EV_WRITE)) { + /* io watcher: not stopping it may cause the failing callback to be called repeatedly */ + gevent_stop(watcher, loop); + goto end; + } + } + if (!ev_is_active(c_watcher)) { + /* Watcher was stopped, maybe by libev. Let's call stop() to clean up + * 'callback' and 'args' properties, do Py_DECREF() and ev_ref() if necessary. + * BTW, we don't need to check for EV_ERROR, because libev stops the watcher in that case. */ + gevent_stop(watcher, loop); + } +end: + if (py_events) { + Py_DECREF(py_events); + PyTuple_SET_ITEM(args, 0, GEVENT_CORE_EVENTS); + } + Py_DECREF(watcher); + Py_DECREF(args); + Py_DECREF(callback); + Py_DECREF(loop); + GIL_RELEASE; +} + + +static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb) { + /* no need for GIL here because it is only called from run_callbacks which already has GIL */ + PyObject *result, *callback, *args; + if (!loop || !cb) + return; + callback = cb->callback; + args = cb->args; + if (!callback || !args) + return; + if (callback == Py_None || args == Py_None) + return; + Py_INCREF(loop); + Py_INCREF(callback); + Py_INCREF(args); + + Py_INCREF(Py_None); + Py_DECREF(cb->callback); + cb->callback = Py_None; + + result = PyObject_Call(callback, args, NULL); + if (result) { + Py_DECREF(result); + } + else { + gevent_handle_error(loop, (PyObject*)cb); + } + + Py_INCREF(Py_None); + Py_DECREF(cb->args); + cb->args = Py_None; + + Py_DECREF(callback); + Py_DECREF(args); + Py_DECREF(loop); +} + + +#undef DEFINE_CALLBACK +#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ + static void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \ + struct PyGevent##WATCHER_TYPE##Object* watcher = GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \ + gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \ + } + + +DEFINE_CALLBACKS + + +static void gevent_run_callbacks(struct ev_loop *_loop, void *watcher, int revents) { + struct PyGeventLoopObject* loop; + PyObject *result; + GIL_DECLARE; + GIL_ENSURE; + loop = GET_OBJECT(PyGeventLoopObject, watcher, _prepare); + Py_INCREF(loop); + gevent_check_signals(loop); + result = ((_GEVENTLOOP *)loop->__pyx_vtab)->_run_callbacks(loop); + if (result) { + Py_DECREF(result); + } + else { + PyErr_Print(); + PyErr_Clear(); + } + Py_DECREF(loop); + GIL_RELEASE; +} + +#if defined(_WIN32) + +static void gevent_periodic_signal_check(struct ev_loop *_loop, void *watcher, int revents) { + GIL_DECLARE; + GIL_ENSURE; + gevent_check_signals(GET_OBJECT(PyGeventLoopObject, watcher, _periodic_signal_checker)); + GIL_RELEASE; +} + +#endif /* _WIN32 */ + +#endif /* Py_PYTHON_H */ diff --git a/python/gevent/libev/callbacks.h b/python/gevent/libev/callbacks.h new file mode 100644 index 0000000..669ea9e --- /dev/null +++ b/python/gevent/libev/callbacks.h @@ -0,0 +1,43 @@ +#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ + static void gevent_callback_##WATCHER_LC(struct ev_loop *, void *, int); + + +#define DEFINE_CALLBACKS0 \ + DEFINE_CALLBACK(io, IO); \ + DEFINE_CALLBACK(timer, Timer); \ + DEFINE_CALLBACK(signal, Signal); \ + DEFINE_CALLBACK(idle, Idle); \ + DEFINE_CALLBACK(prepare, Prepare); \ + DEFINE_CALLBACK(check, Check); \ + DEFINE_CALLBACK(fork, Fork); \ + DEFINE_CALLBACK(async, Async); \ + DEFINE_CALLBACK(stat, Stat); + + +#ifndef _WIN32 + +#define DEFINE_CALLBACKS \ + DEFINE_CALLBACKS0 \ + DEFINE_CALLBACK(child, Child) + +#else + +#define DEFINE_CALLBACKS DEFINE_CALLBACKS0 + +#endif + + +DEFINE_CALLBACKS + + +static void gevent_run_callbacks(struct ev_loop *, void *, int); +struct PyGeventLoopObject; +static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context); +struct PyGeventCallbackObject; +static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb); + +#if defined(_WIN32) +static void gevent_periodic_signal_check(struct ev_loop *, void *, int); +#endif + +static void gevent_noop(struct ev_loop *_loop, void *watcher, int revents) { } diff --git a/python/gevent/libev/corecext.ppyx b/python/gevent/libev/corecext.ppyx new file mode 100644 index 0000000..a474d7e --- /dev/null +++ b/python/gevent/libev/corecext.ppyx @@ -0,0 +1,1134 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +# This directive, supported in Cython 0.24+, causes sources files to be +# much smaller and thus cythonpp.py to be slightly faster. But it does make +# debugging more difficult. +# cython: emit_code_comments=False +cimport cython +cimport libev +# Note this is not the standard cython 'cpython' (which has a backwards compat alias of 'python') +# it's our custom def. If it's not on the include path, we get warned. +from python cimport * + +# Work around lack of absolute_import in Cython +# Note for PY3: not doing so will leave reference to locals() on import +# (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) +sys = __import__('sys', level=0) +os = __import__('os', level=0) +traceback = __import__('traceback', level=0) +signalmodule = __import__('signal', level=0) + + +__all__ = ['get_version', + 'get_header_version', + 'supported_backends', + 'recommended_backends', + 'embeddable_backends', + 'time', + 'loop'] + +cdef tuple integer_types + +if sys.version_info[0] >= 3: + integer_types = int, +else: + integer_types = (int, long) + + +cdef extern from "callbacks.h": + void gevent_callback_io(libev.ev_loop, void*, int) + void gevent_callback_timer(libev.ev_loop, void*, int) + void gevent_callback_signal(libev.ev_loop, void*, int) + void gevent_callback_idle(libev.ev_loop, void*, int) + void gevent_callback_prepare(libev.ev_loop, void*, int) + void gevent_callback_check(libev.ev_loop, void*, int) + void gevent_callback_fork(libev.ev_loop, void*, int) + void gevent_callback_async(libev.ev_loop, void*, int) + void gevent_callback_child(libev.ev_loop, void*, int) + void gevent_callback_stat(libev.ev_loop, void*, int) + void gevent_run_callbacks(libev.ev_loop, void*, int) + void gevent_periodic_signal_check(libev.ev_loop, void*, int) + void gevent_call(loop, callback) + void gevent_noop(libev.ev_loop, void*, int) + +cdef extern from *: + int errno + +cdef extern from "stathelper.c": + object _pystat_fromstructstat(void*) + + +UNDEF = libev.EV_UNDEF +NONE = libev.EV_NONE +READ = libev.EV_READ +WRITE = libev.EV_WRITE +TIMER = libev.EV_TIMER +PERIODIC = libev.EV_PERIODIC +SIGNAL = libev.EV_SIGNAL +CHILD = libev.EV_CHILD +STAT = libev.EV_STAT +IDLE = libev.EV_IDLE +PREPARE = libev.EV_PREPARE +CHECK = libev.EV_CHECK +EMBED = libev.EV_EMBED +FORK = libev.EV_FORK +CLEANUP = libev.EV_CLEANUP +ASYNC = libev.EV_ASYNC +CUSTOM = libev.EV_CUSTOM +ERROR = libev.EV_ERROR + +READWRITE = libev.EV_READ | libev.EV_WRITE + +MINPRI = libev.EV_MINPRI +MAXPRI = libev.EV_MAXPRI + +BACKEND_PORT = libev.EVBACKEND_PORT +BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE +BACKEND_EPOLL = libev.EVBACKEND_EPOLL +BACKEND_POLL = libev.EVBACKEND_POLL +BACKEND_SELECT = libev.EVBACKEND_SELECT +FORKCHECK = libev.EVFLAG_FORKCHECK +NOINOTIFY = libev.EVFLAG_NOINOTIFY +SIGNALFD = libev.EVFLAG_SIGNALFD +NOSIGMASK = libev.EVFLAG_NOSIGMASK + + +@cython.internal +cdef class _EVENTSType: + + def __repr__(self): + return 'gevent.core.EVENTS' + + +cdef public object GEVENT_CORE_EVENTS = _EVENTSType() +EVENTS = GEVENT_CORE_EVENTS + + +def get_version(): + return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) + + +def get_header_version(): + return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) + + +# This list backends in the order they are actually tried by libev +_flags = [(libev.EVBACKEND_PORT, 'port'), + (libev.EVBACKEND_KQUEUE, 'kqueue'), + (libev.EVBACKEND_EPOLL, 'epoll'), + (libev.EVBACKEND_POLL, 'poll'), + (libev.EVBACKEND_SELECT, 'select'), + (libev.EVFLAG_NOENV, 'noenv'), + (libev.EVFLAG_FORKCHECK, 'forkcheck'), + (libev.EVFLAG_NOINOTIFY, 'noinotify'), + (libev.EVFLAG_SIGNALFD, 'signalfd'), + (libev.EVFLAG_NOSIGMASK, 'nosigmask')] + + +_flags_str2int = dict((string, flag) for (flag, string) in _flags) + + +_events = [(libev.EV_READ, 'READ'), + (libev.EV_WRITE, 'WRITE'), + (libev.EV__IOFDSET, '_IOFDSET'), + (libev.EV_PERIODIC, 'PERIODIC'), + (libev.EV_SIGNAL, 'SIGNAL'), + (libev.EV_CHILD, 'CHILD'), + (libev.EV_STAT, 'STAT'), + (libev.EV_IDLE, 'IDLE'), + (libev.EV_PREPARE, 'PREPARE'), + (libev.EV_CHECK, 'CHECK'), + (libev.EV_EMBED, 'EMBED'), + (libev.EV_FORK, 'FORK'), + (libev.EV_CLEANUP, 'CLEANUP'), + (libev.EV_ASYNC, 'ASYNC'), + (libev.EV_CUSTOM, 'CUSTOM'), + (libev.EV_ERROR, 'ERROR')] + + +cpdef _flags_to_list(unsigned int flags): + cdef list result = [] + for code, value in _flags: + if flags & code: + result.append(value) + flags &= ~code + if not flags: + break + if flags: + result.append(flags) + return result + + +if sys.version_info[0] >= 3: + basestring = (bytes, str) +else: + basestring = __builtins__.basestring + + +cpdef unsigned int _flags_to_int(object flags) except? -1: + # Note, that order does not matter, libev has its own predefined order + if not flags: + return 0 + if isinstance(flags, integer_types): + return flags + cdef unsigned int result = 0 + try: + if isinstance(flags, basestring): + flags = flags.split(',') + for value in flags: + value = value.strip().lower() + if value: + result |= _flags_str2int[value] + except KeyError as ex: + raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) + return result + + +cdef str _str_hex(object flag): + if isinstance(flag, integer_types): + return hex(flag) + return str(flag) + + +cpdef _check_flags(unsigned int flags): + cdef list as_list + flags &= libev.EVBACKEND_MASK + if not flags: + return + if not (flags & libev.EVBACKEND_ALL): + raise ValueError('Invalid value for backend: 0x%x' % flags) + if not (flags & libev.ev_supported_backends()): + as_list = [_str_hex(x) for x in _flags_to_list(flags)] + raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) + + +cpdef _events_to_str(int events): + cdef list result = [] + cdef int c_flag + for (flag, string) in _events: + c_flag = flag + if events & c_flag: + result.append(string) + events = events & (~c_flag) + if not events: + break + if events: + result.append(hex(events)) + return '|'.join(result) + + +def supported_backends(): + return _flags_to_list(libev.ev_supported_backends()) + + +def recommended_backends(): + return _flags_to_list(libev.ev_recommended_backends()) + + +def embeddable_backends(): + return _flags_to_list(libev.ev_embeddable_backends()) + + +def time(): + return libev.ev_time() + + +#define LOOP_PROPERTY(NAME) property NAME: \ + \ + def __get__(self): \ + CHECK_LOOP3(self) \ + return self._ptr.NAME + + +cdef bint _default_loop_destroyed = False + + +#define CHECK_LOOP2(LOOP) \ + if not LOOP._ptr: \ + raise ValueError('operation on destroyed loop') + + +#define CHECK_LOOP3(LOOP) \ + if not LOOP._ptr: \ + raise ValueError('operation on destroyed loop') + + + +cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: + cdef libev.ev_loop* _ptr + cdef public object error_handler + cdef libev.ev_prepare _prepare + cdef public list _callbacks + cdef libev.ev_timer _timer0 +#ifdef _WIN32 + cdef libev.ev_timer _periodic_signal_checker +#endif + + def __init__(self, object flags=None, object default=None, size_t ptr=0): + cdef unsigned int c_flags + cdef object old_handler = None + libev.ev_prepare_init(&self._prepare, <void*>gevent_run_callbacks) +#ifdef _WIN32 + libev.ev_timer_init(&self._periodic_signal_checker, <void*>gevent_periodic_signal_check, 0.3, 0.3) +#endif + libev.ev_timer_init(&self._timer0, <void*>gevent_noop, 0.0, 0.0) + if ptr: + self._ptr = <libev.ev_loop*>ptr + else: + c_flags = _flags_to_int(flags) + _check_flags(c_flags) + c_flags |= libev.EVFLAG_NOENV + c_flags |= libev.EVFLAG_FORKCHECK + if default is None: + default = True + if _default_loop_destroyed: + default = False + if default: + self._ptr = libev.gevent_ev_default_loop(c_flags) + if not self._ptr: + raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) +#ifdef _WIN32 + libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) + libev.ev_unref(self._ptr) +#endif + else: + self._ptr = libev.ev_loop_new(c_flags) + if not self._ptr: + raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) + if default or __SYSERR_CALLBACK is None: + set_syserr_cb(self._handle_syserr) + libev.ev_prepare_start(self._ptr, &self._prepare) + libev.ev_unref(self._ptr) + self._callbacks = [] + + cdef _run_callbacks(self): + cdef callback cb + cdef object callbacks + cdef int count = 1000 + libev.ev_timer_stop(self._ptr, &self._timer0) + while self._callbacks and count > 0: + callbacks = self._callbacks + self._callbacks = [] + for cb in callbacks: + libev.ev_unref(self._ptr) + gevent_call(self, cb) + count -= 1 + if self._callbacks: + libev.ev_timer_start(self._ptr, &self._timer0) + + def _stop_watchers(self): + if libev.ev_is_active(&self._prepare): + libev.ev_ref(self._ptr) + libev.ev_prepare_stop(self._ptr, &self._prepare) +#ifdef _WIN32 + if libev.ev_is_active(&self._periodic_signal_checker): + libev.ev_ref(self._ptr) + libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) +#endif + + def destroy(self): + global _default_loop_destroyed + if self._ptr: + self._stop_watchers() + if __SYSERR_CALLBACK == self._handle_syserr: + set_syserr_cb(None) + if libev.ev_is_default_loop(self._ptr): + _default_loop_destroyed = True + libev.ev_loop_destroy(self._ptr) + self._ptr = NULL + + def __dealloc__(self): + if self._ptr: + self._stop_watchers() + if not libev.ev_is_default_loop(self._ptr): + libev.ev_loop_destroy(self._ptr) + self._ptr = NULL + + property ptr: + + def __get__(self): + return <size_t>self._ptr + + property WatcherType: + + def __get__(self): + return watcher + + property MAXPRI: + + def __get__(self): + return libev.EV_MAXPRI + + property MINPRI: + + def __get__(self): + return libev.EV_MINPRI + + def _handle_syserr(self, message, errno): + if sys.version_info[0] >= 3: + message = message.decode() + self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) + + cpdef handle_error(self, context, type, value, tb): + cdef object handle_error + cdef object error_handler = self.error_handler + if error_handler is not None: + # we do want to do getattr every time so that setting Hub.handle_error property just works + handle_error = getattr(error_handler, 'handle_error', error_handler) + handle_error(context, type, value, tb) + else: + self._default_handle_error(context, type, value, tb) + + cpdef _default_handle_error(self, context, type, value, tb): + # note: Hub sets its own error handler so this is not used by gevent + # this is here to make core.loop usable without the rest of gevent + traceback.print_exception(type, value, tb) + if self._ptr: + libev.ev_break(self._ptr, libev.EVBREAK_ONE) + + def run(self, nowait=False, once=False): + CHECK_LOOP2(self) + cdef unsigned int flags = 0 + if nowait: + flags |= libev.EVRUN_NOWAIT + if once: + flags |= libev.EVRUN_ONCE + with nogil: + libev.ev_run(self._ptr, flags) + + def reinit(self): + if self._ptr: + libev.ev_loop_fork(self._ptr) + + def ref(self): + CHECK_LOOP2(self) + libev.ev_ref(self._ptr) + + def unref(self): + CHECK_LOOP2(self) + libev.ev_unref(self._ptr) + + def break_(self, int how=libev.EVBREAK_ONE): + CHECK_LOOP2(self) + libev.ev_break(self._ptr, how) + + def verify(self): + CHECK_LOOP2(self) + libev.ev_verify(self._ptr) + + def now(self): + CHECK_LOOP2(self) + return libev.ev_now(self._ptr) + + def update(self): + CHECK_LOOP2(self) + libev.ev_now_update(self._ptr) + + def __repr__(self): + return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) + + property default: + + def __get__(self): + CHECK_LOOP3(self) + return True if libev.ev_is_default_loop(self._ptr) else False + + property iteration: + + def __get__(self): + CHECK_LOOP3(self) + return libev.ev_iteration(self._ptr) + + property depth: + + def __get__(self): + CHECK_LOOP3(self) + return libev.ev_depth(self._ptr) + + property backend_int: + + def __get__(self): + CHECK_LOOP3(self) + return libev.ev_backend(self._ptr) + + property backend: + + def __get__(self): + CHECK_LOOP3(self) + cdef unsigned int backend = libev.ev_backend(self._ptr) + for key, value in _flags: + if key == backend: + return value + return backend + + property pendingcnt: + + def __get__(self): + CHECK_LOOP3(self) + return libev.ev_pending_count(self._ptr) + +#ifdef _WIN32 + def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): + return io(self, fd, events, ref, priority) +#else + def io(self, int fd, int events, ref=True, priority=None): + return io(self, fd, events, ref, priority) +#endif + + def timer(self, double after, double repeat=0.0, ref=True, priority=None): + return timer(self, after, repeat, ref, priority) + + def signal(self, int signum, ref=True, priority=None): + return signal(self, signum, ref, priority) + + def idle(self, ref=True, priority=None): + return idle(self, ref, priority) + + def prepare(self, ref=True, priority=None): + return prepare(self, ref, priority) + + def check(self, ref=True, priority=None): + return check(self, ref, priority) + + def fork(self, ref=True, priority=None): + return fork(self, ref, priority) + + def async(self, ref=True, priority=None): + return async(self, ref, priority) + +#ifdef _WIN32 +#else + + def child(self, int pid, bint trace=0, ref=True): + return child(self, pid, trace, ref) + + def install_sigchld(self): + libev.gevent_install_sigchld_handler() + + def reset_sigchld(self): + libev.gevent_reset_sigchld_handler() + +#endif + + def stat(self, str path, float interval=0.0, ref=True, priority=None): + return stat(self, path, interval, ref, priority) + + def run_callback(self, func, *args): + CHECK_LOOP2(self) + cdef callback cb = callback(func, args) + self._callbacks.append(cb) + libev.ev_ref(self._ptr) + return cb + + def _format(self): + if not self._ptr: + return 'destroyed' + cdef object msg = self.backend + if self.default: + msg += ' default' + msg += ' pending=%s' % self.pendingcnt +#ifdef LIBEV_EMBED + msg += self._format_details() +#endif + return msg + +#ifdef LIBEV_EMBED + + def _format_details(self): + cdef str msg = '' + cdef object fileno = self.fileno() + cdef object sigfd = None + cdef object activecnt = None + try: + sigfd = self.sigfd + except AttributeError: + sigfd = None + try: + activecnt = self.activecnt + except AttributeError: + pass + if activecnt is not None: + msg += ' ref=' + repr(activecnt) + if fileno is not None: + msg += ' fileno=' + repr(fileno) + if sigfd is not None and sigfd != -1: + msg += ' sigfd=' + repr(sigfd) + return msg + + def fileno(self): + cdef int fd + if self._ptr: + fd = self._ptr.backend_fd + if fd >= 0: + return fd + + LOOP_PROPERTY(activecnt) + + LOOP_PROPERTY(sig_pending) + +#if EV_USE_SIGNALFD + LOOP_PROPERTY(sigfd) +#endif + + property origflags: + + def __get__(self): + CHECK_LOOP3(self) + return _flags_to_list(self._ptr.origflags) + + property origflags_int: + + def __get__(self): + CHECK_LOOP3(self) + return self._ptr.origflags + +#endif + + +cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: + cdef public object callback + cdef public tuple args + + def __init__(self, callback, args): + self.callback = callback + self.args = args + + def stop(self): + self.callback = None + self.args = None + + # Note, that __nonzero__ and pending are different + # nonzero is used in contexts where we need to know whether to schedule another callback, + # so it's true if it's pending or currently running + # 'pending' has the same meaning as libev watchers: it is cleared before entering callback + + def __nonzero__(self): + # it's nonzero if it's pending or currently executing + return self.args is not None + + property pending: + + def __get__(self): + return self.callback is not None + + def __repr__(self): + if Py_ReprEnter(<PyObjectPtr>self) != 0: + return "<...>" + try: + format = self._format() + result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + if self.callback is None and self.args is None: + result += " stopped" + return result + ">" + finally: + Py_ReprLeave(<PyObjectPtr>self) + + def _format(self): + return '' + + +#define PYTHON_INCREF if not self._flags & 1: \ + Py_INCREF(<PyObjectPtr>self) \ + self._flags |= 1 + +#define LIBEV_UNREF if self._flags & 6 == 4: \ + libev.ev_unref(self.loop._ptr) \ + self._flags |= 2 + +# about readonly _flags attribute: +# bit #1 set if object owns Python reference to itself (Py_INCREF was called and we must call Py_DECREF later) +# bit #2 set if ev_unref() was called and we must call ev_ref() later +# bit #3 set if user wants to call ev_unref() before start() + +#define WATCHER_BASE(TYPE) \ + cdef public loop loop \ + cdef object _callback \ + cdef public tuple args \ + cdef readonly int _flags \ + cdef libev.ev_##TYPE _watcher \ + \ + property ref: \ + \ + def __get__(self): \ + return False if self._flags & 4 else True \ + \ + def __set__(self, object value): \ + CHECK_LOOP3(self.loop) \ + if value: \ + if not self._flags & 4: \ + return # ref is already True \ + if self._flags & 2: # ev_unref was called, undo \ + libev.ev_ref(self.loop._ptr) \ + self._flags &= ~6 # do not want unref, no outstanding unref \ + else: \ + if self._flags & 4: \ + return # ref is already False \ + self._flags |= 4 \ + if not self._flags & 2 and libev.ev_is_active(&self._watcher): \ + libev.ev_unref(self.loop._ptr) \ + self._flags |= 2 \ + \ + property callback: \ + \ + def __get__(self): \ + return self._callback \ + \ + def __set__(self, object callback): \ + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: \ + raise TypeError("Expected callable, not %r" % (callback, )) \ + self._callback = callback \ + \ + def stop(self): \ + CHECK_LOOP2(self.loop) \ + if self._flags & 2: \ + libev.ev_ref(self.loop._ptr) \ + self._flags &= ~2 \ + libev.ev_##TYPE##_stop(self.loop._ptr, &self._watcher) \ + self._callback = None \ + self.args = None \ + if self._flags & 1: \ + Py_DECREF(<PyObjectPtr>self) \ + self._flags &= ~1 \ + \ + property priority: \ + \ + def __get__(self): \ + return libev.ev_priority(&self._watcher) \ + \ + def __set__(self, int priority): \ + if libev.ev_is_active(&self._watcher): \ + raise AttributeError("Cannot set priority of an active watcher") \ + libev.ev_set_priority(&self._watcher, priority) \ + \ + def feed(self, int revents, object callback, *args): \ + CHECK_LOOP2(self.loop) \ + self.callback = callback \ + self.args = args \ + LIBEV_UNREF \ + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \ + PYTHON_INCREF + +#define ACTIVE property active: \ + \ + def __get__(self): \ + return True if libev.ev_is_active(&self._watcher) else False + +#define START(TYPE) def start(self, object callback, *args): \ + CHECK_LOOP2(self.loop) \ + if callback is None: \ + raise TypeError('callback must be callable, not None') \ + self.callback = callback \ + self.args = args \ + LIBEV_UNREF \ + libev.ev_##TYPE##_start(self.loop._ptr, &self._watcher) \ + PYTHON_INCREF + + +#define PENDING \ + property pending: \ + \ + def __get__(self): \ + return True if libev.ev_is_pending(&self._watcher) else False + + + +#define WATCHER(TYPE) WATCHER_BASE(TYPE) \ + \ + START(TYPE) \ + \ + ACTIVE \ + \ + PENDING + + +#define COMMA , + + +#define INIT(TYPE, ARGS_INITIALIZERS, ARGS) \ + def __init__(self, loop loop ARGS_INITIALIZERS, ref=True, priority=None): \ + libev.ev_##TYPE##_init(&self._watcher, <void *>gevent_callback_##TYPE ARGS) \ + self.loop = loop \ + if ref: \ + self._flags = 0 \ + else: \ + self._flags = 4 \ + if priority is not None: \ + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: + """Abstract base class for all the watchers""" + + def __repr__(self): + if Py_ReprEnter(<PyObjectPtr>self) != 0: + return "<...>" + try: + format = self._format() + result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) + if self.active: + result += " active" + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + return result + ">" + finally: + Py_ReprLeave(<PyObjectPtr>self) + + def _format(self): + return '' + + +cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: + + WATCHER_BASE(io) + + def start(self, object callback, *args, pass_events=False): + CHECK_LOOP2(self.loop) + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + if pass_events: + self.args = (GEVENT_CORE_EVENTS, ) + args + else: + self.args = args + LIBEV_UNREF + libev.ev_io_start(self.loop._ptr, &self._watcher) + PYTHON_INCREF + + ACTIVE + + PENDING + +#ifdef _WIN32 + + def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): + if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): + raise ValueError('illegal event mask: %r' % events) + cdef int vfd = libev.vfd_open(fd) + libev.vfd_free(self._watcher.fd) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, events) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + +#else + + def __init__(self, loop loop, int fd, int events, ref=True, priority=None): + if fd < 0: + raise ValueError('fd must be non-negative: %r' % fd) + if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): + raise ValueError('illegal event mask: %r' % events) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, fd, events) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + +#endif + + property fd: + + def __get__(self): + return libev.vfd_get(self._watcher.fd) + + def __set__(self, long fd): + if libev.ev_is_active(&self._watcher): + raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") + cdef int vfd = libev.vfd_open(fd) + libev.vfd_free(self._watcher.fd) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events) + + property events: + + def __get__(self): + return self._watcher.events + + def __set__(self, int events): + if libev.ev_is_active(&self._watcher): + raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events) + + property events_str: + + def __get__(self): + return _events_to_str(self._watcher.events) + + def _format(self): + return ' fd=%s events=%s' % (self.fd, self.events_str) + +#ifdef _WIN32 + + def __cinit__(self): + self._watcher.fd = -1; + + def __dealloc__(self): + libev.vfd_free(self._watcher.fd) + +#endif + + +cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: + + WATCHER_BASE(timer) + + def start(self, object callback, *args, update=True): + CHECK_LOOP2(self.loop) + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + LIBEV_UNREF + if update: + libev.ev_now_update(self.loop._ptr) + libev.ev_timer_start(self.loop._ptr, &self._watcher) + PYTHON_INCREF + + ACTIVE + + PENDING + + def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): + if repeat < 0.0: + raise ValueError("repeat must be positive or zero: %r" % repeat) + libev.ev_timer_init(&self._watcher, <void *>gevent_callback_timer, after, repeat) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + property at: + + def __get__(self): + return self._watcher.at + + # QQQ: add 'after' and 'repeat' properties? + + def again(self, object callback, *args, update=True): + CHECK_LOOP2(self.loop) + self.callback = callback + self.args = args + LIBEV_UNREF + if update: + libev.ev_now_update(self.loop._ptr) + libev.ev_timer_again(self.loop._ptr, &self._watcher) + PYTHON_INCREF + + +cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: + + WATCHER(signal) + + def __init__(self, loop loop, int signalnum, ref=True, priority=None): + if signalnum < 1 or signalnum >= signalmodule.NSIG: + raise ValueError('illegal signal number: %r' % signalnum) + # still possible to crash on one of libev's asserts: + # 1) "libev: ev_signal_start called with illegal signal number" + # EV_NSIG might be different from signal.NSIG on some platforms + # 2) "libev: a signal must not be attached to two different loops" + # we probably could check that in LIBEV_EMBED mode, but not in general + libev.ev_signal_init(&self._watcher, <void *>gevent_callback_signal, signalnum) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: + + WATCHER(idle) + + INIT(idle,,) + + +cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: + + WATCHER(prepare) + + INIT(prepare,,) + + +cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: + + WATCHER(check) + + INIT(check,,) + + +cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: + + WATCHER(fork) + + INIT(fork,,) + + +cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: + + WATCHER_BASE(async) + + START(async) + + ACTIVE + + property pending: + + def __get__(self): + return True if libev.ev_async_pending(&self._watcher) else False + + INIT(async,,) + + def send(self): + CHECK_LOOP2(self.loop) + libev.ev_async_send(self.loop._ptr, &self._watcher) + +#ifdef _WIN32 +#else + +cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: + + WATCHER(child) + + def __init__(self, loop loop, int pid, bint trace=0, ref=True): + if not loop.default: + raise TypeError('child watchers are only available on the default loop') + libev.gevent_install_sigchld_handler() + libev.ev_child_init(&self._watcher, <void *>gevent_callback_child, pid, trace) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + + def _format(self): + return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) + + property pid: + + def __get__(self): + return self._watcher.pid + + property rpid: + + def __get__(self): + return self._watcher.rpid + + def __set__(self, int value): + self._watcher.rpid = value + + property rstatus: + + def __get__(self): + return self._watcher.rstatus + + def __set__(self, int value): + self._watcher.rstatus = value + +#endif + + +cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: + + WATCHER(stat) + cdef readonly str path + cdef readonly bytes _paths + + def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): + self.path = path + cdef bytes paths + if isinstance(path, unicode): + # the famous Python3 filesystem encoding debacle hits us here. Can we do better? + # We must keep a reference to the encoded string so that its bytes don't get freed + # and overwritten, leading to strange errors from libev ("no such file or directory") + paths = (<unicode>path).encode(sys.getfilesystemencoding()) + self._paths = paths + else: + paths = <bytes>path + self._paths = paths + libev.ev_stat_init(&self._watcher, <void *>gevent_callback_stat, <char*>paths, interval) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + property attr: + + def __get__(self): + if not self._watcher.attr.st_nlink: + return + return _pystat_fromstructstat(&self._watcher.attr) + + property prev: + + def __get__(self): + if not self._watcher.prev.st_nlink: + return + return _pystat_fromstructstat(&self._watcher.prev) + + property interval: + + def __get__(self): + return self._watcher.interval + + +__SYSERR_CALLBACK = None + + +cdef void _syserr_cb(char* msg) with gil: + try: + __SYSERR_CALLBACK(msg, errno) + except: + set_syserr_cb(None) + print_exc = getattr(traceback, 'print_exc', None) + if print_exc is not None: + print_exc() + + +cpdef set_syserr_cb(callback): + global __SYSERR_CALLBACK + if callback is None: + libev.ev_set_syserr_cb(NULL) + __SYSERR_CALLBACK = None + elif callable(callback): + libev.ev_set_syserr_cb(<void *>_syserr_cb) + __SYSERR_CALLBACK = callback + else: + raise TypeError('Expected callable or None, got %r' % (callback, )) + + +#ifdef LIBEV_EMBED +LIBEV_EMBED = True +EV_USE_FLOOR = libev.EV_USE_FLOOR +EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL +EV_USE_REALTIME = libev.EV_USE_REALTIME +EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC +EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP +EV_USE_INOTIFY = libev.EV_USE_INOTIFY +EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD +EV_USE_EVENTFD = libev.EV_USE_EVENTFD +EV_USE_4HEAP = libev.EV_USE_4HEAP +#else +LIBEV_EMBED = False +#endif diff --git a/python/gevent/libev/corecext.pyx b/python/gevent/libev/corecext.pyx new file mode 100644 index 0000000..a7fb888 --- /dev/null +++ b/python/gevent/libev/corecext.pyx @@ -0,0 +1,2110 @@ +# Generated by cythonpp.py on 2017-06-05 11:30:19 +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +# This directive, supported in Cython 0.24+, causes sources files to be +# much smaller and thus cythonpp.py to be slightly faster. But it does make +# debugging more difficult. +# cython: emit_code_comments=False +cimport cython +cimport libev +# Note this is not the standard cython 'cpython' (which has a backwards compat alias of 'python') +# it's our custom def. If it's not on the include path, we get warned. +from python cimport * + +# Work around lack of absolute_import in Cython +# Note for PY3: not doing so will leave reference to locals() on import +# (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py) +sys = __import__('sys', level=0) +os = __import__('os', level=0) +traceback = __import__('traceback', level=0) +signalmodule = __import__('signal', level=0) + + +__all__ = ['get_version', + 'get_header_version', + 'supported_backends', + 'recommended_backends', + 'embeddable_backends', + 'time', + 'loop'] + +cdef tuple integer_types + +if sys.version_info[0] >= 3: + integer_types = int, +else: + integer_types = (int, long) + + +cdef extern from "callbacks.h": + void gevent_callback_io(libev.ev_loop, void*, int) + void gevent_callback_timer(libev.ev_loop, void*, int) + void gevent_callback_signal(libev.ev_loop, void*, int) + void gevent_callback_idle(libev.ev_loop, void*, int) + void gevent_callback_prepare(libev.ev_loop, void*, int) + void gevent_callback_check(libev.ev_loop, void*, int) + void gevent_callback_fork(libev.ev_loop, void*, int) + void gevent_callback_async(libev.ev_loop, void*, int) + void gevent_callback_child(libev.ev_loop, void*, int) + void gevent_callback_stat(libev.ev_loop, void*, int) + void gevent_run_callbacks(libev.ev_loop, void*, int) + void gevent_periodic_signal_check(libev.ev_loop, void*, int) + void gevent_call(loop, callback) + void gevent_noop(libev.ev_loop, void*, int) + +cdef extern from *: + int errno + +cdef extern from "stathelper.c": + object _pystat_fromstructstat(void*) + + +UNDEF = libev.EV_UNDEF +NONE = libev.EV_NONE +READ = libev.EV_READ +WRITE = libev.EV_WRITE +TIMER = libev.EV_TIMER +PERIODIC = libev.EV_PERIODIC +SIGNAL = libev.EV_SIGNAL +CHILD = libev.EV_CHILD +STAT = libev.EV_STAT +IDLE = libev.EV_IDLE +PREPARE = libev.EV_PREPARE +CHECK = libev.EV_CHECK +EMBED = libev.EV_EMBED +FORK = libev.EV_FORK +CLEANUP = libev.EV_CLEANUP +ASYNC = libev.EV_ASYNC +CUSTOM = libev.EV_CUSTOM +ERROR = libev.EV_ERROR + +READWRITE = libev.EV_READ | libev.EV_WRITE + +MINPRI = libev.EV_MINPRI +MAXPRI = libev.EV_MAXPRI + +BACKEND_PORT = libev.EVBACKEND_PORT +BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE +BACKEND_EPOLL = libev.EVBACKEND_EPOLL +BACKEND_POLL = libev.EVBACKEND_POLL +BACKEND_SELECT = libev.EVBACKEND_SELECT +FORKCHECK = libev.EVFLAG_FORKCHECK +NOINOTIFY = libev.EVFLAG_NOINOTIFY +SIGNALFD = libev.EVFLAG_SIGNALFD +NOSIGMASK = libev.EVFLAG_NOSIGMASK + + +@cython.internal +cdef class _EVENTSType: + + def __repr__(self): + return 'gevent.core.EVENTS' + + +cdef public object GEVENT_CORE_EVENTS = _EVENTSType() +EVENTS = GEVENT_CORE_EVENTS + + +def get_version(): + return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) + + +def get_header_version(): + return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) + + +# This list backends in the order they are actually tried by libev +_flags = [(libev.EVBACKEND_PORT, 'port'), + (libev.EVBACKEND_KQUEUE, 'kqueue'), + (libev.EVBACKEND_EPOLL, 'epoll'), + (libev.EVBACKEND_POLL, 'poll'), + (libev.EVBACKEND_SELECT, 'select'), + (libev.EVFLAG_NOENV, 'noenv'), + (libev.EVFLAG_FORKCHECK, 'forkcheck'), + (libev.EVFLAG_NOINOTIFY, 'noinotify'), + (libev.EVFLAG_SIGNALFD, 'signalfd'), + (libev.EVFLAG_NOSIGMASK, 'nosigmask')] + + +_flags_str2int = dict((string, flag) for (flag, string) in _flags) + + +_events = [(libev.EV_READ, 'READ'), + (libev.EV_WRITE, 'WRITE'), + (libev.EV__IOFDSET, '_IOFDSET'), + (libev.EV_PERIODIC, 'PERIODIC'), + (libev.EV_SIGNAL, 'SIGNAL'), + (libev.EV_CHILD, 'CHILD'), + (libev.EV_STAT, 'STAT'), + (libev.EV_IDLE, 'IDLE'), + (libev.EV_PREPARE, 'PREPARE'), + (libev.EV_CHECK, 'CHECK'), + (libev.EV_EMBED, 'EMBED'), + (libev.EV_FORK, 'FORK'), + (libev.EV_CLEANUP, 'CLEANUP'), + (libev.EV_ASYNC, 'ASYNC'), + (libev.EV_CUSTOM, 'CUSTOM'), + (libev.EV_ERROR, 'ERROR')] + + +cpdef _flags_to_list(unsigned int flags): + cdef list result = [] + for code, value in _flags: + if flags & code: + result.append(value) + flags &= ~code + if not flags: + break + if flags: + result.append(flags) + return result + + +if sys.version_info[0] >= 3: + basestring = (bytes, str) +else: + basestring = __builtins__.basestring + + +cpdef unsigned int _flags_to_int(object flags) except? -1: + # Note, that order does not matter, libev has its own predefined order + if not flags: + return 0 + if isinstance(flags, integer_types): + return flags + cdef unsigned int result = 0 + try: + if isinstance(flags, basestring): + flags = flags.split(',') + for value in flags: + value = value.strip().lower() + if value: + result |= _flags_str2int[value] + except KeyError as ex: + raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) + return result + + +cdef str _str_hex(object flag): + if isinstance(flag, integer_types): + return hex(flag) + return str(flag) + + +cpdef _check_flags(unsigned int flags): + cdef list as_list + flags &= libev.EVBACKEND_MASK + if not flags: + return + if not (flags & libev.EVBACKEND_ALL): + raise ValueError('Invalid value for backend: 0x%x' % flags) + if not (flags & libev.ev_supported_backends()): + as_list = [_str_hex(x) for x in _flags_to_list(flags)] + raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) + + +cpdef _events_to_str(int events): + cdef list result = [] + cdef int c_flag + for (flag, string) in _events: + c_flag = flag + if events & c_flag: + result.append(string) + events = events & (~c_flag) + if not events: + break + if events: + result.append(hex(events)) + return '|'.join(result) + + +def supported_backends(): + return _flags_to_list(libev.ev_supported_backends()) + + +def recommended_backends(): + return _flags_to_list(libev.ev_recommended_backends()) + + +def embeddable_backends(): + return _flags_to_list(libev.ev_embeddable_backends()) + + +def time(): + return libev.ev_time() + + + + +cdef bint _default_loop_destroyed = False + + + + + + + +cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: + cdef libev.ev_loop* _ptr + cdef public object error_handler + cdef libev.ev_prepare _prepare + cdef public list _callbacks + cdef libev.ev_timer _timer0 +#ifdef _WIN32 + cdef libev.ev_timer _periodic_signal_checker +#endif + + def __init__(self, object flags=None, object default=None, size_t ptr=0): + cdef unsigned int c_flags + cdef object old_handler = None + libev.ev_prepare_init(&self._prepare, <void*>gevent_run_callbacks) +#ifdef _WIN32 + libev.ev_timer_init(&self._periodic_signal_checker, <void*>gevent_periodic_signal_check, 0.3, 0.3) +#endif + libev.ev_timer_init(&self._timer0, <void*>gevent_noop, 0.0, 0.0) + if ptr: + self._ptr = <libev.ev_loop*>ptr + else: + c_flags = _flags_to_int(flags) + _check_flags(c_flags) + c_flags |= libev.EVFLAG_NOENV + c_flags |= libev.EVFLAG_FORKCHECK + if default is None: + default = True + if _default_loop_destroyed: + default = False + if default: + self._ptr = libev.gevent_ev_default_loop(c_flags) + if not self._ptr: + raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) +#ifdef _WIN32 + libev.ev_timer_start(self._ptr, &self._periodic_signal_checker) + libev.ev_unref(self._ptr) +#endif + else: + self._ptr = libev.ev_loop_new(c_flags) + if not self._ptr: + raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) + if default or __SYSERR_CALLBACK is None: + set_syserr_cb(self._handle_syserr) + libev.ev_prepare_start(self._ptr, &self._prepare) + libev.ev_unref(self._ptr) + self._callbacks = [] + + cdef _run_callbacks(self): + cdef callback cb + cdef object callbacks + cdef int count = 1000 + libev.ev_timer_stop(self._ptr, &self._timer0) + while self._callbacks and count > 0: + callbacks = self._callbacks + self._callbacks = [] + for cb in callbacks: + libev.ev_unref(self._ptr) + gevent_call(self, cb) + count -= 1 + if self._callbacks: + libev.ev_timer_start(self._ptr, &self._timer0) + + def _stop_watchers(self): + if libev.ev_is_active(&self._prepare): + libev.ev_ref(self._ptr) + libev.ev_prepare_stop(self._ptr, &self._prepare) +#ifdef _WIN32 + if libev.ev_is_active(&self._periodic_signal_checker): + libev.ev_ref(self._ptr) + libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker) +#endif + + def destroy(self): + global _default_loop_destroyed + if self._ptr: + self._stop_watchers() + if __SYSERR_CALLBACK == self._handle_syserr: + set_syserr_cb(None) + if libev.ev_is_default_loop(self._ptr): + _default_loop_destroyed = True + libev.ev_loop_destroy(self._ptr) + self._ptr = NULL + + def __dealloc__(self): + if self._ptr: + self._stop_watchers() + if not libev.ev_is_default_loop(self._ptr): + libev.ev_loop_destroy(self._ptr) + self._ptr = NULL + + property ptr: + + def __get__(self): + return <size_t>self._ptr + + property WatcherType: + + def __get__(self): + return watcher + + property MAXPRI: + + def __get__(self): + return libev.EV_MAXPRI + + property MINPRI: + + def __get__(self): + return libev.EV_MINPRI + + def _handle_syserr(self, message, errno): + if sys.version_info[0] >= 3: + message = message.decode() + self.handle_error(None, SystemError, SystemError(message + ': ' + os.strerror(errno)), None) + + cpdef handle_error(self, context, type, value, tb): + cdef object handle_error + cdef object error_handler = self.error_handler + if error_handler is not None: + # we do want to do getattr every time so that setting Hub.handle_error property just works + handle_error = getattr(error_handler, 'handle_error', error_handler) + handle_error(context, type, value, tb) + else: + self._default_handle_error(context, type, value, tb) + + cpdef _default_handle_error(self, context, type, value, tb): + # note: Hub sets its own error handler so this is not used by gevent + # this is here to make core.loop usable without the rest of gevent + traceback.print_exception(type, value, tb) + if self._ptr: + libev.ev_break(self._ptr, libev.EVBREAK_ONE) + + def run(self, nowait=False, once=False): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + cdef unsigned int flags = 0 + if nowait: + flags |= libev.EVRUN_NOWAIT + if once: + flags |= libev.EVRUN_ONCE + with nogil: + libev.ev_run(self._ptr, flags) + + def reinit(self): + if self._ptr: + libev.ev_loop_fork(self._ptr) + + def ref(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_ref(self._ptr) + + def unref(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_unref(self._ptr) + + def break_(self, int how=libev.EVBREAK_ONE): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_break(self._ptr, how) + + def verify(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_verify(self._ptr) + + def now(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return libev.ev_now(self._ptr) + + def update(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_now_update(self._ptr) + + def __repr__(self): + return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) + + property default: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return True if libev.ev_is_default_loop(self._ptr) else False + + property iteration: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return libev.ev_iteration(self._ptr) + + property depth: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return libev.ev_depth(self._ptr) + + property backend_int: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return libev.ev_backend(self._ptr) + + property backend: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + cdef unsigned int backend = libev.ev_backend(self._ptr) + for key, value in _flags: + if key == backend: + return value + return backend + + property pendingcnt: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return libev.ev_pending_count(self._ptr) + +#ifdef _WIN32 + def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None): + return io(self, fd, events, ref, priority) +#else + def io(self, int fd, int events, ref=True, priority=None): + return io(self, fd, events, ref, priority) +#endif + + def timer(self, double after, double repeat=0.0, ref=True, priority=None): + return timer(self, after, repeat, ref, priority) + + def signal(self, int signum, ref=True, priority=None): + return signal(self, signum, ref, priority) + + def idle(self, ref=True, priority=None): + return idle(self, ref, priority) + + def prepare(self, ref=True, priority=None): + return prepare(self, ref, priority) + + def check(self, ref=True, priority=None): + return check(self, ref, priority) + + def fork(self, ref=True, priority=None): + return fork(self, ref, priority) + + def async(self, ref=True, priority=None): + return async(self, ref, priority) + +#ifdef _WIN32 +#else + + def child(self, int pid, bint trace=0, ref=True): + return child(self, pid, trace, ref) + + def install_sigchld(self): + libev.gevent_install_sigchld_handler() + + def reset_sigchld(self): + libev.gevent_reset_sigchld_handler() + +#endif + + def stat(self, str path, float interval=0.0, ref=True, priority=None): + return stat(self, path, interval, ref, priority) + + def run_callback(self, func, *args): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + cdef callback cb = callback(func, args) + self._callbacks.append(cb) + libev.ev_ref(self._ptr) + return cb + + def _format(self): + if not self._ptr: + return 'destroyed' + cdef object msg = self.backend + if self.default: + msg += ' default' + msg += ' pending=%s' % self.pendingcnt +#ifdef LIBEV_EMBED + msg += self._format_details() +#endif + return msg + +#ifdef LIBEV_EMBED + + def _format_details(self): + cdef str msg = '' + cdef object fileno = self.fileno() + cdef object sigfd = None + cdef object activecnt = None + try: + sigfd = self.sigfd + except AttributeError: + sigfd = None + try: + activecnt = self.activecnt + except AttributeError: + pass + if activecnt is not None: + msg += ' ref=' + repr(activecnt) + if fileno is not None: + msg += ' fileno=' + repr(fileno) + if sigfd is not None and sigfd != -1: + msg += ' sigfd=' + repr(sigfd) + return msg + + def fileno(self): + cdef int fd + if self._ptr: + fd = self._ptr.backend_fd + if fd >= 0: + return fd + + property activecnt: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return self._ptr.activecnt + + property sig_pending: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return self._ptr.sig_pending + +#if EV_USE_SIGNALFD + property sigfd: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return self._ptr.sigfd +#endif + + property origflags: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return _flags_to_list(self._ptr.origflags) + + property origflags_int: + + def __get__(self): + + if not self._ptr: + raise ValueError('operation on destroyed loop') + return self._ptr.origflags + +#endif + + +cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback_Type]: + cdef public object callback + cdef public tuple args + + def __init__(self, callback, args): + self.callback = callback + self.args = args + + def stop(self): + self.callback = None + self.args = None + + # Note, that __nonzero__ and pending are different + # nonzero is used in contexts where we need to know whether to schedule another callback, + # so it's true if it's pending or currently running + # 'pending' has the same meaning as libev watchers: it is cleared before entering callback + + def __nonzero__(self): + # it's nonzero if it's pending or currently executing + return self.args is not None + + property pending: + + def __get__(self): + return self.callback is not None + + def __repr__(self): + if Py_ReprEnter(<PyObjectPtr>self) != 0: + return "<...>" + try: + format = self._format() + result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + if self.callback is None and self.args is None: + result += " stopped" + return result + ">" + finally: + Py_ReprLeave(<PyObjectPtr>self) + + def _format(self): + return '' + + + + +# about readonly _flags attribute: +# bit #1 set if object owns Python reference to itself (Py_INCREF was called and we must call Py_DECREF later) +# bit #2 set if ev_unref() was called and we must call ev_ref() later +# bit #3 set if user wants to call ev_unref() before start() + + + + + + + + + + + + + + +cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]: + """Abstract base class for all the watchers""" + + def __repr__(self): + if Py_ReprEnter(<PyObjectPtr>self) != 0: + return "<...>" + try: + format = self._format() + result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), format) + if self.active: + result += " active" + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + return result + ">" + finally: + Py_ReprLeave(<PyObjectPtr>self) + + def _format(self): + return '' + + +cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_io _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_io_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args, pass_events=False): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + if pass_events: + self.args = (GEVENT_CORE_EVENTS, ) + args + else: + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_io_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + +#ifdef _WIN32 + + def __init__(self, loop loop, libev.vfd_socket_t fd, int events, ref=True, priority=None): + if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): + raise ValueError('illegal event mask: %r' % events) + cdef int vfd = libev.vfd_open(fd) + libev.vfd_free(self._watcher.fd) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, events) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + +#else + + def __init__(self, loop loop, int fd, int events, ref=True, priority=None): + if fd < 0: + raise ValueError('fd must be non-negative: %r' % fd) + if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): + raise ValueError('illegal event mask: %r' % events) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, fd, events) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + +#endif + + property fd: + + def __get__(self): + return libev.vfd_get(self._watcher.fd) + + def __set__(self, long fd): + if libev.ev_is_active(&self._watcher): + raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") + cdef int vfd = libev.vfd_open(fd) + libev.vfd_free(self._watcher.fd) + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events) + + property events: + + def __get__(self): + return self._watcher.events + + def __set__(self, int events): + if libev.ev_is_active(&self._watcher): + raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") + libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events) + + property events_str: + + def __get__(self): + return _events_to_str(self._watcher.events) + + def _format(self): + return ' fd=%s events=%s' % (self.fd, self.events_str) + +#ifdef _WIN32 + + def __cinit__(self): + self._watcher.fd = -1; + + def __dealloc__(self): + libev.vfd_free(self._watcher.fd) + +#endif + + +cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_timer _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_timer_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args, update=True): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + if update: + libev.ev_now_update(self.loop._ptr) + libev.ev_timer_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + def __init__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None): + if repeat < 0.0: + raise ValueError("repeat must be positive or zero: %r" % repeat) + libev.ev_timer_init(&self._watcher, <void *>gevent_callback_timer, after, repeat) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + property at: + + def __get__(self): + return self._watcher.at + + # QQQ: add 'after' and 'repeat' properties? + + def again(self, object callback, *args, update=True): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + if update: + libev.ev_now_update(self.loop._ptr) + libev.ev_timer_again(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + +cdef public class signal(watcher) [object PyGeventSignalObject, type PyGeventSignal_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_signal _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_signal_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_signal_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + def __init__(self, loop loop, int signalnum, ref=True, priority=None): + if signalnum < 1 or signalnum >= signalmodule.NSIG: + raise ValueError('illegal signal number: %r' % signalnum) + # still possible to crash on one of libev's asserts: + # 1) "libev: ev_signal_start called with illegal signal number" + # EV_NSIG might be different from signal.NSIG on some platforms + # 2) "libev: a signal must not be attached to two different loops" + # we probably could check that in LIBEV_EMBED mode, but not in general + libev.ev_signal_init(&self._watcher, <void *>gevent_callback_signal, signalnum) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class idle(watcher) [object PyGeventIdleObject, type PyGeventIdle_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_idle _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_idle_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_idle_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + + def __init__(self, loop loop , ref=True, priority=None): + libev.ev_idle_init(&self._watcher, <void *>gevent_callback_idle ) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class prepare(watcher) [object PyGeventPrepareObject, type PyGeventPrepare_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_prepare _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_prepare_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_prepare_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + + def __init__(self, loop loop , ref=True, priority=None): + libev.ev_prepare_init(&self._watcher, <void *>gevent_callback_prepare ) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class check(watcher) [object PyGeventCheckObject, type PyGeventCheck_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_check _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_check_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_check_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + + def __init__(self, loop loop , ref=True, priority=None): + libev.ev_check_init(&self._watcher, <void *>gevent_callback_check ) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_fork _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_fork_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_fork_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + + def __init__(self, loop loop , ref=True, priority=None): + libev.ev_fork_init(&self._watcher, <void *>gevent_callback_fork ) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + +cdef public class async(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_async _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_async_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_async_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + property pending: + + def __get__(self): + return True if libev.ev_async_pending(&self._watcher) else False + + + def __init__(self, loop loop , ref=True, priority=None): + libev.ev_async_init(&self._watcher, <void *>gevent_callback_async ) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + def send(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + libev.ev_async_send(self.loop._ptr, &self._watcher) + +#ifdef _WIN32 +#else + +cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_child _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_child_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_child_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + + def __init__(self, loop loop, int pid, bint trace=0, ref=True): + if not loop.default: + raise TypeError('child watchers are only available on the default loop') + libev.gevent_install_sigchld_handler() + libev.ev_child_init(&self._watcher, <void *>gevent_callback_child, pid, trace) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + + def _format(self): + return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) + + property pid: + + def __get__(self): + return self._watcher.pid + + property rpid: + + def __get__(self): + return self._watcher.rpid + + def __set__(self, int value): + self._watcher.rpid = value + + property rstatus: + + def __get__(self): + return self._watcher.rstatus + + def __set__(self, int value): + self._watcher.rstatus = value + +#endif + + +cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Type]: + + + cdef public loop loop + cdef object _callback + cdef public tuple args + cdef readonly int _flags + cdef libev.ev_stat _watcher + + property ref: + + def __get__(self): + return False if self._flags & 4 else True + + def __set__(self, object value): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + libev.ev_ref(self.loop._ptr) + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(&self._watcher): + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + + property callback: + + def __get__(self): + return self._callback + + def __set__(self, object callback): + if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: + raise TypeError("Expected callable, not %r" % (callback, )) + self._callback = callback + + def stop(self): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if self._flags & 2: + libev.ev_ref(self.loop._ptr) + self._flags &= ~2 + libev.ev_stat_stop(self.loop._ptr, &self._watcher) + self._callback = None + self.args = None + if self._flags & 1: + Py_DECREF(<PyObjectPtr>self) + self._flags &= ~1 + + property priority: + + def __get__(self): + return libev.ev_priority(&self._watcher) + + def __set__(self, int priority): + if libev.ev_is_active(&self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(&self._watcher, priority) + + def feed(self, int revents, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + def start(self, object callback, *args): + + if not self.loop._ptr: + raise ValueError('operation on destroyed loop') + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args + if self._flags & 6 == 4: + libev.ev_unref(self.loop._ptr) + self._flags |= 2 + libev.ev_stat_start(self.loop._ptr, &self._watcher) + if not self._flags & 1: + Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + property active: + + def __get__(self): + return True if libev.ev_is_active(&self._watcher) else False + + + property pending: + + def __get__(self): + return True if libev.ev_is_pending(&self._watcher) else False + cdef readonly str path + cdef readonly bytes _paths + + def __init__(self, loop loop, str path, float interval=0.0, ref=True, priority=None): + self.path = path + cdef bytes paths + if isinstance(path, unicode): + # the famous Python3 filesystem encoding debacle hits us here. Can we do better? + # We must keep a reference to the encoded string so that its bytes don't get freed + # and overwritten, leading to strange errors from libev ("no such file or directory") + paths = (<unicode>path).encode(sys.getfilesystemencoding()) + self._paths = paths + else: + paths = <bytes>path + self._paths = paths + libev.ev_stat_init(&self._watcher, <void *>gevent_callback_stat, <char*>paths, interval) + self.loop = loop + if ref: + self._flags = 0 + else: + self._flags = 4 + if priority is not None: + libev.ev_set_priority(&self._watcher, priority) + + property attr: + + def __get__(self): + if not self._watcher.attr.st_nlink: + return + return _pystat_fromstructstat(&self._watcher.attr) + + property prev: + + def __get__(self): + if not self._watcher.prev.st_nlink: + return + return _pystat_fromstructstat(&self._watcher.prev) + + property interval: + + def __get__(self): + return self._watcher.interval + + +__SYSERR_CALLBACK = None + + +cdef void _syserr_cb(char* msg) with gil: + try: + __SYSERR_CALLBACK(msg, errno) + except: + set_syserr_cb(None) + print_exc = getattr(traceback, 'print_exc', None) + if print_exc is not None: + print_exc() + + +cpdef set_syserr_cb(callback): + global __SYSERR_CALLBACK + if callback is None: + libev.ev_set_syserr_cb(NULL) + __SYSERR_CALLBACK = None + elif callable(callback): + libev.ev_set_syserr_cb(<void *>_syserr_cb) + __SYSERR_CALLBACK = callback + else: + raise TypeError('Expected callable or None, got %r' % (callback, )) + + +#ifdef LIBEV_EMBED +LIBEV_EMBED = True +EV_USE_FLOOR = libev.EV_USE_FLOOR +EV_USE_CLOCK_SYSCALL = libev.EV_USE_CLOCK_SYSCALL +EV_USE_REALTIME = libev.EV_USE_REALTIME +EV_USE_MONOTONIC = libev.EV_USE_MONOTONIC +EV_USE_NANOSLEEP = libev.EV_USE_NANOSLEEP +EV_USE_INOTIFY = libev.EV_USE_INOTIFY +EV_USE_SIGNALFD = libev.EV_USE_SIGNALFD +EV_USE_EVENTFD = libev.EV_USE_EVENTFD +EV_USE_4HEAP = libev.EV_USE_4HEAP +#else +LIBEV_EMBED = False +#endif diff --git a/python/gevent/libev/corecffi.py b/python/gevent/libev/corecffi.py new file mode 100644 index 0000000..7283fb4 --- /dev/null +++ b/python/gevent/libev/corecffi.py @@ -0,0 +1,1132 @@ +# pylint:disable=too-many-lines, protected-access, redefined-outer-name, not-callable, +# pylint:disable=no-member +from __future__ import absolute_import, print_function +import sys +import os +import traceback +import signal as signalmodule + +# pylint:disable=undefined-all-variable +__all__ = [ + 'get_version', + 'get_header_version', + 'supported_backends', + 'recommended_backends', + 'embeddable_backends', + 'time', + 'loop', +] + +import gevent.libev._corecffi as _corecffi # pylint:disable=no-name-in-module + +ffi = _corecffi.ffi # pylint:disable=no-member +libev = _corecffi.lib # pylint:disable=no-member + +if hasattr(libev, 'vfd_open'): + # Must be on windows + assert sys.platform.startswith("win"), "vfd functions only needed on windows" + vfd_open = libev.vfd_open + vfd_free = libev.vfd_free + vfd_get = libev.vfd_get +else: + vfd_open = vfd_free = vfd_get = lambda fd: fd + +##### +## NOTE on Windows: +# The C implementation does several things specially for Windows; +# a possibly incomplete list is: +# +# - the loop runs a periodic signal checker; +# - the io watcher constructor is different and it has a destructor; +# - the child watcher is not defined +# +# The CFFI implementation does none of these things, and so +# is possibly NOT FUNCTIONALLY CORRECT on Win32 +##### + +##### +## Note on CFFI objects, callbacks and the lifecycle of watcher objects +# +# Each subclass of `watcher` allocates a C structure of the +# appropriate type e.g., struct gevent_ev_io and holds this pointer in +# its `_gwatcher` attribute. When that watcher instance is garbage +# collected, then the C structure is also freed. The C structure is +# passed to libev from the watcher's start() method and then to the +# appropriate C callback function, e.g., _gevent_ev_io_callback, which +# passes it back to python's _python_callback where we need the +# watcher instance. Therefore, as long as that callback is active (the +# watcher is started), the watcher instance must not be allowed to get +# GC'd---any access at the C level or even the FFI level to the freed +# memory could crash the process. +# +# However, the typical idiom calls for writing something like this: +# loop.io(fd, python_cb).start() +# thus forgetting the newly created watcher subclass and allowing it to be immediately +# GC'd. To combat this, when the watcher is started, it places itself into the loop's +# `_keepaliveset`, and it only removes itself when the watcher's `stop()` method is called. +# Often, this is the *only* reference keeping the watcher object, and hence its C structure, +# alive. +# +# This is slightly complicated by the fact that the python-level +# callback, called from the C callback, could choose to manually stop +# the watcher. When we return to the C level callback, we now have an +# invalid pointer, and attempting to pass it back to Python (e.g., to +# handle an error) could crash. Hence, _python_callback, +# _gevent_io_callback, and _python_handle_error cooperate to make sure +# that the watcher instance stays in the loops `_keepaliveset` while +# the C code could be running---and if it gets removed, to not call back +# to Python again. +# See also https://github.com/gevent/gevent/issues/676 +#### + + +@ffi.callback("int(void* handle, int revents)") +def _python_callback(handle, revents): + """ + Returns an integer having one of three values: + + - -1 + An exception occurred during the callback and you must call + :func:`_python_handle_error` to deal with it. The Python watcher + object will have the exception tuple saved in ``_exc_info``. + - 0 + Everything went according to plan. You should check to see if the libev + watcher is still active, and call :func:`_python_stop` if so. This will + clean up the memory. + - 1 + Everything went according to plan, but the watcher has already + been stopped. Its memory may no longer be valid. + """ + try: + # Even dereferencing the handle needs to be inside the try/except; + # if we don't return normally (e.g., a signal) then we wind up going + # to the 'onerror' handler, which + # is not what we want; that can permanently wedge the loop depending + # on which callback was executing + the_watcher = ffi.from_handle(handle) + args = the_watcher.args + if args is None: + # Legacy behaviour from corecext: convert None into () + # See test__core_watcher.py + args = _NOARGS + if args and args[0] == GEVENT_CORE_EVENTS: + args = (revents, ) + args[1:] + the_watcher.callback(*args) + except: # pylint:disable=bare-except + the_watcher._exc_info = sys.exc_info() + # Depending on when the exception happened, the watcher + # may or may not have been stopped. We need to make sure its + # memory stays valid so we can stop it at the ev level if needed. + the_watcher.loop._keepaliveset.add(the_watcher) + return -1 + else: + if the_watcher in the_watcher.loop._keepaliveset: + # It didn't stop itself + return 0 + return 1 # It stopped itself +libev.python_callback = _python_callback + + +@ffi.callback("void(void* handle, int revents)") +def _python_handle_error(handle, revents): + try: + watcher = ffi.from_handle(handle) + exc_info = watcher._exc_info + del watcher._exc_info + watcher.loop.handle_error(watcher, *exc_info) + finally: + # XXX Since we're here on an error condition, and we + # made sure that the watcher object was put in loop._keepaliveset, + # what about not stopping the watcher? Looks like a possible + # memory leak? + if revents & (libev.EV_READ | libev.EV_WRITE): + try: + watcher.stop() + except: # pylint:disable=bare-except + watcher.loop.handle_error(watcher, *sys.exc_info()) + return # pylint:disable=lost-exception +libev.python_handle_error = _python_handle_error + + +@ffi.callback("void(void* handle)") +def _python_stop(handle): + watcher = ffi.from_handle(handle) + watcher.stop() +libev.python_stop = _python_stop + + +UNDEF = libev.EV_UNDEF +NONE = libev.EV_NONE +READ = libev.EV_READ +WRITE = libev.EV_WRITE +TIMER = libev.EV_TIMER +PERIODIC = libev.EV_PERIODIC +SIGNAL = libev.EV_SIGNAL +CHILD = libev.EV_CHILD +STAT = libev.EV_STAT +IDLE = libev.EV_IDLE +PREPARE = libev.EV_PREPARE +CHECK = libev.EV_CHECK +EMBED = libev.EV_EMBED +FORK = libev.EV_FORK +CLEANUP = libev.EV_CLEANUP +ASYNC = libev.EV_ASYNC +CUSTOM = libev.EV_CUSTOM +ERROR = libev.EV_ERROR + +READWRITE = libev.EV_READ | libev.EV_WRITE + +MINPRI = libev.EV_MINPRI +MAXPRI = libev.EV_MAXPRI + +BACKEND_PORT = libev.EVBACKEND_PORT +BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE +BACKEND_EPOLL = libev.EVBACKEND_EPOLL +BACKEND_POLL = libev.EVBACKEND_POLL +BACKEND_SELECT = libev.EVBACKEND_SELECT +FORKCHECK = libev.EVFLAG_FORKCHECK +NOINOTIFY = libev.EVFLAG_NOINOTIFY +SIGNALFD = libev.EVFLAG_SIGNALFD +NOSIGMASK = libev.EVFLAG_NOSIGMASK + + +class _EVENTSType(object): + def __repr__(self): + return 'gevent.core.EVENTS' + +EVENTS = GEVENT_CORE_EVENTS = _EVENTSType() + + +def get_version(): + return 'libev-%d.%02d' % (libev.ev_version_major(), libev.ev_version_minor()) + + +def get_header_version(): + return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) + +_flags = [(libev.EVBACKEND_PORT, 'port'), + (libev.EVBACKEND_KQUEUE, 'kqueue'), + (libev.EVBACKEND_EPOLL, 'epoll'), + (libev.EVBACKEND_POLL, 'poll'), + (libev.EVBACKEND_SELECT, 'select'), + (libev.EVFLAG_NOENV, 'noenv'), + (libev.EVFLAG_FORKCHECK, 'forkcheck'), + (libev.EVFLAG_SIGNALFD, 'signalfd'), + (libev.EVFLAG_NOSIGMASK, 'nosigmask')] + +_flags_str2int = dict((string, flag) for (flag, string) in _flags) + +_events = [(libev.EV_READ, 'READ'), + (libev.EV_WRITE, 'WRITE'), + (libev.EV__IOFDSET, '_IOFDSET'), + (libev.EV_PERIODIC, 'PERIODIC'), + (libev.EV_SIGNAL, 'SIGNAL'), + (libev.EV_CHILD, 'CHILD'), + (libev.EV_STAT, 'STAT'), + (libev.EV_IDLE, 'IDLE'), + (libev.EV_PREPARE, 'PREPARE'), + (libev.EV_CHECK, 'CHECK'), + (libev.EV_EMBED, 'EMBED'), + (libev.EV_FORK, 'FORK'), + (libev.EV_CLEANUP, 'CLEANUP'), + (libev.EV_ASYNC, 'ASYNC'), + (libev.EV_CUSTOM, 'CUSTOM'), + (libev.EV_ERROR, 'ERROR')] + + +def _flags_to_list(flags): + result = [] + for code, value in _flags: + if flags & code: + result.append(value) + flags &= ~code + if not flags: + break + if flags: + result.append(flags) + return result + +if sys.version_info[0] >= 3: + basestring = (bytes, str) + integer_types = (int,) +else: + import __builtin__ # pylint:disable=import-error + basestring = __builtin__.basestring, + integer_types = (int, __builtin__.long) + + +def _flags_to_int(flags): + # Note, that order does not matter, libev has its own predefined order + if not flags: + return 0 + if isinstance(flags, integer_types): + return flags + result = 0 + try: + if isinstance(flags, basestring): + flags = flags.split(',') + for value in flags: + value = value.strip().lower() + if value: + result |= _flags_str2int[value] + except KeyError as ex: + raise ValueError('Invalid backend or flag: %s\nPossible values: %s' % (ex, ', '.join(sorted(_flags_str2int.keys())))) + return result + + +def _str_hex(flag): + if isinstance(flag, integer_types): + return hex(flag) + return str(flag) + + +def _check_flags(flags): + as_list = [] + flags &= libev.EVBACKEND_MASK + if not flags: + return + if not flags & libev.EVBACKEND_ALL: + raise ValueError('Invalid value for backend: 0x%x' % flags) + if not flags & libev.ev_supported_backends(): + as_list = [_str_hex(x) for x in _flags_to_list(flags)] + raise ValueError('Unsupported backend: %s' % '|'.join(as_list)) + + +def _events_to_str(events): + result = [] + for (flag, string) in _events: + c_flag = flag + if events & c_flag: + result.append(string) + events = events & (~c_flag) + if not events: + break + if events: + result.append(hex(events)) + return '|'.join(result) + + +def supported_backends(): + return _flags_to_list(libev.ev_supported_backends()) + + +def recommended_backends(): + return _flags_to_list(libev.ev_recommended_backends()) + + +def embeddable_backends(): + return _flags_to_list(libev.ev_embeddable_backends()) + + +def time(): + return libev.ev_time() + +_default_loop_destroyed = False + + +def _loop_callback(*args, **kwargs): + return ffi.callback(*args, **kwargs) + + +class loop(object): + # pylint:disable=too-many-public-methods + + error_handler = None + + def __init__(self, flags=None, default=None): + self._in_callback = False + self._callbacks = [] + + # self._check is a watcher that runs in each iteration of the + # mainloop, just after the blocking call + self._check = ffi.new("struct ev_check *") + self._check_callback_ffi = _loop_callback("void(*)(struct ev_loop *, void*, int)", + self._check_callback, + onerror=self._check_callback_handle_error) + libev.ev_check_init(self._check, self._check_callback_ffi) + + # self._prepare is a watcher that runs in each iteration of the mainloop, + # just before the blocking call + self._prepare = ffi.new("struct ev_prepare *") + self._prepare_callback_ffi = _loop_callback("void(*)(struct ev_loop *, void*, int)", + self._run_callbacks, + onerror=self._check_callback_handle_error) + libev.ev_prepare_init(self._prepare, self._prepare_callback_ffi) + + # A timer we start and stop on demand. If we have callbacks, + # too many to run in one iteration of _run_callbacks, we turn this + # on so as to have the next iteration of the run loop return to us + # as quickly as possible. + # TODO: There may be a more efficient way to do this using ev_timer_again; + # see the "ev_timer" section of the ev manpage (http://linux.die.net/man/3/ev) + self._timer0 = ffi.new("struct ev_timer *") + libev.ev_timer_init(self._timer0, libev.gevent_noop, 0.0, 0.0) + + # TODO: We may be able to do something nicer and use the existing python_callback + # combined with onerror and the class check/timer/prepare to simplify things + # and unify our handling + + c_flags = _flags_to_int(flags) + _check_flags(c_flags) + c_flags |= libev.EVFLAG_NOENV + c_flags |= libev.EVFLAG_FORKCHECK + if default is None: + default = True + if _default_loop_destroyed: + default = False + if default: + self._ptr = libev.gevent_ev_default_loop(c_flags) + if not self._ptr: + raise SystemError("ev_default_loop(%s) failed" % (c_flags, )) + + else: + self._ptr = libev.ev_loop_new(c_flags) + if not self._ptr: + raise SystemError("ev_loop_new(%s) failed" % (c_flags, )) + if default or globals()["__SYSERR_CALLBACK"] is None: + set_syserr_cb(self._handle_syserr) + + libev.ev_prepare_start(self._ptr, self._prepare) + self.unref() + libev.ev_check_start(self._ptr, self._check) + self.unref() + + self._keepaliveset = set() + + def _check_callback_handle_error(self, t, v, tb): + # None as the context argument causes the exception to be raised + # in the main greenlet. + self.handle_error(None, t, v, tb) + + def _check_callback(self, *args): + # If we have the onerror callback, this is a no-op; all the real + # work to rethrow the exception is done by the onerror callback + pass + + def _run_callbacks(self, _evloop, _, _revents): + count = 1000 + libev.ev_timer_stop(self._ptr, self._timer0) + while self._callbacks and count > 0: + callbacks = self._callbacks + self._callbacks = [] + for cb in callbacks: + self.unref() + callback = cb.callback + args = cb.args + if callback is None or args is None: + # it's been stopped + continue + + cb.callback = None + + try: + callback(*args) + except: # pylint:disable=bare-except + # If we allow an exception to escape this method (while we are running the ev callback), + # then CFFI will print the error and libev will continue executing. + # There are two problems with this. The first is that the code after + # the loop won't run. The second is that any remaining callbacks scheduled + # for this loop iteration will be silently dropped; they won't run, but they'll + # also not be *stopped* (which is not a huge deal unless you're looking for + # consistency or checking the boolean/pending status; the loop doesn't keep + # a reference to them like it does to watchers...*UNLESS* the callback itself had + # a reference to a watcher; then I don't know what would happen, it depends on + # the state of the watcher---a leak or crash is not totally inconceivable). + # The Cython implementation in core.ppyx uses gevent_call from callbacks.c + # to run the callback, which uses gevent_handle_error to handle any errors the + # Python callback raises...it unconditionally simply prints any error raised + # by loop.handle_error and clears it, so callback handling continues. + # We take a similar approach (but are extra careful about printing) + try: + self.handle_error(cb, *sys.exc_info()) + except: # pylint:disable=bare-except + try: + print("Exception while handling another error", file=sys.stderr) + traceback.print_exc() + except: # pylint:disable=bare-except + pass # Nothing we can do here + finally: + # NOTE: this must be reset here, because cb.args is used as a flag in + # the callback class so that bool(cb) of a callback that has been run + # becomes False + cb.args = None + count -= 1 + if self._callbacks: + libev.ev_timer_start(self._ptr, self._timer0) + + def _stop_aux_watchers(self): + if libev.ev_is_active(self._prepare): + self.ref() + libev.ev_prepare_stop(self._ptr, self._prepare) + if libev.ev_is_active(self._check): + self.ref() + libev.ev_check_stop(self._ptr, self._check) + + def destroy(self): + global _default_loop_destroyed + if self._ptr: + self._stop_aux_watchers() + if globals()["__SYSERR_CALLBACK"] == self._handle_syserr: + set_syserr_cb(None) + if libev.ev_is_default_loop(self._ptr): + _default_loop_destroyed = True + libev.ev_loop_destroy(self._ptr) + self._ptr = ffi.NULL + + @property + def ptr(self): + return self._ptr + + @property + def WatcherType(self): + return watcher + + @property + def MAXPRI(self): + return libev.EV_MAXPRI + + @property + def MINPRI(self): + return libev.EV_MINPRI + + def _handle_syserr(self, message, errno): + try: + errno = os.strerror(errno) + except: # pylint:disable=bare-except + traceback.print_exc() + try: + message = '%s: %s' % (message, errno) + except: # pylint:disable=bare-except + traceback.print_exc() + self.handle_error(None, SystemError, SystemError(message), None) + + def handle_error(self, context, type, value, tb): + handle_error = None + error_handler = self.error_handler + if error_handler is not None: + # we do want to do getattr every time so that setting Hub.handle_error property just works + handle_error = getattr(error_handler, 'handle_error', error_handler) + handle_error(context, type, value, tb) + else: + self._default_handle_error(context, type, value, tb) + + def _default_handle_error(self, context, type, value, tb): # pylint:disable=unused-argument + # note: Hub sets its own error handler so this is not used by gevent + # this is here to make core.loop usable without the rest of gevent + traceback.print_exception(type, value, tb) + libev.ev_break(self._ptr, libev.EVBREAK_ONE) + + def run(self, nowait=False, once=False): + flags = 0 + if nowait: + flags |= libev.EVRUN_NOWAIT + if once: + flags |= libev.EVRUN_ONCE + + libev.ev_run(self._ptr, flags) + + def reinit(self): + libev.ev_loop_fork(self._ptr) + + def ref(self): + libev.ev_ref(self._ptr) + + def unref(self): + libev.ev_unref(self._ptr) + + def break_(self, how=libev.EVBREAK_ONE): + libev.ev_break(self._ptr, how) + + def verify(self): + libev.ev_verify(self._ptr) + + def now(self): + return libev.ev_now(self._ptr) + + def update(self): + libev.ev_now_update(self._ptr) + + def __repr__(self): + return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self._format()) + + @property + def default(self): + return True if libev.ev_is_default_loop(self._ptr) else False + + @property + def iteration(self): + return libev.ev_iteration(self._ptr) + + @property + def depth(self): + return libev.ev_depth(self._ptr) + + @property + def backend_int(self): + return libev.ev_backend(self._ptr) + + @property + def backend(self): + backend = libev.ev_backend(self._ptr) + for key, value in _flags: + if key == backend: + return value + return backend + + @property + def pendingcnt(self): + return libev.ev_pending_count(self._ptr) + + def io(self, fd, events, ref=True, priority=None): + return io(self, fd, events, ref, priority) + + def timer(self, after, repeat=0.0, ref=True, priority=None): + return timer(self, after, repeat, ref, priority) + + def signal(self, signum, ref=True, priority=None): + return signal(self, signum, ref, priority) + + def idle(self, ref=True, priority=None): + return idle(self, ref, priority) + + def prepare(self, ref=True, priority=None): + return prepare(self, ref, priority) + + def check(self, ref=True, priority=None): + return check(self, ref, priority) + + def fork(self, ref=True, priority=None): + return fork(self, ref, priority) + + def async(self, ref=True, priority=None): + return async(self, ref, priority) + + if sys.platform != "win32": + + def child(self, pid, trace=0, ref=True): + return child(self, pid, trace, ref) + + def install_sigchld(self): + libev.gevent_install_sigchld_handler() + + def reset_sigchld(self): + libev.gevent_reset_sigchld_handler() + + def stat(self, path, interval=0.0, ref=True, priority=None): + return stat(self, path, interval, ref, priority) + + def callback(self, priority=None): + return callback(self, priority) + + def run_callback(self, func, *args): + cb = callback(func, args) + self._callbacks.append(cb) + self.ref() + + return cb + + def _format(self): + if not self._ptr: + return 'destroyed' + msg = self.backend + if self.default: + msg += ' default' + msg += ' pending=%s' % self.pendingcnt + msg += self._format_details() + return msg + + def _format_details(self): + msg = '' + fileno = self.fileno() + try: + activecnt = self.activecnt + except AttributeError: + activecnt = None + if activecnt is not None: + msg += ' ref=' + repr(activecnt) + if fileno is not None: + msg += ' fileno=' + repr(fileno) + #if sigfd is not None and sigfd != -1: + # msg += ' sigfd=' + repr(sigfd) + return msg + + def fileno(self): + if self._ptr: + fd = self._ptr.backend_fd + if fd >= 0: + return fd + + @property + def activecnt(self): + if not self._ptr: + raise ValueError('operation on destroyed loop') + return self._ptr.activecnt + +# For times when *args is captured but often not passed (empty), +# we can avoid keeping the new tuple that was created for *args +# around by using a constant. +_NOARGS = () + + +class callback(object): + + __slots__ = ('callback', 'args') + + def __init__(self, callback, args): + self.callback = callback + self.args = args or _NOARGS + + def stop(self): + self.callback = None + self.args = None + + # Note that __nonzero__ and pending are different + # bool() is used in contexts where we need to know whether to schedule another callback, + # so it's true if it's pending or currently running + # 'pending' has the same meaning as libev watchers: it is cleared before actually + # running the callback + + def __nonzero__(self): + # it's nonzero if it's pending or currently executing + # NOTE: This depends on loop._run_callbacks setting the args property + # to None. + return self.args is not None + __bool__ = __nonzero__ + + @property + def pending(self): + return self.callback is not None + + def _format(self): + return '' + + def __repr__(self): + result = "<%s at 0x%x" % (self.__class__.__name__, id(self)) + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + if self.callback is None and self.args is None: + result += " stopped" + return result + ">" + + +class watcher(object): + + def __init__(self, _loop, ref=True, priority=None, args=_NOARGS): + self.loop = _loop + if ref: + self._flags = 0 + else: + self._flags = 4 + self._args = None + self._callback = None + self._handle = ffi.new_handle(self) + + self._watcher = ffi.new(self._watcher_struct_pointer_type) + self._watcher.data = self._handle + if priority is not None: + libev.ev_set_priority(self._watcher, priority) + self._watcher_init(self._watcher, + self._watcher_callback, + *args) + + # A string identifying the type of libev object we watch, e.g., 'ev_io' + # This should be a class attribute. + _watcher_type = None + # A class attribute that is the callback on the libev object that init's the C struct, + # e.g., libev.ev_io_init. If None, will be set by _init_subclasses. + _watcher_init = None + # A class attribute that is the callback on the libev object that starts the C watcher, + # e.g., libev.ev_io_start. If None, will be set by _init_subclasses. + _watcher_start = None + # A class attribute that is the callback on the libev object that stops the C watcher, + # e.g., libev.ev_io_stop. If None, will be set by _init_subclasses. + _watcher_stop = None + # A cffi ctype object identifying the struct pointer we create. + # This is a class attribute set based on the _watcher_type + _watcher_struct_pointer_type = None + # The attribute of the libev object identifying the custom + # callback function for this type of watcher. This is a class + # attribute set based on the _watcher_type in _init_subclasses. + _watcher_callback = None + + @classmethod + def _init_subclasses(cls): + for subclass in cls.__subclasses__(): # pylint:disable=no-member + watcher_type = subclass._watcher_type + subclass._watcher_struct_pointer_type = ffi.typeof('struct ' + watcher_type + '*') + subclass._watcher_callback = ffi.addressof(libev, + '_gevent_generic_callback') + for name in 'start', 'stop', 'init': + ev_name = watcher_type + '_' + name + watcher_name = '_watcher' + '_' + name + if getattr(subclass, watcher_name) is None: + setattr(subclass, watcher_name, + getattr(libev, ev_name)) + + # this is not needed, since we keep alive the watcher while it's started + #def __del__(self): + # self._watcher_stop(self.loop._ptr, self._watcher) + + def __repr__(self): + formats = self._format() + result = "<%s at 0x%x%s" % (self.__class__.__name__, id(self), formats) + if self.pending: + result += " pending" + if self.callback is not None: + result += " callback=%r" % (self.callback, ) + if self.args is not None: + result += " args=%r" % (self.args, ) + if self.callback is None and self.args is None: + result += " stopped" + result += " handle=%s" % (self._watcher.data) + return result + ">" + + def _format(self): + return '' + + def _libev_unref(self): + if self._flags & 6 == 4: + self.loop.unref() + self._flags |= 2 + + def _get_ref(self): + return False if self._flags & 4 else True + + def _set_ref(self, value): + if value: + if not self._flags & 4: + return # ref is already True + if self._flags & 2: # ev_unref was called, undo + self.loop.ref() + self._flags &= ~6 # do not want unref, no outstanding unref + else: + if self._flags & 4: + return # ref is already False + self._flags |= 4 + if not self._flags & 2 and libev.ev_is_active(self._watcher): + self.loop.unref() + self._flags |= 2 + + ref = property(_get_ref, _set_ref) + + def _get_callback(self): + return self._callback + + def _set_callback(self, cb): + if not callable(cb) and cb is not None: + raise TypeError("Expected callable, not %r" % (cb, )) + self._callback = cb + callback = property(_get_callback, _set_callback) + + def _get_args(self): + return self._args + + def _set_args(self, args): + if not isinstance(args, tuple) and args is not None: + raise TypeError("args must be a tuple or None") + self._args = args + + args = property(_get_args, _set_args) + + def start(self, callback, *args): + if callback is None: + raise TypeError('callback must be callable, not None') + self.callback = callback + self.args = args or _NOARGS + self._libev_unref() + self.loop._keepaliveset.add(self) + self._watcher_start(self.loop._ptr, self._watcher) + + def stop(self): + if self._flags & 2: + self.loop.ref() + self._flags &= ~2 + self._watcher_stop(self.loop._ptr, self._watcher) + self.loop._keepaliveset.discard(self) + self._callback = None + self.args = None + + def _get_priority(self): + return libev.ev_priority(self._watcher) + + def _set_priority(self, priority): + if libev.ev_is_active(self._watcher): + raise AttributeError("Cannot set priority of an active watcher") + libev.ev_set_priority(self._watcher, priority) + + priority = property(_get_priority, _set_priority) + + def feed(self, revents, callback, *args): + self.callback = callback + self.args = args or _NOARGS + if self._flags & 6 == 4: + self.loop.unref() + self._flags |= 2 + libev.ev_feed_event(self.loop._ptr, self._watcher, revents) + if not self._flags & 1: + # Py_INCREF(<PyObjectPtr>self) + self._flags |= 1 + + @property + def active(self): + return True if libev.ev_is_active(self._watcher) else False + + @property + def pending(self): + return True if libev.ev_is_pending(self._watcher) else False + + +class io(watcher): + _watcher_type = 'ev_io' + + def __init__(self, loop, fd, events, ref=True, priority=None): + # XXX: Win32: Need to vfd_open the fd and free the old one? + # XXX: Win32: Need a destructor to free the old fd? + if fd < 0: + raise ValueError('fd must be non-negative: %r' % fd) + if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE): + raise ValueError('illegal event mask: %r' % events) + watcher.__init__(self, loop, ref=ref, priority=priority, args=(fd, events)) + + def start(self, callback, *args, **kwargs): + # pylint:disable=arguments-differ + args = args or _NOARGS + if kwargs.get('pass_events'): + args = (GEVENT_CORE_EVENTS, ) + args + watcher.start(self, callback, *args) + + def _get_fd(self): + return vfd_get(self._watcher.fd) + + def _set_fd(self, fd): + if libev.ev_is_active(self._watcher): + raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active") + vfd = vfd_open(fd) + vfd_free(self._watcher.fd) + self._watcher_init(self._watcher, self._watcher_callback, vfd, self._watcher.events) + + fd = property(_get_fd, _set_fd) + + def _get_events(self): + return self._watcher.events + + def _set_events(self, events): + if libev.ev_is_active(self._watcher): + raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active") + self._watcher_init(self._watcher, self._watcher_callback, self._watcher.fd, events) + + events = property(_get_events, _set_events) + + @property + def events_str(self): + return _events_to_str(self._watcher.events) + + def _format(self): + return ' fd=%s events=%s' % (self.fd, self.events_str) + + +class timer(watcher): + _watcher_type = 'ev_timer' + + def __init__(self, loop, after=0.0, repeat=0.0, ref=True, priority=None): + if repeat < 0.0: + raise ValueError("repeat must be positive or zero: %r" % repeat) + watcher.__init__(self, loop, ref=ref, priority=priority, args=(after, repeat)) + + def start(self, callback, *args, **kw): + # pylint:disable=arguments-differ + update = kw.get("update", True) + if update: + # Quoth the libev doc: "This is a costly operation and is + # usually done automatically within ev_run(). This + # function is rarely useful, but when some event callback + # runs for a very long time without entering the event + # loop, updating libev's idea of the current time is a + # good idea." + # So do we really need to default to true? + libev.ev_now_update(self.loop._ptr) + watcher.start(self, callback, *args) + + @property + def at(self): + return self._watcher.at + + def again(self, callback, *args, **kw): + # Exactly the same as start(), just with a different initializer + # function + self._watcher_start = libev.ev_timer_again + try: + self.start(callback, *args, **kw) + finally: + del self._watcher_start + + +class signal(watcher): + _watcher_type = 'ev_signal' + + def __init__(self, loop, signalnum, ref=True, priority=None): + if signalnum < 1 or signalnum >= signalmodule.NSIG: + raise ValueError('illegal signal number: %r' % signalnum) + # still possible to crash on one of libev's asserts: + # 1) "libev: ev_signal_start called with illegal signal number" + # EV_NSIG might be different from signal.NSIG on some platforms + # 2) "libev: a signal must not be attached to two different loops" + # we probably could check that in LIBEV_EMBED mode, but not in general + watcher.__init__(self, loop, ref=ref, priority=priority, args=(signalnum, )) + + +class idle(watcher): + _watcher_type = 'ev_idle' + + +class prepare(watcher): + _watcher_type = 'ev_prepare' + + +class check(watcher): + _watcher_type = 'ev_check' + + +class fork(watcher): + _watcher_type = 'ev_fork' + + +class async(watcher): + _watcher_type = 'ev_async' + + def send(self): + libev.ev_async_send(self.loop._ptr, self._watcher) + + @property + def pending(self): + return True if libev.ev_async_pending(self._watcher) else False + + +class child(watcher): + _watcher_type = 'ev_child' + + def __init__(self, loop, pid, trace=0, ref=True): + if not loop.default: + raise TypeError('child watchers are only available on the default loop') + loop.install_sigchld() + watcher.__init__(self, loop, ref=ref, args=(pid, trace)) + + def _format(self): + return ' pid=%r rstatus=%r' % (self.pid, self.rstatus) + + @property + def pid(self): + return self._watcher.pid + + @property + def rpid(self, ): + return self._watcher.rpid + + @rpid.setter + def rpid(self, value): + self._watcher.rpid = value + + @property + def rstatus(self): + return self._watcher.rstatus + + @rstatus.setter + def rstatus(self, value): + self._watcher.rstatus = value + + +class stat(watcher): + _watcher_type = 'ev_stat' + + @staticmethod + def _encode_path(path): + if isinstance(path, bytes): + return path + + # encode for the filesystem. Not all systems (e.g., Unix) + # will have an encoding specified + encoding = sys.getfilesystemencoding() or 'utf-8' + try: + path = path.encode(encoding, 'surrogateescape') + except LookupError: + # Can't encode it, and the error handler doesn't + # exist. Probably on Python 2 with an astral character. + # Not sure how to handle this. + raise UnicodeEncodeError("Can't encode path to filesystem encoding") + return path + + def __init__(self, _loop, path, interval=0.0, ref=True, priority=None): + # Store the encoded path in the same attribute that corecext does + self._paths = self._encode_path(path) + + # Keep the original path to avoid re-encoding, especially on Python 3 + self._path = path + + # Although CFFI would automatically convert a bytes object into a char* when + # calling ev_stat_init(..., char*, ...), on PyPy the char* pointer is not + # guaranteed to live past the function call. On CPython, only with a constant/interned + # bytes object is the pointer guaranteed to last path the function call. (And since + # Python 3 is pretty much guaranteed to produce a newly-encoded bytes object above, thats + # rarely the case). Therefore, we must keep a reference to the produced cdata object + # so that the struct ev_stat_watcher's `path` pointer doesn't become invalid/deallocated + self._cpath = ffi.new('char[]', self._paths) + + watcher.__init__(self, _loop, ref=ref, priority=priority, + args=(self._cpath, + interval)) + + @property + def path(self): + return self._path + + @property + def attr(self): + if not self._watcher.attr.st_nlink: + return + return self._watcher.attr + + @property + def prev(self): + if not self._watcher.prev.st_nlink: + return + return self._watcher.prev + + @property + def interval(self): + return self._watcher.interval + +# All watcher subclasses must be declared above. Now we do some +# initialization; this is not only a minor optimization, it protects +# against later runtime typos and attribute errors +watcher._init_subclasses() + + +def _syserr_cb(msg): + try: + msg = ffi.string(msg) + __SYSERR_CALLBACK(msg, ffi.errno) + except: + set_syserr_cb(None) + raise # let cffi print the traceback + +_syserr_cb._cb = ffi.callback("void(*)(char *msg)", _syserr_cb) + + +def set_syserr_cb(callback): + global __SYSERR_CALLBACK + if callback is None: + libev.ev_set_syserr_cb(ffi.NULL) + __SYSERR_CALLBACK = None + elif callable(callback): + libev.ev_set_syserr_cb(_syserr_cb._cb) + __SYSERR_CALLBACK = callback + else: + raise TypeError('Expected callable or None, got %r' % (callback, )) + +__SYSERR_CALLBACK = None + +LIBEV_EMBED = True diff --git a/python/gevent/libev/gevent.corecext.c b/python/gevent/libev/gevent.corecext.c new file mode 100644 index 0000000..d118d59 --- /dev/null +++ b/python/gevent/libev/gevent.corecext.c @@ -0,0 +1,33465 @@ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +/* Generated by cythonpp.py on 2017-06-05 11:30:19 */ +/* Generated by Cython 0.25.2 */ +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. +#else +#define CYTHON_ABI "0_25_2" +#include <stddef.h> +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #elif defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include <math.h> +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__gevent__libev__corecext +#define __PYX_HAVE_API__gevent__libev__corecext +#include "libev_vfd.h" +#include "libev.h" +#include "frameobject.h" +#include "callbacks.h" +#include "stathelper.c" +#ifdef _OPENMP +#include <omp.h> +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include <cstdlib> + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) && defined (_M_X64) + #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + + +static const char *__pyx_f[] = { + "gevent.libev.corecext.pyx", +}; + +/*--- Type declarations ---*/ +struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType; +struct PyGeventLoopObject; +struct PyGeventCallbackObject; +struct PyGeventWatcherObject; +struct PyGeventIOObject; +struct PyGeventTimerObject; +struct PyGeventSignalObject; +struct PyGeventIdleObject; +struct PyGeventPrepareObject; +struct PyGeventCheckObject; +struct PyGeventForkObject; +struct PyGeventAsyncObject; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +struct PyGeventChildObject; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +struct PyGeventStatObject; +struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr; + +struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType { + PyObject_HEAD +}; + + +struct PyGeventLoopObject { + PyObject_HEAD + struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *__pyx_vtab; + struct ev_loop *_ptr; + PyObject *error_handler; + struct ev_prepare _prepare; + PyObject *_callbacks; + struct ev_timer _timer0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + struct ev_timer _periodic_signal_checker; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type; + +struct PyGeventCallbackObject { + PyObject_HEAD + PyObject *callback; + PyObject *args; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCallback_Type; + +struct PyGeventWatcherObject { + PyObject_HEAD +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventWatcher_Type; + +struct PyGeventIOObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_io _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIO_Type; + +struct PyGeventTimerObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_timer _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventTimer_Type; + +struct PyGeventSignalObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_signal _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventSignal_Type; + +struct PyGeventIdleObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_idle _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventIdle_Type; + +struct PyGeventPrepareObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_prepare _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventPrepare_Type; + +struct PyGeventCheckObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_check _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventCheck_Type; + +struct PyGeventForkObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_fork _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventFork_Type; + +struct PyGeventAsyncObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_async _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAsync_Type; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + +struct PyGeventChildObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_child _watcher; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventChild_Type; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + +struct PyGeventStatObject { + struct PyGeventWatcherObject __pyx_base; + struct PyGeventLoopObject *loop; + PyObject *_callback; + PyObject *args; + int _flags; + struct ev_stat _watcher; + PyObject *path; + PyObject *_paths; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventStat_Type; + +struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr { + PyObject_HEAD + PyObject *__pyx_v_flag; + PyObject *__pyx_v_string; +}; + + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventLoop_Type; + + +struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop { + PyObject *(*_run_callbacks)(struct PyGeventLoopObject *); + PyObject *(*handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); + PyObject *(*_default_handle_error)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *__pyx_vtabptr_6gevent_5libev_8corecext_loop; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* IterFinish.proto */ +static CYTHON_INLINE int __Pyx_IterFinish(void); + +/* UnpackItemEndCheck.proto */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#endif + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* StringJoin.proto */ +#if PY_MAJOR_VERSION < 3 +#define __Pyx_PyString_Join __Pyx_PyBytes_Join +#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v)) +#else +#define __Pyx_PyString_Join PyUnicode_Join +#define __Pyx_PyBaseString_Join PyUnicode_Join +#endif +#if CYTHON_COMPILING_IN_CPYTHON + #if PY_MAJOR_VERSION < 3 + #define __Pyx_PyBytes_Join _PyString_Join + #else + #define __Pyx_PyBytes_Join _PyBytes_Join + #endif +#else +static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* ListCompAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* GetAttr.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); + +/* GetAttr3.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); + +/* ArgTypeTest.proto */ +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* PyObjectSetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +/* KeywordStringCheck.proto */ +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* CallableCheck.proto */ +#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) +#else +#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) +#endif + +/* CallNextTpTraverse.proto */ +static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); + +/* CallNextTpClear.proto */ +static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); + +/* IncludeStringH.proto */ +#include <string.h> + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_vfd_socket_t(vfd_socket_t value); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + +/* CIntFromPy.proto */ +static CYTHON_INLINE vfd_socket_t __Pyx_PyInt_As_vfd_socket_t(PyObject *); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FetchCommonType.proto */ +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/* PyObjectCallMethod1.proto */ +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); + +/* CoroutineBase.proto */ +typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *); +typedef struct { + PyObject_HEAD + __pyx_coroutine_body_t body; + PyObject *closure; + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; + PyObject *gi_weakreflist; + PyObject *classobj; + PyObject *yieldfrom; + PyObject *gi_name; + PyObject *gi_qualname; + PyObject *gi_modulename; + int resume_label; + char is_running; +} __pyx_CoroutineObject; +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); +static int __Pyx_Coroutine_clear(PyObject *self); +#if 1 || PY_VERSION_HEX < 0x030300B0 +static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); +#else +#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) +#endif + +/* PatchModuleWithCoroutine.proto */ +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); + +/* PatchGeneratorABC.proto */ +static int __Pyx_patch_abc(void); + +/* Generator.proto */ +#define __Pyx_Generator_USED +static PyTypeObject *__pyx_GeneratorType = 0; +#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) +#define __Pyx_Generator_New(body, closure, name, qualname, module_name)\ + __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname, module_name) +static PyObject *__Pyx_Generator_Next(PyObject *self); +static int __pyx_Generator_init(void); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self); /* proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/ + +/* Module declarations from 'cython' */ + +/* Module declarations from 'libev' */ + +/* Module declarations from 'python' */ + +/* Module declarations from 'gevent.libev.corecext' */ +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext__EVENTSType = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_loop = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_callback = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_watcher = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_io = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_timer = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_signal = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_idle = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_prepare = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_check = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_fork = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_async = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_child = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext_stat = 0; +static PyTypeObject *__pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = 0; +static PyObject *__pyx_v_6gevent_5libev_8corecext_integer_types = 0; +__PYX_EXTERN_C DL_EXPORT(PyObject) *GEVENT_CORE_EVENTS; +static int __pyx_v_6gevent_5libev_8corecext__default_loop_destroyed; +static PyObject *__pyx_f_6gevent_5libev_8corecext__flags_to_list(unsigned int, int __pyx_skip_dispatch); /*proto*/ +static unsigned int __pyx_f_6gevent_5libev_8corecext__flags_to_int(PyObject *, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__str_hex(PyObject *); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__check_flags(unsigned int, int __pyx_skip_dispatch); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__events_to_str(int, int __pyx_skip_dispatch); /*proto*/ +static void __pyx_f_6gevent_5libev_8corecext__syserr_cb(char *); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_set_syserr_cb(PyObject *, int __pyx_skip_dispatch); /*proto*/ +#define __Pyx_MODULE_NAME "gevent.libev.corecext" +int __pyx_module_is_main_gevent__libev__corecext = 0; + +/* Implementation of 'gevent.libev.corecext' */ +static PyObject *__pyx_builtin___import__; +static PyObject *__pyx_builtin_KeyError; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_hex; +static PyObject *__pyx_builtin_SystemError; +static PyObject *__pyx_builtin_id; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_builtin_AttributeError; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_builtin_TypeError; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_builtin_AttributeError; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_[] = ","; +static const char __pyx_k__3[] = ", "; +static const char __pyx_k__4[] = "|"; +static const char __pyx_k__5[] = ": "; +static const char __pyx_k_fd[] = "fd"; +static const char __pyx_k_id[] = "id"; +static const char __pyx_k_os[] = "os"; +static const char __pyx_k_tb[] = "tb"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static const char __pyx_k__21[] = "<...>"; +static const char __pyx_k__22[] = ">"; +static const char __pyx_k__23[] = ""; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k__21[] = ""; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static const char __pyx_k__27[] = "<...>"; +static const char __pyx_k__28[] = ">"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k__26[] = "<...>"; +static const char __pyx_k__27[] = ">"; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_all[] = "__all__"; +static const char __pyx_k_hex[] = "hex"; +static const char __pyx_k_how[] = "how"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_pid[] = "pid"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_ptr[] = "ptr"; +static const char __pyx_k_ref[] = "ref"; +static const char __pyx_k_sys[] = "sys"; +static const char __pyx_k_FORK[] = "FORK"; +static const char __pyx_k_IDLE[] = "IDLE"; +static const char __pyx_k_NONE[] = "NONE"; +static const char __pyx_k_NSIG[] = "NSIG"; +static const char __pyx_k_READ[] = "READ"; +static const char __pyx_k_STAT[] = "STAT"; +static const char __pyx_k_args[] = "args"; +static const char __pyx_k_func[] = "func"; +static const char __pyx_k_join[] = "join"; +static const char __pyx_k_keys[] = "keys"; +static const char __pyx_k_loop[] = "loop"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_once[] = "once"; +static const char __pyx_k_path[] = "path"; +static const char __pyx_k_poll[] = "poll"; +static const char __pyx_k_port[] = "port"; +static const char __pyx_k_send[] = "send"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_time[] = "time"; +static const char __pyx_k_type[] = "type"; +static const char __pyx_k_ASYNC[] = "ASYNC"; +static const char __pyx_k_CHECK[] = "CHECK"; +static const char __pyx_k_CHILD[] = "CHILD"; +static const char __pyx_k_EMBED[] = "EMBED"; +static const char __pyx_k_ERROR[] = "ERROR"; +static const char __pyx_k_TIMER[] = "TIMER"; +static const char __pyx_k_UNDEF[] = "UNDEF"; +static const char __pyx_k_WRITE[] = "WRITE"; +static const char __pyx_k_after[] = "after"; +static const char __pyx_k_class[] = "__class__"; +static const char __pyx_k_close[] = "close"; +static const char __pyx_k_epoll[] = "epoll"; +static const char __pyx_k_errno[] = "errno"; +static const char __pyx_k_flags[] = "_flags"; +static const char __pyx_k_level[] = "level"; +static const char __pyx_k_lower[] = "lower"; +static const char __pyx_k_noenv[] = "noenv"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_ref_2[] = " ref="; +static const char __pyx_k_sigfd[] = "sigfd"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_split[] = "split"; +static const char __pyx_k_strip[] = "strip"; +static const char __pyx_k_throw[] = "throw"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_trace[] = "trace"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_value[] = "value"; +static const char __pyx_k_CUSTOM[] = "CUSTOM"; +static const char __pyx_k_EVENTS[] = "EVENTS"; +static const char __pyx_k_MAXPRI[] = "MAXPRI"; +static const char __pyx_k_MINPRI[] = "MINPRI"; +static const char __pyx_k_SIGNAL[] = "SIGNAL"; +static const char __pyx_k_active[] = "active"; +static const char __pyx_k_args_r[] = " args=%r"; +static const char __pyx_k_decode[] = "decode"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_events[] = "_events"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_fileno[] = "fileno"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_format[] = "_format"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_kqueue[] = "kqueue"; +static const char __pyx_k_nowait[] = "nowait"; +static const char __pyx_k_repeat[] = "repeat"; +static const char __pyx_k_select[] = "select"; +static const char __pyx_k_signal[] = "signal"; +static const char __pyx_k_signum[] = "signum"; +static const char __pyx_k_update[] = "update"; +static const char __pyx_k_CLEANUP[] = "CLEANUP"; +static const char __pyx_k_IOFDSET[] = "_IOFDSET"; +static const char __pyx_k_PREPARE[] = "PREPARE"; +static const char __pyx_k_backend[] = "backend"; +static const char __pyx_k_context[] = "context"; +static const char __pyx_k_default[] = "default"; +static const char __pyx_k_flags_2[] = "flags"; +static const char __pyx_k_genexpr[] = "genexpr"; +static const char __pyx_k_message[] = "message"; +static const char __pyx_k_pending[] = "pending"; +static const char __pyx_k_revents[] = "revents"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_rstatus[] = "rstatus"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_sigfd_2[] = " sigfd="; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_stopped[] = " stopped"; +static const char __pyx_k_KeyError[] = "KeyError"; +static const char __pyx_k_PERIODIC[] = "PERIODIC"; +static const char __pyx_k_SIGNALFD[] = "SIGNALFD"; +static const char __pyx_k_active_2[] = " active"; +static const char __pyx_k_builtins[] = "__builtins__"; +static const char __pyx_k_callback[] = "callback"; +static const char __pyx_k_events_2[] = "events"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_fileno_2[] = " fileno="; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_interval[] = "interval"; +static const char __pyx_k_priority[] = "priority"; +static const char __pyx_k_signalfd[] = "signalfd"; +static const char __pyx_k_strerror[] = "strerror"; +static const char __pyx_k_FORKCHECK[] = "FORKCHECK"; +static const char __pyx_k_NOINOTIFY[] = "NOINOTIFY"; +static const char __pyx_k_NOSIGMASK[] = "NOSIGMASK"; +static const char __pyx_k_READWRITE[] = "READWRITE"; +static const char __pyx_k_TypeError[] = "TypeError"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_activecnt[] = "activecnt"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_default_2[] = " default"; +static const char __pyx_k_destroyed[] = "destroyed"; +static const char __pyx_k_forkcheck[] = "forkcheck"; +static const char __pyx_k_noinotify[] = "noinotify"; +static const char __pyx_k_nosigmask[] = "nosigmask"; +static const char __pyx_k_pending_2[] = " pending"; +static const char __pyx_k_pending_s[] = " pending=%s"; +static const char __pyx_k_print_exc[] = "print_exc"; +static const char __pyx_k_signalnum[] = "signalnum"; +static const char __pyx_k_traceback[] = "traceback"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_basestring[] = "basestring"; +static const char __pyx_k_callback_r[] = " callback=%r"; +static const char __pyx_k_events_str[] = "events_str"; +static const char __pyx_k_pendingcnt[] = "pendingcnt"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_LIBEV_EMBED[] = "LIBEV_EMBED"; +static const char __pyx_k_SystemError[] = "SystemError"; +static const char __pyx_k_get_version[] = "get_version"; +static const char __pyx_k_libev_d_02d[] = "libev-%d.%02d"; +static const char __pyx_k_pass_events[] = "pass_events"; +static const char __pyx_k_s_at_0x_x_s[] = "<%s at 0x%x %s>"; +static const char __pyx_k_BACKEND_POLL[] = "BACKEND_POLL"; +static const char __pyx_k_BACKEND_PORT[] = "BACKEND_PORT"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_EV_USE_4HEAP[] = "EV_USE_4HEAP"; +static const char __pyx_k_EV_USE_FLOOR[] = "EV_USE_FLOOR"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_handle_error[] = "handle_error"; +static const char __pyx_k_signalmodule[] = "signalmodule"; +static const char __pyx_k_version_info[] = "version_info"; +static const char __pyx_k_BACKEND_EPOLL[] = "BACKEND_EPOLL"; +static const char __pyx_k_fd_s_events_s[] = " fd=%s events=%s"; +static const char __pyx_k_flags_str2int[] = "_flags_str2int"; +static const char __pyx_k_handle_syserr[] = "_handle_syserr"; +static const char __pyx_k_s_at_0x_x_s_2[] = "<%s at 0x%x%s"; +static const char __pyx_k_stop_watchers[] = "_stop_watchers"; +static const char __pyx_k_AttributeError[] = "AttributeError"; +static const char __pyx_k_BACKEND_KQUEUE[] = "BACKEND_KQUEUE"; +static const char __pyx_k_BACKEND_SELECT[] = "BACKEND_SELECT"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_EV_USE_EVENTFD[] = "EV_USE_EVENTFD"; +static const char __pyx_k_EV_USE_INOTIFY[] = "EV_USE_INOTIFY"; +static const char __pyx_k_format_details[] = "_format_details"; +static const char __pyx_k_EV_USE_REALTIME[] = "EV_USE_REALTIME"; +static const char __pyx_k_EV_USE_SIGNALFD[] = "EV_USE_SIGNALFD"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_SYSERR_CALLBACK[] = "__SYSERR_CALLBACK"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_pid_r_rstatus_r[] = " pid=%r rstatus=%r"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_print_exception[] = "print_exception"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_EV_USE_MONOTONIC[] = "EV_USE_MONOTONIC"; +static const char __pyx_k_EV_USE_NANOSLEEP[] = "EV_USE_NANOSLEEP"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_get_header_version[] = "get_header_version"; +static const char __pyx_k_gevent_core_EVENTS[] = "gevent.core.EVENTS"; +static const char __pyx_k_supported_backends[] = "supported_backends"; +static const char __pyx_k_embeddable_backends[] = "embeddable_backends"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_EV_USE_CLOCK_SYSCALL[] = "EV_USE_CLOCK_SYSCALL"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_default_handle_error[] = "_default_handle_error"; +static const char __pyx_k_ev_loop_new_s_failed[] = "ev_loop_new(%s) failed"; +static const char __pyx_k_illegal_event_mask_r[] = "illegal event mask: %r"; +static const char __pyx_k_recommended_backends[] = "recommended_backends"; +static const char __pyx_k_Unsupported_backend_s[] = "Unsupported backend: %s"; +static const char __pyx_k_getfilesystemencoding[] = "getfilesystemencoding"; +static const char __pyx_k_gevent_libev_corecext[] = "gevent.libev.corecext"; +static const char __pyx_k_Expected_callable_not_r[] = "Expected callable, not %r"; +static const char __pyx_k_illegal_signal_number_r[] = "illegal signal number: %r"; +static const char __pyx_k_ev_default_loop_s_failed[] = "ev_default_loop(%s) failed"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_fd_must_be_non_negative_r[] = "fd must be non-negative: %r"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_operation_on_destroyed_loop[] = "operation on destroyed loop"; +static const char __pyx_k_Invalid_value_for_backend_0x_x[] = "Invalid value for backend: 0x%x"; +static const char __pyx_k_io_watcher_attribute_events_is[] = "'io' watcher attribute 'events' is read-only while watcher is active"; +static const char __pyx_k_Expected_callable_or_None_got_r[] = "Expected callable or None, got %r"; +static const char __pyx_k_io_watcher_attribute_fd_is_read[] = "'io' watcher attribute 'fd' is read-only while watcher is active"; +static const char __pyx_k_repeat_must_be_positive_or_zero[] = "repeat must be positive or zero: %r"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmpqvkqo2j9\\gevent.libev.corecext.pyx"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmp2ctkbz0o\\gevent.libev.corecext.pyx"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmp2ae88oah\\gevent.libev.corecext.pyx"; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmpoursn1jm\\gevent.libev.corecext.pyx"; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmp60jryori\\gevent.libev.corecext.pyx"; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_C_Users_appveyor_AppData_Local_T[] = "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\tmpetzymc07\\gevent.libev.corecext.pyx"; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_Cannot_set_priority_of_an_active[] = "Cannot set priority of an active watcher"; +static const char __pyx_k_Invalid_backend_or_flag_s_Possib[] = "Invalid backend or flag: %s\nPossible values: %s"; +static const char __pyx_k_callback_must_be_callable_not_No[] = "callback must be callable, not None"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static const char __pyx_k_child_watchers_are_only_availabl[] = "child watchers are only available on the default loop"; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_; +static PyObject *__pyx_n_s_ASYNC; +static PyObject *__pyx_n_s_AttributeError; +static PyObject *__pyx_n_s_BACKEND_EPOLL; +static PyObject *__pyx_n_s_BACKEND_KQUEUE; +static PyObject *__pyx_n_s_BACKEND_POLL; +static PyObject *__pyx_n_s_BACKEND_PORT; +static PyObject *__pyx_n_s_BACKEND_SELECT; +static PyObject *__pyx_n_s_CHECK; +static PyObject *__pyx_n_s_CHILD; +static PyObject *__pyx_n_s_CLEANUP; +static PyObject *__pyx_n_s_CUSTOM; +static PyObject *__pyx_kp_s_C_Users_appveyor_AppData_Local_T; +static PyObject *__pyx_kp_s_Cannot_set_priority_of_an_active; +static PyObject *__pyx_n_s_EMBED; +static PyObject *__pyx_n_s_ERROR; +static PyObject *__pyx_n_s_EVENTS; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_EV_USE_4HEAP; +static PyObject *__pyx_n_s_EV_USE_CLOCK_SYSCALL; +static PyObject *__pyx_n_s_EV_USE_EVENTFD; +static PyObject *__pyx_n_s_EV_USE_FLOOR; +static PyObject *__pyx_n_s_EV_USE_INOTIFY; +static PyObject *__pyx_n_s_EV_USE_MONOTONIC; +static PyObject *__pyx_n_s_EV_USE_NANOSLEEP; +static PyObject *__pyx_n_s_EV_USE_REALTIME; +static PyObject *__pyx_n_s_EV_USE_SIGNALFD; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_Expected_callable_not_r; +static PyObject *__pyx_kp_s_Expected_callable_or_None_got_r; +static PyObject *__pyx_n_s_FORK; +static PyObject *__pyx_n_s_FORKCHECK; +static PyObject *__pyx_n_s_IDLE; +static PyObject *__pyx_n_s_IOFDSET; +static PyObject *__pyx_kp_s_Invalid_backend_or_flag_s_Possib; +static PyObject *__pyx_kp_s_Invalid_value_for_backend_0x_x; +static PyObject *__pyx_n_s_KeyError; +static PyObject *__pyx_n_s_LIBEV_EMBED; +static PyObject *__pyx_n_s_MAXPRI; +static PyObject *__pyx_n_s_MINPRI; +static PyObject *__pyx_n_s_NOINOTIFY; +static PyObject *__pyx_n_s_NONE; +static PyObject *__pyx_n_s_NOSIGMASK; +static PyObject *__pyx_n_s_NSIG; +static PyObject *__pyx_n_s_PERIODIC; +static PyObject *__pyx_n_s_PREPARE; +static PyObject *__pyx_n_s_READ; +static PyObject *__pyx_n_s_READWRITE; +static PyObject *__pyx_n_s_SIGNAL; +static PyObject *__pyx_n_s_SIGNALFD; +static PyObject *__pyx_n_s_STAT; +static PyObject *__pyx_n_s_SYSERR_CALLBACK; +static PyObject *__pyx_n_s_SystemError; +static PyObject *__pyx_n_s_TIMER; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_n_s_UNDEF; +static PyObject *__pyx_kp_s_Unsupported_backend_s; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_WRITE; +static PyObject *__pyx_kp_s__21; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_kp_s__22; +static PyObject *__pyx_kp_s__23; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s__26; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s__27; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_kp_s__28; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s__3; +static PyObject *__pyx_kp_s__4; +static PyObject *__pyx_kp_s__5; +static PyObject *__pyx_n_s_active; +static PyObject *__pyx_kp_s_active_2; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_activecnt; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_after; +static PyObject *__pyx_n_s_all; +static PyObject *__pyx_n_s_args; +static PyObject *__pyx_kp_s_args_r; +static PyObject *__pyx_n_s_backend; +static PyObject *__pyx_n_s_basestring; +static PyObject *__pyx_n_s_builtins; +static PyObject *__pyx_n_s_callback; +static PyObject *__pyx_kp_s_callback_must_be_callable_not_No; +static PyObject *__pyx_kp_s_callback_r; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_child_watchers_are_only_availabl; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_close; +static PyObject *__pyx_n_s_context; +static PyObject *__pyx_n_s_decode; +static PyObject *__pyx_n_s_default; +static PyObject *__pyx_kp_s_default_2; +static PyObject *__pyx_n_s_default_handle_error; +static PyObject *__pyx_n_s_destroyed; +static PyObject *__pyx_n_s_embeddable_backends; +static PyObject *__pyx_n_s_encode; +static PyObject *__pyx_n_s_epoll; +static PyObject *__pyx_n_s_errno; +static PyObject *__pyx_kp_s_ev_default_loop_s_failed; +static PyObject *__pyx_kp_s_ev_loop_new_s_failed; +static PyObject *__pyx_n_s_events; +static PyObject *__pyx_n_s_events_2; +static PyObject *__pyx_n_s_events_str; +static PyObject *__pyx_n_s_fd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_fd_must_be_non_negative_r; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_fd_s_events_s; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_fileno; +static PyObject *__pyx_kp_s_fileno_2; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_flags_2; +static PyObject *__pyx_n_s_flags_str2int; +static PyObject *__pyx_n_s_forkcheck; +static PyObject *__pyx_n_s_format; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_format_details; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_func; +static PyObject *__pyx_n_s_genexpr; +static PyObject *__pyx_n_s_get_header_version; +static PyObject *__pyx_n_s_get_version; +static PyObject *__pyx_n_s_getfilesystemencoding; +static PyObject *__pyx_kp_s_gevent_core_EVENTS; +static PyObject *__pyx_n_s_gevent_libev_corecext; +static PyObject *__pyx_n_s_handle_error; +static PyObject *__pyx_n_s_handle_syserr; +static PyObject *__pyx_n_s_hex; +static PyObject *__pyx_n_s_how; +static PyObject *__pyx_n_s_id; +static PyObject *__pyx_kp_s_illegal_event_mask_r; +static PyObject *__pyx_kp_s_illegal_signal_number_r; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_interval; +static PyObject *__pyx_kp_s_io_watcher_attribute_events_is; +static PyObject *__pyx_kp_s_io_watcher_attribute_fd_is_read; +static PyObject *__pyx_n_s_join; +static PyObject *__pyx_n_s_keys; +static PyObject *__pyx_n_s_kqueue; +static PyObject *__pyx_n_s_level; +static PyObject *__pyx_kp_s_libev_d_02d; +static PyObject *__pyx_n_s_loop; +static PyObject *__pyx_n_s_lower; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_message; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_noenv; +static PyObject *__pyx_n_s_noinotify; +static PyObject *__pyx_n_s_nosigmask; +static PyObject *__pyx_n_s_nowait; +static PyObject *__pyx_n_s_once; +static PyObject *__pyx_kp_s_operation_on_destroyed_loop; +static PyObject *__pyx_n_s_os; +static PyObject *__pyx_n_s_pass_events; +static PyObject *__pyx_n_s_path; +static PyObject *__pyx_n_s_pending; +static PyObject *__pyx_kp_s_pending_2; +static PyObject *__pyx_kp_s_pending_s; +static PyObject *__pyx_n_s_pendingcnt; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_pid; +static PyObject *__pyx_kp_s_pid_r_rstatus_r; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_poll; +static PyObject *__pyx_n_s_port; +static PyObject *__pyx_n_s_print_exc; +static PyObject *__pyx_n_s_print_exception; +static PyObject *__pyx_n_s_priority; +static PyObject *__pyx_n_s_ptr; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_recommended_backends; +static PyObject *__pyx_n_s_ref; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_ref_2; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_repeat; +static PyObject *__pyx_kp_s_repeat_must_be_positive_or_zero; +static PyObject *__pyx_n_s_revents; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_rstatus; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_kp_s_s_at_0x_x_s; +static PyObject *__pyx_kp_s_s_at_0x_x_s_2; +static PyObject *__pyx_n_s_select; +static PyObject *__pyx_n_s_send; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_sigfd; +static PyObject *__pyx_kp_s_sigfd_2; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_signal; +static PyObject *__pyx_n_s_signalfd; +static PyObject *__pyx_n_s_signalmodule; +static PyObject *__pyx_n_s_signalnum; +static PyObject *__pyx_n_s_signum; +static PyObject *__pyx_n_s_split; +static PyObject *__pyx_n_s_stop_watchers; +static PyObject *__pyx_kp_s_stopped; +static PyObject *__pyx_n_s_strerror; +static PyObject *__pyx_n_s_strip; +static PyObject *__pyx_n_s_supported_backends; +static PyObject *__pyx_n_s_sys; +static PyObject *__pyx_n_s_tb; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_throw; +static PyObject *__pyx_n_s_time; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_trace; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_n_s_traceback; +static PyObject *__pyx_n_s_type; +static PyObject *__pyx_n_s_update; +static PyObject *__pyx_n_s_value; +static PyObject *__pyx_n_s_version_info; +static PyObject *__pyx_pf_6gevent_5libev_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4loop___init__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, size_t __pyx_v_ptr); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_2_stop_watchers(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static void __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_28update(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_46async(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_58_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher___repr__(struct PyGeventWatcherObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_2_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_3ref___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_3ref_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8callback___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_8callback_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_stop(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8priority___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_8priority_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2feed(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6active___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_7pending___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_10__cinit__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static void __pyx_pf_6gevent_5libev_8corecext_2io_12__dealloc__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4loop___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_4loop_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_4loop_4__del__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4args___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_4args_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_2io_4args_4__del__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6_flags___get__(struct PyGeventIOObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_3ref___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_3ref_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8callback___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_8callback_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_stop(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8priority___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_8priority_2__set__(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2feed(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6active___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_7pending___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_6__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4loop___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_4__del__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4args___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4args_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4args_4__del__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6_flags___get__(struct PyGeventTimerObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_3ref___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_3ref_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_8callback___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_8callback_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_stop(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_8priority___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_8priority_2__set__(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_2feed(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4start(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_6active___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_7pending___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_6__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4loop___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_4__del__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4args___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4args_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4args_4__del__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_6_flags___get__(struct PyGeventSignalObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_3ref___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_3ref_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_8callback___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_8callback_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_stop(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_8priority___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_8priority_2__set__(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_2feed(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4start(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_6active___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_7pending___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_6__init__(struct PyGeventIdleObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4loop___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_4__del__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4args___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4args_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4args_4__del__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_6_flags___get__(struct PyGeventIdleObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_3ref___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_3ref_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_8callback___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_8callback_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_stop(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_8priority___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_8priority_2__set__(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_2feed(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4start(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_6active___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_7pending___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_6__init__(struct PyGeventPrepareObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4loop___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_4__del__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4args___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_4__del__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_6_flags___get__(struct PyGeventPrepareObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_3ref___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_3ref_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_8callback___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_8callback_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_stop(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_8priority___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_8priority_2__set__(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_2feed(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4start(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_6active___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_7pending___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_6__init__(struct PyGeventCheckObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4loop___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_4loop_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_4loop_4__del__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4args___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_4args_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5check_4args_4__del__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_6_flags___get__(struct PyGeventCheckObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_3ref___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_3ref_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_8callback___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_8callback_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_stop(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_8priority___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_8priority_2__set__(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_2feed(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4start(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_6active___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_7pending___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_6__init__(struct PyGeventForkObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4loop___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_4__del__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4args___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4args_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4args_4__del__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_6_flags___get__(struct PyGeventForkObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_3ref___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_3ref_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8callback___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_8callback_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_stop(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8priority___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_8priority_2__set__(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_2feed(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4start(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_6active___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_7pending___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_6__init__(struct PyGeventAsyncObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8send(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4loop___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_4loop_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_4loop_4__del__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4args___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_4args_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5async_4args_4__del__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_6_flags___get__(struct PyGeventAsyncObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3ref___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_3ref_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8callback___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_8callback_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_stop(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8priority___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_8priority_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_2feed(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4start(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_6active___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7pending___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_6__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8_format(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4loop___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_4loop_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_4loop_4__del__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4args___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_4args_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_5child_4args_4__del__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_6_flags___get__(struct PyGeventChildObject *__pyx_v_self); /* proto */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8callback___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_8callback_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_stop(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8priority___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_8priority_2__set__(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_2feed(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4start(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6active___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_7pending___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_6__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4loop___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_4__del__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4args___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4args_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4args_4__del__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_flags___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback); /* proto */ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext__EVENTSType(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_loop(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_callback(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_watcher(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_async(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_3; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_int_neg_1; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static int __pyx_k__9; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__19; +static PyObject *__pyx_tuple__20; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__23; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__25; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_tuple__26; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_tuple__27; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__28; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__29; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__32; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_tuple__34; +static PyObject *__pyx_tuple__35; +static PyObject *__pyx_tuple__36; +static PyObject *__pyx_tuple__37; +static PyObject *__pyx_tuple__38; +static PyObject *__pyx_tuple__39; +static PyObject *__pyx_tuple__40; +static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__42; +static PyObject *__pyx_tuple__43; +static PyObject *__pyx_tuple__44; +static PyObject *__pyx_tuple__45; +static PyObject *__pyx_tuple__46; +static PyObject *__pyx_tuple__47; +static PyObject *__pyx_tuple__48; +static PyObject *__pyx_tuple__49; +static PyObject *__pyx_tuple__50; +static PyObject *__pyx_tuple__51; +static PyObject *__pyx_tuple__52; +static PyObject *__pyx_tuple__53; +static PyObject *__pyx_tuple__54; +static PyObject *__pyx_tuple__55; +static PyObject *__pyx_tuple__56; +static PyObject *__pyx_tuple__57; +static PyObject *__pyx_tuple__58; +static PyObject *__pyx_tuple__59; +static PyObject *__pyx_tuple__60; +static PyObject *__pyx_tuple__61; +static PyObject *__pyx_tuple__62; +static PyObject *__pyx_tuple__63; +static PyObject *__pyx_tuple__64; +static PyObject *__pyx_tuple__65; +static PyObject *__pyx_tuple__66; +static PyObject *__pyx_tuple__67; +static PyObject *__pyx_tuple__68; +static PyObject *__pyx_tuple__69; +static PyObject *__pyx_tuple__70; +static PyObject *__pyx_tuple__71; +static PyObject *__pyx_tuple__72; +static PyObject *__pyx_tuple__73; +static PyObject *__pyx_tuple__74; +static PyObject *__pyx_tuple__75; +static PyObject *__pyx_tuple__76; +static PyObject *__pyx_tuple__77; +static PyObject *__pyx_tuple__78; +static PyObject *__pyx_tuple__79; +static PyObject *__pyx_tuple__80; +static PyObject *__pyx_tuple__81; +static PyObject *__pyx_tuple__82; +static PyObject *__pyx_tuple__83; +static PyObject *__pyx_tuple__84; +static PyObject *__pyx_tuple__85; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__86; +static PyObject *__pyx_tuple__87; +static PyObject *__pyx_tuple__88; +static PyObject *__pyx_tuple__89; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_tuple__90; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__91; +static PyObject *__pyx_tuple__92; +static PyObject *__pyx_tuple__93; +static PyObject *__pyx_tuple__94; +static PyObject *__pyx_tuple__95; +static PyObject *__pyx_tuple__96; +static PyObject *__pyx_tuple__97; +static PyObject *__pyx_codeobj__98; +static PyObject *__pyx_codeobj__99; +static PyObject *__pyx_codeobj__100; +static PyObject *__pyx_codeobj__101; +static PyObject *__pyx_codeobj__102; +static PyObject *__pyx_codeobj__103; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_codeobj__90; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_codeobj__91; +static PyObject *__pyx_codeobj__92; +static PyObject *__pyx_codeobj__93; +static PyObject *__pyx_codeobj__94; +static PyObject *__pyx_codeobj__95; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__90; +static PyObject *__pyx_tuple__91; +static PyObject *__pyx_tuple__92; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_codeobj__93; +static PyObject *__pyx_codeobj__94; +static PyObject *__pyx_codeobj__95; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_codeobj__96; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_tuple__93; +static PyObject *__pyx_tuple__94; +static PyObject *__pyx_tuple__95; +static PyObject *__pyx_tuple__96; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_codeobj__97; +static PyObject *__pyx_codeobj__98; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_codeobj__86; +static PyObject *__pyx_codeobj__87; +static PyObject *__pyx_codeobj__88; +static PyObject *__pyx_codeobj__89; +static PyObject *__pyx_codeobj__90; +static PyObject *__pyx_codeobj__91; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_codeobj__99; +static PyObject *__pyx_codeobj__100; +static PyObject *__pyx_codeobj__101; +static PyObject *__pyx_codeobj__102; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_gb_6gevent_5libev_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ + + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_22genexpr(CYTHON_UNUSED PyObject *__pyx_self) { + struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("genexpr", 0); + __pyx_cur_scope = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(__pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __pyx_cur_scope = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 128, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); + } + { + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gevent_5libev_8corecext_24generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_gevent_libev_corecext); if (unlikely(!gen)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_6gevent_5libev_8corecext_24generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_cur_scope = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_r = PyDict_New(); if (unlikely(!__pyx_r)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_r); + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 128, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 128, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L7_unpacking_done; + __pyx_L6_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_L7_unpacking_done:; + } + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_flag); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_flag, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_string); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_string, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + if (unlikely(PyDict_SetItem(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_string, (PyObject*)__pyx_cur_scope->__pyx_v_flag))) __PYX_ERR(0, 128, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +PyObject *GEVENT_CORE_EVENTS = 0; + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(((struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_11_EVENTSType___repr__(CYTHON_UNUSED struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_kp_s_gevent_core_EVENTS); + __pyx_r = __pyx_kp_s_gevent_core_EVENTS; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_1get_version = {"get_version", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_1get_version, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_1get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_version (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_get_version(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_get_version(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_version", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_version_major()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(ev_version_minor()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_3get_header_version = {"get_header_version", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_3get_header_version, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_3get_header_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_header_version (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2get_header_version(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2get_header_version(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("get_header_version", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(EV_VERSION_MAJOR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(EV_VERSION_MINOR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_libev_d_02d, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.get_header_version", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__flags_to_list(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_v_result = 0; + PyObject *__pyx_v_code = NULL; + PyObject *__pyx_v_value = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + int __pyx_t_9; + int __pyx_t_10; + unsigned int __pyx_t_11; + __Pyx_RefNannySetupContext("_flags_to_list", 0); + + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_result = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 151, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 151, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 151, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 151, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_code, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6); + __pyx_t_6 = 0; + + __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_code); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_9) { + + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_value); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 153, __pyx_L1_error) + + } + + __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyNumber_Invert(__pyx_v_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyNumber_InPlaceAnd(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_11 = __Pyx_PyInt_As_unsigned_int(__pyx_t_5); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_flags = __pyx_t_11; + + __pyx_t_9 = ((!(__pyx_v_flags != 0)) != 0); + if (__pyx_t_9) { + + goto __pyx_L4_break; + + } + + } + __pyx_L4_break:; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_9 = (__pyx_v_flags != 0); + if (__pyx_t_9) { + + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + } + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_code); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list(PyObject *__pyx_self, PyObject *__pyx_arg_flags) { + unsigned int __pyx_v_flags; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_flags_to_list (wrapper)", 0); + assert(__pyx_arg_flags); { + __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 149, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(__pyx_self, ((unsigned int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4_flags_to_list(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_flags_to_list", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/ +static unsigned int __pyx_f_6gevent_5libev_8corecext__flags_to_int(PyObject *__pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { + unsigned int __pyx_v_result; + PyObject *__pyx_v_value = NULL; + PyObject *__pyx_v_ex = NULL; + unsigned int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + unsigned int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_9; + PyObject *(*__pyx_t_10)(PyObject *); + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + int __pyx_t_17; + __Pyx_RefNannySetupContext("_flags_to_int", 0); + __Pyx_INCREF(__pyx_v_flags); + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_flags); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 170, __pyx_L1_error) + __pyx_t_2 = ((!__pyx_t_1) != 0); + if (__pyx_t_2) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_3 = __pyx_v_6gevent_5libev_8corecext_integer_types; + __Pyx_INCREF(__pyx_t_3); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 172, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_r = __pyx_t_4; + goto __pyx_L0; + + } + + __pyx_v_result = 0; + + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + /*try:*/ { + + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_basestring); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyObject_IsInstance(__pyx_v_flags, __pyx_t_3); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 176, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_flags, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 177, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_flags, __pyx_t_8); + __pyx_t_8 = 0; + + } + + if (likely(PyList_CheckExact(__pyx_v_flags)) || PyTuple_CheckExact(__pyx_v_flags)) { + __pyx_t_8 = __pyx_v_flags; __Pyx_INCREF(__pyx_t_8); __pyx_t_9 = 0; + __pyx_t_10 = NULL; + } else { + __pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 178, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 178, __pyx_L5_error) + } + for (;;) { + if (likely(!__pyx_t_10)) { + if (likely(PyList_CheckExact(__pyx_t_8))) { + if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 178, __pyx_L5_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + } else { + if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 178, __pyx_L5_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + } + } else { + __pyx_t_3 = __pyx_t_10(__pyx_t_8); + if (unlikely(!__pyx_t_3)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 178, __pyx_L5_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_3); + __pyx_t_3 = 0; + + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_strip); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 179, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_13)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_13); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + } + } + if (__pyx_t_13) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 179, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else { + __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 179, __pyx_L5_error) + } + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_lower); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 179, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + } + } + if (__pyx_t_11) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else { + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L5_error) + } + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3); + __pyx_t_3 = 0; + + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 180, __pyx_L5_error) + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 181, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_11 = PyObject_GetItem(__pyx_t_12, __pyx_v_value); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 181, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_InPlaceOr(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 181, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_12); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 181, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_v_result = __pyx_t_4; + + } + + } + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + } + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L12_try_end; + __pyx_L5_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + + __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); + if (__pyx_t_14) { + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 182, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(__pyx_t_12); + __pyx_v_ex = __pyx_t_12; + + __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags_str2int); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_keys); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { + __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16); + if (likely(__pyx_t_15)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); + __Pyx_INCREF(__pyx_t_15); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_16, function); + } + } + if (__pyx_t_15) { + __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } else { + __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 183, __pyx_L7_except_error) + } + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __pyx_t_16 = PySequence_List(__pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_3 = ((PyObject*)__pyx_t_16); + __pyx_t_16 = 0; + __pyx_t_17 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __pyx_t_16 = __Pyx_PyString_Join(__pyx_kp_s__3, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_ex); + __Pyx_GIVEREF(__pyx_v_ex); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ex); + __Pyx_GIVEREF(__pyx_t_16); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_16); + __pyx_t_16 = 0; + __pyx_t_16 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_16); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_16); + __pyx_t_16 = 0; + __pyx_t_16 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 183, __pyx_L7_except_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_16, 0, 0, 0); + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __PYX_ERR(0, 183, __pyx_L7_except_error) + } + goto __pyx_L7_except_error; + __pyx_L7_except_error:; + + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + goto __pyx_L1_error; + __pyx_L12_try_end:; + } + + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_16); + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_ex); + __Pyx_XDECREF(__pyx_v_flags); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int(PyObject *__pyx_self, PyObject *__pyx_v_flags) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_flags_to_int (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(__pyx_self, ((PyObject *)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6_flags_to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_flags) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + unsigned int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("_flags_to_int", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext._flags_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_f_6gevent_5libev_8corecext__str_hex(PyObject *__pyx_v_flag) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("_str_hex", 0); + + __pyx_t_1 = __pyx_v_6gevent_5libev_8corecext_integer_types; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_flag, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_flag); + __Pyx_GIVEREF(__pyx_v_flag); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_flag); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 189, __pyx_L1_error) + __pyx_r = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + goto __pyx_L0; + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_flag); + __Pyx_GIVEREF(__pyx_v_flag); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_flag); + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_r = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext._str_hex", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__check_flags(unsigned int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_v_as_list = 0; + PyObject *__pyx_v_x = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + __Pyx_RefNannySetupContext("_check_flags", 0); + + __pyx_v_flags = (__pyx_v_flags & EVBACKEND_MASK); + + __pyx_t_1 = ((!(__pyx_v_flags != 0)) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + } + + __pyx_t_1 = ((!((__pyx_v_flags & EVBACKEND_ALL) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 199, __pyx_L1_error) + + } + + __pyx_t_1 = ((!((__pyx_v_flags & ev_supported_backends()) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_v_flags, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { + __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 201, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } + } else { + __pyx_t_2 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_2)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 201, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__str_hex(__pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 201, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_as_list = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_as_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_backend_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 202, __pyx_L1_error) + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_as_list); + __Pyx_XDECREF(__pyx_v_x); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_9_check_flags(PyObject *__pyx_self, PyObject *__pyx_arg_flags) { + unsigned int __pyx_v_flags; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_check_flags (wrapper)", 0); + assert(__pyx_arg_flags); { + __pyx_v_flags = __Pyx_PyInt_As_unsigned_int(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 193, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8_check_flags(__pyx_self, ((unsigned int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8_check_flags(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_flags) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_check_flags", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__check_flags(__pyx_v_flags, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext._check_flags", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext__events_to_str(int __pyx_v_events, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_v_result = 0; + int __pyx_v_c_flag; + PyObject *__pyx_v_flag = NULL; + PyObject *__pyx_v_string = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + __Pyx_RefNannySetupContext("_events_to_str", 0); + + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_result = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_events); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 208, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 208, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 208, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 208, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 208, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 208, __pyx_L1_error) + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 208, __pyx_L1_error) + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_flag, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_string, __pyx_t_6); + __pyx_t_6 = 0; + + __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_flag); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 209, __pyx_L1_error) + __pyx_v_c_flag = __pyx_t_9; + + __pyx_t_10 = ((__pyx_v_events & __pyx_v_c_flag) != 0); + if (__pyx_t_10) { + + __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_string); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 211, __pyx_L1_error) + + __pyx_v_events = (__pyx_v_events & (~__pyx_v_c_flag)); + + } + + __pyx_t_10 = ((!(__pyx_v_events != 0)) != 0); + if (__pyx_t_10) { + + goto __pyx_L4_break; + + } + + } + __pyx_L4_break:; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_10 = (__pyx_v_events != 0); + if (__pyx_t_10) { + + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__4, __pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_flag); + __Pyx_XDECREF(__pyx_v_string); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_11_events_to_str(PyObject *__pyx_self, PyObject *__pyx_arg_events) { + int __pyx_v_events; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_events_to_str (wrapper)", 0); + assert(__pyx_arg_events); { + __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_10_events_to_str(__pyx_self, ((int)__pyx_v_events)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_10_events_to_str(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_events) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_events_to_str", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__events_to_str(__pyx_v_events, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext._events_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_13supported_backends = {"supported_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_13supported_backends, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_13supported_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("supported_backends (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_12supported_backends(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_12supported_backends(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("supported_backends", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_supported_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.supported_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_15recommended_backends = {"recommended_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_15recommended_backends, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_15recommended_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("recommended_backends (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_14recommended_backends(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_14recommended_backends(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("recommended_backends", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_recommended_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.recommended_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_17embeddable_backends = {"embeddable_backends", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_17embeddable_backends(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("embeddable_backends (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_16embeddable_backends(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("embeddable_backends", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(ev_embeddable_backends(), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.embeddable_backends", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_6gevent_5libev_8corecext_19time = {"time", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_19time, METH_NOARGS, 0}; +static PyObject *__pyx_pw_6gevent_5libev_8corecext_19time(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("time (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_18time(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_18time(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("time", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(ev_time()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.time", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_flags = 0; + PyObject *__pyx_v_default = 0; + size_t __pyx_v_ptr; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags_2,&__pyx_n_s_default,&__pyx_n_s_ptr,0}; + PyObject* values[3] = {0,0,0}; + values[0] = ((PyObject *)Py_None); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags_2); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ptr); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 256, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_flags = values[0]; + __pyx_v_default = values[1]; + if (values[2]) { + __pyx_v_ptr = __Pyx_PyInt_As_size_t(values[2]); if (unlikely((__pyx_v_ptr == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 256, __pyx_L3_error) + } else { + __pyx_v_ptr = ((size_t)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 256, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop___init__(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_flags, __pyx_v_default, __pyx_v_ptr); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4loop___init__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_flags, PyObject *__pyx_v_default, size_t __pyx_v_ptr) { + unsigned int __pyx_v_c_flags; + CYTHON_UNUSED PyObject *__pyx_v_old_handler = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + unsigned int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + __Pyx_RefNannySetupContext("__init__", 0); + __Pyx_INCREF(__pyx_v_default); + + __Pyx_INCREF(Py_None); + __pyx_v_old_handler = Py_None; + + ev_prepare_init((&__pyx_v_self->_prepare), ((void *)gevent_run_callbacks)); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + ev_timer_init((&__pyx_v_self->_periodic_signal_checker), ((void *)gevent_periodic_signal_check), 0.3, 0.3); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + ev_timer_init((&__pyx_v_self->_timer0), ((void *)gevent_noop), 0.0, 0.0); + + __pyx_t_1 = (__pyx_v_ptr != 0); + if (__pyx_t_1) { + + __pyx_v_self->_ptr = ((struct ev_loop *)__pyx_v_ptr); + + goto __pyx_L3; + } + + /*else*/ { + __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__flags_to_int(__pyx_v_flags, 0); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_v_c_flags = __pyx_t_2; + + __pyx_t_3 = __pyx_f_6gevent_5libev_8corecext__check_flags(__pyx_v_c_flags, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_NOENV); + + __pyx_v_c_flags = (__pyx_v_c_flags | EVFLAG_FORKCHECK); + + __pyx_t_1 = (__pyx_v_default == Py_None); + __pyx_t_4 = (__pyx_t_1 != 0); + if (__pyx_t_4) { + + __Pyx_INCREF(Py_True); + __Pyx_DECREF_SET(__pyx_v_default, Py_True); + + __pyx_t_4 = (__pyx_v_6gevent_5libev_8corecext__default_loop_destroyed != 0); + if (__pyx_t_4) { + + __Pyx_INCREF(Py_False); + __Pyx_DECREF_SET(__pyx_v_default, Py_False); + + } + + } + + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 275, __pyx_L1_error) + if (__pyx_t_4) { + + __pyx_v_self->_ptr = gevent_ev_default_loop(__pyx_v_c_flags); + + __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_4) { + + __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_default_loop_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 278, __pyx_L1_error) + + } +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + + ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_periodic_signal_checker)); + + ev_unref(__pyx_v_self->_ptr); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + goto __pyx_L6; + } + + /*else*/ { + __pyx_v_self->_ptr = ev_loop_new(__pyx_v_c_flags); + + __pyx_t_4 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_4) { + + __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_c_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ev_loop_new_s_failed, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 286, __pyx_L1_error) + + } + } + __pyx_L6:; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_default); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 287, __pyx_L1_error) + if (!__pyx_t_1) { + } else { + __pyx_t_4 = __pyx_t_1; + goto __pyx_L10_bool_binop_done; + } + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = (__pyx_t_3 == Py_None); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = (__pyx_t_1 != 0); + __pyx_t_4 = __pyx_t_6; + __pyx_L10_bool_binop_done:; + if (__pyx_t_4) { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(__pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + } + + ev_prepare_start(__pyx_v_self->_ptr, (&__pyx_v_self->_prepare)); + + ev_unref(__pyx_v_self->_ptr); + } + __pyx_L3:; + + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_v_self->_callbacks); + __Pyx_DECREF(__pyx_v_self->_callbacks); + __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.loop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_old_handler); + __Pyx_XDECREF(__pyx_v_default); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks(struct PyGeventLoopObject *__pyx_v_self) { + struct PyGeventCallbackObject *__pyx_v_cb = 0; + PyObject *__pyx_v_callbacks = 0; + int __pyx_v_count; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("_run_callbacks", 0); + + __pyx_v_count = 0x3E8; + + ev_timer_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0)); + + while (1) { + __pyx_t_2 = (__pyx_v_self->_callbacks != Py_None) && (PyList_GET_SIZE(__pyx_v_self->_callbacks) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + __pyx_t_2 = ((__pyx_v_count > 0) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L5_bool_binop_done:; + if (!__pyx_t_1) break; + + __pyx_t_3 = __pyx_v_self->_callbacks; + __Pyx_INCREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_callbacks, __pyx_t_3); + __pyx_t_3 = 0; + + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->_callbacks); + __Pyx_DECREF(__pyx_v_self->_callbacks); + __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + if (likely(PyList_CheckExact(__pyx_v_callbacks)) || PyTuple_CheckExact(__pyx_v_callbacks)) { + __pyx_t_3 = __pyx_v_callbacks; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; + __pyx_t_5 = NULL; + } else { + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_callbacks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_5)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } else { + if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } + } else { + __pyx_t_6 = __pyx_t_5(__pyx_t_3); + if (unlikely(!__pyx_t_6)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 301, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_6); + } + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6gevent_5libev_8corecext_callback))))) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_cb, ((struct PyGeventCallbackObject *)__pyx_t_6)); + __pyx_t_6 = 0; + + ev_unref(__pyx_v_self->_ptr); + + gevent_call(__pyx_v_self, __pyx_v_cb); + + __pyx_v_count = (__pyx_v_count - 1); + + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + + __pyx_t_1 = (__pyx_v_self->_callbacks != Py_None) && (PyList_GET_SIZE(__pyx_v_self->_callbacks) != 0); + if (__pyx_t_1) { + + ev_timer_start(__pyx_v_self->_ptr, (&__pyx_v_self->_timer0)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("gevent.libev.corecext.loop._run_callbacks", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_cb); + __Pyx_XDECREF(__pyx_v_callbacks); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3_stop_watchers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3_stop_watchers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_stop_watchers (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_2_stop_watchers(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_2_stop_watchers(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("_stop_watchers", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_prepare)) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->_ptr); + + ev_prepare_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_prepare)); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + + } + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_periodic_signal_checker)) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->_ptr); + + ev_timer_stop(__pyx_v_self->_ptr, (&__pyx_v_self->_periodic_signal_checker)); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("destroy (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_4destroy(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("destroy", 0); + + __pyx_t_1 = (__pyx_v_self->_ptr != 0); + if (__pyx_t_1) { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop_watchers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_syserr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 322, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 322, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_1) { + + __pyx_t_4 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + } + + __pyx_t_1 = (ev_is_default_loop(__pyx_v_self->_ptr) != 0); + if (__pyx_t_1) { + + __pyx_v_6gevent_5libev_8corecext__default_loop_destroyed = 1; + + } + + ev_loop_destroy(__pyx_v_self->_ptr); + + __pyx_v_self->_ptr = NULL; + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext.loop.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static void __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_6gevent_5libev_8corecext_4loop_6__dealloc__(struct PyGeventLoopObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + __pyx_t_1 = (__pyx_v_self->_ptr != 0); + if (__pyx_t_1) { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop_watchers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_1 = ((!(ev_is_default_loop(__pyx_v_self->_ptr) != 0)) != 0); + if (__pyx_t_1) { + + ev_loop_destroy(__pyx_v_self->_ptr); + + } + + __pyx_v_self->_ptr = NULL; + + } + + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("gevent.libev.corecext.loop.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_3ptr___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop.ptr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11WatcherType___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher)); + __pyx_r = ((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_watcher); + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MAXPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop.MAXPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_6MINPRI___get__(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop.MINPRI.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_message = 0; + PyObject *__pyx_v_errno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_handle_syserr (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_message,&__pyx_n_s_errno,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_errno)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, 1); __PYX_ERR(0, 356, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_syserr") < 0)) __PYX_ERR(0, 356, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_message = values[0]; + __pyx_v_errno = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_handle_syserr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 356, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_message, __pyx_v_errno); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_8_handle_syserr(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_errno) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("_handle_syserr", 0); + __Pyx_INCREF(__pyx_v_message); + + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 357, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_3) { + + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_message, __pyx_t_2); + __pyx_t_2 = 0; + + } + + __pyx_t_2 = PyNumber_Add(__pyx_v_message, __pyx_kp_s__5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strerror); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_4) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_errno); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_errno}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_errno}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(__pyx_v_errno); + __Pyx_GIVEREF(__pyx_v_errno); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_errno); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_SystemError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->handle_error(__pyx_v_self, Py_None, __pyx_builtin_SystemError, __pyx_t_5, Py_None, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("gevent.libev.corecext.loop._handle_syserr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_message); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { + PyObject *__pyx_v_handle_error = 0; + PyObject *__pyx_v_error_handler = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + __Pyx_RefNannySetupContext("handle_error", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_handle_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + __pyx_t_5 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_5 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_context); + __Pyx_GIVEREF(__pyx_v_context); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); + __Pyx_INCREF(__pyx_v_type); + __Pyx_GIVEREF(__pyx_v_type); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); + __Pyx_INCREF(__pyx_v_tb); + __Pyx_GIVEREF(__pyx_v_tb); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + __pyx_t_1 = __pyx_v_self->error_handler; + __Pyx_INCREF(__pyx_t_1); + __pyx_v_error_handler = __pyx_t_1; + __pyx_t_1 = 0; + + __pyx_t_7 = (__pyx_v_error_handler != Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_error_handler, __pyx_n_s_handle_error, __pyx_v_error_handler); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_handle_error = __pyx_t_1; + __pyx_t_1 = 0; + + __Pyx_INCREF(__pyx_v_handle_error); + __pyx_t_2 = __pyx_v_handle_error; __pyx_t_3 = NULL; + __pyx_t_5 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_5 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_context); + __Pyx_GIVEREF(__pyx_v_context); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); + __Pyx_INCREF(__pyx_v_type); + __Pyx_GIVEREF(__pyx_v_type); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); + __Pyx_INCREF(__pyx_v_tb); + __Pyx_GIVEREF(__pyx_v_tb); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_t_1 = ((struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop *)__pyx_v_self->__pyx_vtab)->_default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L3:; + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_handle_error); + __Pyx_XDECREF(__pyx_v_error_handler); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_context = 0; + PyObject *__pyx_v_type = 0; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_tb = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("handle_error (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 1); __PYX_ERR(0, 361, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 2); __PYX_ERR(0, 361, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, 3); __PYX_ERR(0, 361, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_error") < 0)) __PYX_ERR(0, 361, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_context = values[0]; + __pyx_v_type = values[1]; + __pyx_v_value = values[2]; + __pyx_v_tb = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 361, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("handle_error", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_4loop_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop.handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(struct PyGeventLoopObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + __Pyx_RefNannySetupContext("_default_handle_error", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_default_handle_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + __pyx_t_5 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_5 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_context); + __Pyx_GIVEREF(__pyx_v_context); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_context); + __Pyx_INCREF(__pyx_v_type); + __Pyx_GIVEREF(__pyx_v_type); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_type); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_value); + __Pyx_INCREF(__pyx_v_tb); + __Pyx_GIVEREF(__pyx_v_tb); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_print_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + __pyx_t_5 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_5 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_type, __pyx_v_value, __pyx_v_tb}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_2) { + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_INCREF(__pyx_v_type); + __Pyx_GIVEREF(__pyx_v_type); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_type); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_value); + __Pyx_INCREF(__pyx_v_tb); + __Pyx_GIVEREF(__pyx_v_tb); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_tb); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_t_7 = (__pyx_v_self->_ptr != 0); + if (__pyx_t_7) { + + ev_break(__pyx_v_self->_ptr, EVBREAK_ONE); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_context = 0; + PyObject *__pyx_v_type = 0; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_tb = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_default_handle_error (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_context,&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_tb,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_context)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 1); __PYX_ERR(0, 371, __pyx_L3_error) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 2); __PYX_ERR(0, 371, __pyx_L3_error) + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, 3); __PYX_ERR(0, 371, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_default_handle_error") < 0)) __PYX_ERR(0, 371, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_context = values[0]; + __pyx_v_type = values[1]; + __pyx_v_value = values[2]; + __pyx_v_tb = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_default_handle_error", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 371, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_12_default_handle_error(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_context, PyObject *__pyx_v_type, PyObject *__pyx_v_value, PyObject *__pyx_v_tb) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_default_handle_error", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error(__pyx_v_self, __pyx_v_context, __pyx_v_type, __pyx_v_value, __pyx_v_tb, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop._default_handle_error", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_15run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_nowait = 0; + PyObject *__pyx_v_once = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("run (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nowait,&__pyx_n_s_once,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_False); + values[1] = ((PyObject *)Py_False); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nowait); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_once); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run") < 0)) __PYX_ERR(0, 378, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_nowait = values[0]; + __pyx_v_once = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("run", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 378, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_14run(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_nowait, __pyx_v_once); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_14run(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_nowait, PyObject *__pyx_v_once) { + unsigned int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("run", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 381, __pyx_L1_error) + + } + + __pyx_v_flags = 0; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_nowait); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 383, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_flags = (__pyx_v_flags | EVRUN_NOWAIT); + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_once); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 385, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_flags = (__pyx_v_flags | EVRUN_ONCE); + + } + + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + #endif + /*try:*/ { + + ev_run(__pyx_v_self->_ptr, __pyx_v_flags); + } + + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + Py_BLOCK_THREADS + #endif + goto __pyx_L8; + } + __pyx_L8:; + } + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.run", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reinit (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_16reinit(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("reinit", 0); + + __pyx_t_1 = (__pyx_v_self->_ptr != 0); + if (__pyx_t_1) { + + ev_loop_fork(__pyx_v_self->_ptr); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_19ref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("ref (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_18ref(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_18ref(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("ref", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 397, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 397, __pyx_L1_error) + + } + + ev_ref(__pyx_v_self->_ptr); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.ref", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_21unref(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("unref (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_20unref(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_20unref(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("unref", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 403, __pyx_L1_error) + + } + + ev_unref(__pyx_v_self->_ptr); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.unref", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_23break_(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_how; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("break_ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_how,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_how); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "break_") < 0)) __PYX_ERR(0, 406, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_how = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_how == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error) + } else { + __pyx_v_how = __pyx_k__9; + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("break_", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_22break_(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_how); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_22break_(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_how) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("break_", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 409, __pyx_L1_error) + + } + + ev_break(__pyx_v_self->_ptr, __pyx_v_how); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.break_", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_25verify(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("verify (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_24verify(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_24verify(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("verify", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 415, __pyx_L1_error) + + } + + ev_verify(__pyx_v_self->_ptr); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.verify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_27now(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("now (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_26now(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_26now(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("now", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 421, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyFloat_FromDouble(ev_now(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.now", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_29update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_29update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("update (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_28update(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_28update(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("update", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 427, __pyx_L1_error) + + } + + ev_now_update(__pyx_v_self->_ptr); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_30__repr__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (__pyx_t_5) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else { + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.loop.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7default___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 438, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_default_loop(__pyx_v_self->_ptr) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_2 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_2 = Py_False; + } + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.default.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9iteration___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 446, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_iteration(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.iteration.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5depth___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 454, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_depth(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.depth.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11backend_int___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 462, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_backend(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.backend_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_7backend___get__(struct PyGeventLoopObject *__pyx_v_self) { + unsigned int __pyx_v_backend; + PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_value = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *(*__pyx_t_9)(PyObject *); + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 470, __pyx_L1_error) + + } + + __pyx_v_backend = ev_backend(__pyx_v_self->_ptr); + + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { + __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; + __pyx_t_5 = NULL; + } else { + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 472, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + for (;;) { + if (likely(!__pyx_t_5)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 472, __pyx_L1_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } else { + if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 472, __pyx_L1_error) + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #endif + } + } else { + __pyx_t_2 = __pyx_t_5(__pyx_t_3); + if (unlikely(!__pyx_t_2)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 472, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { + PyObject* sequence = __pyx_t_2; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 472, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_6 = PyList_GET_ITEM(sequence, 0); + __pyx_t_7 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_7); + #else + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; + index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; + __Pyx_GOTREF(__pyx_t_7); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 472, __pyx_L1_error) + __pyx_t_9 = NULL; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L7_unpacking_done; + __pyx_L6_unpacking_failed:; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 472, __pyx_L1_error) + __pyx_L7_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6); + __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_7); + __pyx_t_7 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyObject_RichCompare(__pyx_v_key, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 473, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 473, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_value); + __pyx_r = __pyx_v_value; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L0; + + } + + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_backend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("gevent.libev.corecext.loop.backend.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10pendingcnt___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 482, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(ev_pending_count(__pyx_v_self->_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.pendingcnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_33io(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + vfd_socket_t __pyx_v_fd; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_v_fd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + vfd_socket_t __pyx_v_fd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_v_events; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("io (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[4] = {0,0,0,0}; + values[2] = ((PyObject *)Py_True); + values[3] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--; + else { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); __PYX_ERR(0, 489, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, 1); __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) __PYX_ERR(0, 489, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "io") < 0)) __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[0]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[0]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_v_ref = values[2]; + __pyx_v_priority = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 489, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("io", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 486, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_32io(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_32io(struct PyGeventLoopObject *__pyx_v_self, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("io", 0); + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyInt_From_vfd_socket_t(__pyx_v_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyInt_From_vfd_socket_t(__pyx_v_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_1); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 490, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority); + __pyx_t_1 = 0; + __pyx_t_2 = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_io), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop.io", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_35timer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + double __pyx_v_after; + double __pyx_v_repeat; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("timer (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[4] = {0,0,0,0}; + values[2] = ((PyObject *)Py_True); + values[3] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_repeat); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "timer") < 0)) __PYX_ERR(0, 493, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_after = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 493, __pyx_L3_error) + if (values[1]) { + __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 493, __pyx_L3_error) + } else { + __pyx_v_repeat = ((double)0.0); + } + __pyx_v_ref = values[2]; + __pyx_v_priority = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("timer", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 493, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_34timer(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_34timer(struct PyGeventLoopObject *__pyx_v_self, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("timer", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_after); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 494, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_priority); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_timer), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop.timer", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_37signal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_signum; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("signal (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signum,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signum)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "signal") < 0)) __PYX_ERR(0, 496, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_signum = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_signum == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L3_error) + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("signal", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 496, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_36signal(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_signum, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_36signal(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_signum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("signal", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_signum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 497, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 497, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_priority); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_signal), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 497, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.signal", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_39idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("idle (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_True); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "idle") < 0)) __PYX_ERR(0, 499, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_ref = values[0]; + __pyx_v_priority = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("idle", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 499, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_38idle(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_38idle(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("idle", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_idle), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.idle", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("prepare (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_True); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prepare") < 0)) __PYX_ERR(0, 502, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_ref = values[0]; + __pyx_v_priority = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("prepare", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 502, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_40prepare(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("prepare", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 503, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_prepare), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.prepare", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_43check(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("check (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_True); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check") < 0)) __PYX_ERR(0, 505, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_ref = values[0]; + __pyx_v_priority = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("check", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 505, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_42check(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_42check(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("check", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_check), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 506, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_45fork(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("fork (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_True); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fork") < 0)) __PYX_ERR(0, 508, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_ref = values[0]; + __pyx_v_priority = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("fork", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 508, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_44fork(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_44fork(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("fork", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_fork), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.fork", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_47async(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_47async(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("async (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[2] = {0,0}; + values[0] = ((PyObject *)Py_True); + values[1] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "async") < 0)) __PYX_ERR(0, 511, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_ref = values[0]; + __pyx_v_priority = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("async", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 511, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.async", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_46async(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_46async(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("async", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_priority); + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_async), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.async", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49child(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_pid; + int __pyx_v_trace; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("child (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0}; + PyObject* values[3] = {0,0,0}; + values[2] = ((PyObject *)Py_True); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trace); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "child") < 0)) __PYX_ERR(0, 517, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_pid = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 517, __pyx_L3_error) + if (values[1]) { + __pyx_v_trace = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 517, __pyx_L3_error) + } else { + __pyx_v_trace = ((int)0); + } + __pyx_v_ref = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("child", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 517, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_48child(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_pid, __pyx_v_trace, __pyx_v_ref); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48child(struct PyGeventLoopObject *__pyx_v_self, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("child", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_trace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ref); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_child), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop.child", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("install_sigchld (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50install_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("install_sigchld", 0); + + gevent_install_sigchld_handler(); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset_sigchld (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52reset_sigchld(CYTHON_UNUSED struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset_sigchld", 0); + + gevent_reset_sigchld_handler(); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_49stat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_v_path = 0; + float __pyx_v_interval; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stat (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[4] = {0,0,0,0}; + values[2] = ((PyObject *)Py_True); + values[3] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interval); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stat") < 0)) __PYX_ERR(0, 528, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_path = ((PyObject*)values[0]); + if (values[1]) { + __pyx_v_interval = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L3_error) + } else { + __pyx_v_interval = ((float)0.0); + } + __pyx_v_ref = values[2]; + __pyx_v_priority = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("stat", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 528, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) __PYX_ERR(0, 528, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_48stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_54stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_48stat(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_48stat(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stat", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_path); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_ref); + __Pyx_INCREF(__pyx_v_priority); + __Pyx_GIVEREF(__pyx_v_priority); + PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_priority); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_stat), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.stat", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_v_func = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("run_callback (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "run_callback") < 0)) __PYX_ERR(0, 531, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_func = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("run_callback", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 531, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args); +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(((struct PyGeventLoopObject *)__pyx_v_self), __pyx_v_func, __pyx_v_args); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_50run_callback(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_func, PyObject *__pyx_v_args) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + struct PyGeventCallbackObject *__pyx_v_cb = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_RefNannySetupContext("run_callback", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 534, __pyx_L1_error) + + } + + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_func); + __Pyx_GIVEREF(__pyx_v_func); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_func); + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_args); + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext_callback), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_cb = ((struct PyGeventCallbackObject *)__pyx_t_3); + __pyx_t_3 = 0; + + if (unlikely(__pyx_v_self->_callbacks == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); + __PYX_ERR(0, 536, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_callbacks, ((PyObject *)__pyx_v_cb)); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 536, __pyx_L1_error) + + ev_ref(__pyx_v_self->_ptr); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_cb)); + __pyx_r = ((PyObject *)__pyx_v_cb); + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop.run_callback", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_cb); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_59_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_59_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_53_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_52_format(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_58_format(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_58_format(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_52_format(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_52_format(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_v_msg = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_t_4 = NULL; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RefNannySetupContext("_format", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_n_s_destroyed); + __pyx_r = __pyx_n_s_destroyed; + goto __pyx_L0; + + } + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backend); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_msg = __pyx_t_2; + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_default); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 544, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 544, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_1) { + + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_kp_s_default_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2); + __pyx_t_2 = 0; + + } + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pendingcnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_pending_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_2); + __pyx_t_2 = 0; + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format_details); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_3); + __pyx_t_3 = 0; + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_msg); + __pyx_r = __pyx_v_msg; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_XDECREF(__pyx_t_4); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_AddTraceback("gevent.libev.corecext.loop._format", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_msg); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format_details (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_60_format_details(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_54_format_details(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_v_msg = 0; + PyObject *__pyx_v_fileno = 0; + PyObject *__pyx_v_sigfd = 0; + PyObject *__pyx_v_activecnt = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + __Pyx_RefNannySetupContext("_format_details", 0); + + __Pyx_INCREF(__pyx_kp_s__21); + __pyx_v_msg = __pyx_kp_s__21; + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 556, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 556, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_fileno = __pyx_t_1; + __pyx_t_1 = 0; + + __Pyx_INCREF(Py_None); + __pyx_v_sigfd = Py_None; + + __Pyx_INCREF(Py_None); + __pyx_v_activecnt = Py_None; + + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + /*try:*/ { + + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sigfd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_sigfd, __pyx_t_1); + __pyx_t_1 = 0; + + } + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); + if (__pyx_t_7) { + __Pyx_AddTraceback("gevent.libev.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 561, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_3); + + __Pyx_INCREF(Py_None); + __Pyx_DECREF_SET(__pyx_v_sigfd, Py_None); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L4_exception_handled; + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); + __pyx_L10_try_end:; + } + + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_4); + /*try:*/ { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_activecnt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L13_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF_SET(__pyx_v_activecnt, __pyx_t_3); + __pyx_t_3 = 0; + + } + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L20_try_end; + __pyx_L13_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + + __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); + if (__pyx_t_7) { + __Pyx_ErrRestore(0,0,0); + goto __pyx_L14_exception_handled; + } + goto __pyx_L15_except_error; + __pyx_L15_except_error:; + + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); + goto __pyx_L1_error; + __pyx_L14_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); + __pyx_L20_try_end:; + } + + __pyx_t_8 = (__pyx_v_activecnt != Py_None); + __pyx_t_9 = (__pyx_t_8 != 0); + if (__pyx_t_9) { + + __pyx_t_3 = PyObject_Repr(__pyx_v_activecnt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyNumber_Add(__pyx_kp_s_ref_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + } + + __pyx_t_9 = (__pyx_v_fileno != Py_None); + __pyx_t_8 = (__pyx_t_9 != 0); + if (__pyx_t_8) { + + __pyx_t_3 = PyObject_Repr(__pyx_v_fileno); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyNumber_Add(__pyx_kp_s_fileno_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + } + + __pyx_t_9 = (__pyx_v_sigfd != Py_None); + __pyx_t_10 = (__pyx_t_9 != 0); + if (__pyx_t_10) { + } else { + __pyx_t_8 = __pyx_t_10; + goto __pyx_L24_bool_binop_done; + } + __pyx_t_3 = PyObject_RichCompare(__pyx_v_sigfd, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 571, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 571, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_t_10; + __pyx_L24_bool_binop_done:; + if (__pyx_t_8) { + + __pyx_t_3 = PyObject_Repr(__pyx_v_sigfd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyNumber_Add(__pyx_kp_s_sigfd_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + } + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_msg); + __pyx_r = __pyx_v_msg; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop._format_details", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_msg); + __Pyx_XDECREF(__pyx_v_fileno); + __Pyx_XDECREF(__pyx_v_sigfd); + __Pyx_XDECREF(__pyx_v_activecnt); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("fileno (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_62fileno(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_56fileno(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_v_fd; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("fileno", 0); + + __pyx_t_1 = (__pyx_v_self->_ptr != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __pyx_v_self->_ptr->backend_fd; + __pyx_v_fd = __pyx_t_2; + + __pyx_t_1 = ((__pyx_v_fd >= 0) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 580, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + } + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.loop.fileno", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9activecnt___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 587, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 587, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->activecnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.activecnt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_11sig_pending___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 595, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->sig_pending); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.sig_pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(PyObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_5sigfd___get__(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 604, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_ptr->sigfd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.sigfd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_9origflags___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 613, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_f_6gevent_5libev_8corecext__flags_to_list(__pyx_v_self->_ptr->origflags, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.origflags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13origflags_int___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 621, __pyx_L1_error) + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->_ptr->origflags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.loop.origflags_int.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->error_handler); + __pyx_r = __pyx_v_self->error_handler; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->error_handler); + __Pyx_DECREF(__pyx_v_self->error_handler); + __pyx_v_self->error_handler = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4loop_13error_handler_4__del__(struct PyGeventLoopObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->error_handler); + __Pyx_DECREF(__pyx_v_self->error_handler); + __pyx_v_self->error_handler = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks___get__(struct PyGeventLoopObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callbacks); + __pyx_r = __pyx_v_self->_callbacks; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(((struct PyGeventLoopObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_2__set__(struct PyGeventLoopObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->_callbacks); + __Pyx_DECREF(__pyx_v_self->_callbacks); + __pyx_v_self->_callbacks = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.loop._callbacks.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(((struct PyGeventLoopObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4loop_10_callbacks_4__del__(struct PyGeventLoopObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callbacks); + __Pyx_DECREF(__pyx_v_self->_callbacks); + __pyx_v_self->_callbacks = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_args,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 631, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 631, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_callback = values[0]; + __pyx_v_args = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 631, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback___init__(((struct PyGeventCallbackObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback___init__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__init__", 0); + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->callback); + __Pyx_DECREF(__pyx_v_self->callback); + __pyx_v_self->callback = __pyx_v_callback; + + if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_1 = __pyx_v_args; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.callback.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_2stop(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_2stop(struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop", 0); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->callback); + __Pyx_DECREF(__pyx_v_self->callback); + __pyx_v_self->callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4__nonzero__(struct PyGeventCallbackObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__nonzero__", 0); + + __pyx_t_1 = (__pyx_v_self->args != ((PyObject*)Py_None)); + __pyx_r = __pyx_t_1; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_7pending___get__(struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = (__pyx_v_self->callback != Py_None); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 651, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.callback.pending.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_6__repr__(struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_v_format = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + char const *__pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + __pyx_t_1 = ((Py_ReprEnter(((PyObject*)__pyx_v_self)) != 0) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__27); + __pyx_r = __pyx_kp_s__27; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__21); + __pyx_r = __pyx_kp_s__21; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__26); + __pyx_r = __pyx_kp_s__26; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + goto __pyx_L0; + + } + + /*try:*/ { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 657, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 657, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 657, __pyx_L5_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_format = __pyx_t_2; + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_INCREF(__pyx_v_format); + __Pyx_GIVEREF(__pyx_v_format); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_format); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_result = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 659, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 659, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_1) { + + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __pyx_t_1 = (__pyx_v_self->callback != Py_None); + __pyx_t_5 = (__pyx_t_1 != 0); + if (__pyx_t_5) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 662, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_self->callback); + __Pyx_GIVEREF(__pyx_v_self->callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->callback); + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 662, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 662, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __pyx_t_5 = (__pyx_v_self->args != ((PyObject*)Py_None)); + __pyx_t_1 = (__pyx_t_5 != 0); + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_self->args); + __Pyx_GIVEREF(__pyx_v_self->args); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->args); + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __pyx_t_5 = (__pyx_v_self->callback == Py_None); + __pyx_t_6 = (__pyx_t_5 != 0); + if (__pyx_t_6) { + } else { + __pyx_t_1 = __pyx_t_6; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_6 = (__pyx_v_self->args == ((PyObject*)Py_None)); + __pyx_t_5 = (__pyx_t_6 != 0); + __pyx_t_1 = __pyx_t_5; + __pyx_L11_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_stopped); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__28); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 667, __pyx_L5_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__22); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 667, __pyx_L5_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__27); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 667, __pyx_L5_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_4); + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L4_return; + } + + /*finally:*/ { + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L5_error:; + __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; + { + Py_ReprLeave(((PyObject*)__pyx_v_self)); + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); + } + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); + __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_15 = __pyx_r; + __pyx_r = 0; + Py_ReprLeave(((PyObject*)__pyx_v_self)); + __pyx_r = __pyx_t_15; + __pyx_t_15 = 0; + goto __pyx_L0; + } + } + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext.callback.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_format); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8_format(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8_format(CYTHON_UNUSED struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format", 0); + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__23); + __pyx_r = __pyx_kp_s__23; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__21); + __pyx_r = __pyx_kp_s__21; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_8callback___get__(struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->callback); + __pyx_r = __pyx_v_self->callback; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->callback); + __Pyx_DECREF(__pyx_v_self->callback); + __pyx_v_self->callback = __pyx_v_value; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback_8callback_4__del__(struct PyGeventCallbackObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->callback); + __Pyx_DECREF(__pyx_v_self->callback); + __pyx_v_self->callback = Py_None; + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_8callback_4args___get__(struct PyGeventCallbackObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(((struct PyGeventCallbackObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_2__set__(struct PyGeventCallbackObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 629, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.callback.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(((struct PyGeventCallbackObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_8callback_4args_4__del__(struct PyGeventCallbackObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher___repr__(((struct PyGeventWatcherObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher___repr__(struct PyGeventWatcherObject *__pyx_v_self) { + PyObject *__pyx_v_format = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + char const *__pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + __Pyx_RefNannySetupContext("__repr__", 0); + + __pyx_t_1 = ((Py_ReprEnter(((PyObject*)__pyx_v_self)) != 0) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__27); + __pyx_r = __pyx_kp_s__27; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__21); + __pyx_r = __pyx_kp_s__21; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__26); + __pyx_r = __pyx_kp_s__26; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + goto __pyx_L0; + + } + + /*try:*/ { + + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L5_error) + } + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_format = __pyx_t_2; + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_INCREF(__pyx_v_format); + __Pyx_GIVEREF(__pyx_v_format); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_format); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x_s_2, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_result = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_active); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 704, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 704, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_1) { + + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_active_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 705, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pending); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 706, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 706, __pyx_L5_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_1) { + + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_s_pending_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 708, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = (__pyx_t_4 != Py_None); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = (__pyx_t_1 != 0); + if (__pyx_t_5) { + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_callback_r, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2)); + __pyx_t_2 = 0; + + } + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = (__pyx_t_2 != Py_None); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = (__pyx_t_5 != 0); + if (__pyx_t_1) { + + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 711, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_args_r, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 711, __pyx_L5_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + } + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__28); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 712, __pyx_L5_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__22); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 712, __pyx_L5_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_4 = PyNumber_Add(__pyx_v_result, __pyx_kp_s__27); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 712, __pyx_L5_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_4); + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L4_return; + } + + /*finally:*/ { + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __pyx_L5_error:; + __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename; + { + Py_ReprLeave(((PyObject*)__pyx_v_self)); + } + __Pyx_PyThreadState_assign + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); + } + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11); + __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_14 = __pyx_r; + __pyx_r = 0; + Py_ReprLeave(((PyObject*)__pyx_v_self)); + __pyx_r = __pyx_t_14; + __pyx_t_14 = 0; + goto __pyx_L0; + } + } + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext.watcher.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_format); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7watcher_3_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7watcher_2_format(((struct PyGeventWatcherObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7watcher_2_format(CYTHON_UNUSED struct PyGeventWatcherObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format", 0); + + __Pyx_XDECREF(__pyx_r); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__23); + __pyx_r = __pyx_kp_s__23; +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_INCREF(__pyx_kp_s__21); + __pyx_r = __pyx_kp_s__21; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_3ref___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_3ref___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_3ref_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_3ref_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 737, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 738, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8callback___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8callback___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8callback_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_8callback_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 759, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 759, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 759, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 759, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 759, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.io.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_stop(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_stop(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 765, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_io_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8priority___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8priority___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.io.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8priority_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_8priority_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 783, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 786, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 786, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 786, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 786, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.io.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2feed(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2feed(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 789, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 790, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_pass_events = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_pass_events,0}; + PyObject* values[2] = {0,0}; + values[1] = ((PyObject *)Py_False); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (kw_args == 1) { + const Py_ssize_t index = 1; + PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); + if (value) { values[index] = value; kw_args--; } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 800, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + __pyx_v_pass_events = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 800, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4start(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_pass_events, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4start(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_pass_events, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 803, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 805, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 806, __pyx_L1_error) + + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_pass_events); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 807, __pyx_L1_error) + if (__pyx_t_3) { + + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 808, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(GEVENT_CORE_EVENTS); + __Pyx_GIVEREF(GEVENT_CORE_EVENTS); + PyTuple_SET_ITEM(__pyx_t_2, 0, GEVENT_CORE_EVENTS); + __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 808, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + goto __pyx_L5; + } + + /*else*/ { + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + } + __pyx_L5:; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_io_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext.io.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6active___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6active___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_7pending___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_7pending___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + vfd_socket_t __pyx_v_fd; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_v_fd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + vfd_socket_t __pyx_v_fd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_v_events; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_fd,&__pyx_n_s_events_2,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)Py_True); + values[4] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--; + else { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 848, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events_2)) != 0)) kw_args--; + else { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 848, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 848, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[1]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 848, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 848, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_v_fd = __Pyx_PyInt_As_vfd_socket_t(values[1]); if (unlikely((__pyx_v_fd == ((vfd_socket_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error) + __pyx_v_events = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_v_ref = values[3]; + __pyx_v_priority = values[4]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 848, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 832, __pyx_L3_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 832, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 848, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 832, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(((struct PyGeventIOObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_fd, __pyx_v_events, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, vfd_socket_t __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_v_vfd; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static int __pyx_pf_6gevent_5libev_8corecext_2io_6__init__(struct PyGeventIOObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_fd, int __pyx_v_events, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + __Pyx_RefNannySetupContext("__init__", 0); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0); +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = ((__pyx_v_fd < 0) != 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_fd_must_be_non_negative_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 850, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __pyx_t_3 = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 850, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 834, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __PYX_ERR(0, 834, __pyx_L1_error) + + } + + __pyx_t_4 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 835, __pyx_L1_error) + __pyx_v_vfd = __pyx_t_4; + + vfd_free(__pyx_v_self->_watcher.fd); + + ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_events); +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __PYX_ERR(0, 850, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_events & (~((EV__IOFDSET | EV_READ) | EV_WRITE))) != 0); + if (__pyx_t_1) { + + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_illegal_event_mask_r, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 852, __pyx_L1_error) + + } + + ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_fd, __pyx_v_events); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __PYX_ERR(0, 834, __pyx_L1_error) + + } + + __pyx_t_4 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 835, __pyx_L1_error) + __pyx_v_vfd = __pyx_t_4; + + vfd_free(__pyx_v_self->_watcher.fd); + + ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_events); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 839, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 855, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 839, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + goto __pyx_L4; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + goto __pyx_L5; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + goto __pyx_L4; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_L4:; +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_L5:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_L4:; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + __pyx_t_1 = (__pyx_v_priority != Py_None); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_5 = (__pyx_t_1 != 0); + if (__pyx_t_5) { + + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 844, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_4); +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_4 = (__pyx_t_1 != 0); + if (__pyx_t_4) { + + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 860, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_5); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_5 = (__pyx_t_1 != 0); + if (__pyx_t_5) { + + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 844, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_4); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.io.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_2fd___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_long(vfd_get(__pyx_v_self->_watcher.fd)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fd) { + long __pyx_v_fd; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_fd); { + __pyx_v_fd = __Pyx_PyInt_As_long(__pyx_arg_fd); if (unlikely((__pyx_v_fd == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 869, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((long)__pyx_v_fd)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_2fd_2__set__(struct PyGeventIOObject *__pyx_v_self, long __pyx_v_fd) { + int __pyx_v_vfd; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 871, __pyx_L1_error) + + } + + __pyx_t_3 = vfd_open(__pyx_v_fd); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 872, __pyx_L1_error) + __pyx_v_vfd = __pyx_t_3; + + vfd_free(__pyx_v_self->_watcher.fd); + + ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_vfd, __pyx_v_self->_watcher.events); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.fd.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6events___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.events); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 879, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.events.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_events) { + int __pyx_v_events; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_events); { + __pyx_v_events = __Pyx_PyInt_As_int(__pyx_arg_events); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 881, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((int)__pyx_v_events)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_6events_2__set__(struct PyGeventIOObject *__pyx_v_self, int __pyx_v_events) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 883, __pyx_L1_error) + + } + + ev_io_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_io), __pyx_v_self->_watcher.fd, __pyx_v_events); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.io.events.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_10events_str___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext__events_to_str(__pyx_v_self->_watcher.events, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 889, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.events_str.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_8_format(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_8_format(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("_format", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_events_str); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 892, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_fd_s_events_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.io._format", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_11__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_11__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_10__cinit__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_10__cinit__(struct PyGeventIOObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__", 0); + + __pyx_v_self->_watcher.fd = -1; + + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static void __pyx_pw_6gevent_5libev_8corecext_2io_13__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_6gevent_5libev_8corecext_2io_13__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_6gevent_5libev_8corecext_2io_12__dealloc__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_6gevent_5libev_8corecext_2io_12__dealloc__(struct PyGeventIOObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + vfd_free(__pyx_v_self->_watcher.fd); + + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4loop___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4loop___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4loop_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_4loop_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 723, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4loop_4__del__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_4loop_4__del__(struct PyGeventIOObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4args___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_4args___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4args_2__set__(((struct PyGeventIOObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_4args_2__set__(struct PyGeventIOObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 725, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_2io_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_4args_4__del__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_2io_4args_4__del__(struct PyGeventIOObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_2io_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_2io_6_flags___get__(((struct PyGeventIOObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_2io_6_flags___get__(struct PyGeventIOObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.io._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_3ref___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_3ref___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_3ref_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_3ref_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 922, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 923, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_8callback___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8callback___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_8callback_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_8callback_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 944, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 944, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 944, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.timer.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_stop(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_stop(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 950, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_timer_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_8priority___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8priority___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 964, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.timer.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 966, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.timer.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_8priority_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_8priority_2__set__(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 968, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 971, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 971, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 971, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 971, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.timer.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_2feed(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2feed(struct PyGeventTimerObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 974, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 975, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_update = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0}; + PyObject* values[2] = {0,0}; + values[1] = ((PyObject *)Py_True); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (kw_args == 1) { + const Py_ssize_t index = 1; + PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); + if (value) { values[index] = value; kw_args--; } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 985, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + __pyx_v_update = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 985, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4start(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4start(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 988, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 990, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 991, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 996, __pyx_L1_error) + if (__pyx_t_3) { + + ev_now_update(__pyx_v_self->loop->_ptr); + + } + + ev_timer_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_6active___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6active___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_7pending___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_7pending___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + double __pyx_v_after; + double __pyx_v_repeat; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_after,&__pyx_n_s_repeat,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)Py_True); + values[4] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_after); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_repeat); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1014, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + if (values[1]) { + __pyx_v_after = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_after == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1014, __pyx_L3_error) + } else { + __pyx_v_after = ((double)0.0); + } + if (values[2]) { + __pyx_v_repeat = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_repeat == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1014, __pyx_L3_error) + } else { + __pyx_v_repeat = ((double)0.0); + } + __pyx_v_ref = values[3]; + __pyx_v_priority = values[4]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1014, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1014, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_6__init__(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_after, __pyx_v_repeat, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_6__init__(struct PyGeventTimerObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, double __pyx_v_after, double __pyx_v_repeat, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + __Pyx_RefNannySetupContext("__init__", 0); + + __pyx_t_1 = ((__pyx_v_repeat < 0.0) != 0); + if (__pyx_t_1) { + + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1016, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1016, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1016, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1016, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 1016, __pyx_L1_error) + + } + + ev_timer_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_timer), __pyx_v_after, __pyx_v_repeat); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1019, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L4; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L4:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_4 = (__pyx_t_1 != 0); + if (__pyx_t_4) { + + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_5); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_2at___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.timer.at.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_9again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_9again(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_update = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("again (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_update,0}; + PyObject* values[2] = {0,0}; + values[1] = ((PyObject *)Py_True); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (kw_args == 1) { + const Py_ssize_t index = 1; + PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]); + if (value) { values[index] = value; kw_args--; } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "again") < 0)) __PYX_ERR(0, 1033, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + __pyx_v_update = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("again", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1033, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_8again(((struct PyGeventTimerObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_update, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_8again(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_update, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("again", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1036, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1037, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_update); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1042, __pyx_L1_error) + if (__pyx_t_1) { + + ev_now_update(__pyx_v_self->loop->_ptr); + + } + + ev_timer_again(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.timer.again", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4loop___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4loop___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 908, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.timer.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_4__del__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4loop_4__del__(struct PyGeventTimerObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4args___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_4args___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4args_2__set__(((struct PyGeventTimerObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4args_2__set__(struct PyGeventTimerObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 910, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.timer.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5timer_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_4args_4__del__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5timer_4args_4__del__(struct PyGeventTimerObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5timer_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5timer_6_flags___get__(((struct PyGeventTimerObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5timer_6_flags___get__(struct PyGeventTimerObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 911, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.timer._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_3ref___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_3ref___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_3ref_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_3ref_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1067, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1068, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.signal.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_8callback___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_8callback___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_8callback_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_8callback_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1089, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1089, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1089, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1089, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1089, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.signal.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_stop(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_stop(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1095, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_signal_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.signal.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_8priority___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_8priority___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.signal.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1111, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.signal.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_8priority_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_8priority_2__set__(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1113, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.signal.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1116, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1116, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1116, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1116, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.signal.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_2feed(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_2feed(struct PyGeventSignalObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1119, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1120, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.signal.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1130, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1130, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.signal.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4start(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4start(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1133, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1135, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1136, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_signal_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.signal.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_6active___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_6active___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_7pending___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_7pending___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + int __pyx_v_signalnum; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_signalnum,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[4] = {0,0,0,0}; + values[2] = ((PyObject *)Py_True); + values[3] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signalnum)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 1157, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1157, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_signalnum = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_signalnum == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1157, __pyx_L3_error) + __pyx_v_ref = values[2]; + __pyx_v_priority = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1157, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1157, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_6__init__(((struct PyGeventSignalObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_signalnum, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_6__init__(struct PyGeventSignalObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_signalnum, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + __Pyx_RefNannySetupContext("__init__", 0); + + __pyx_t_2 = ((__pyx_v_signalnum < 1) != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_signalmodule); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NSIG); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1158, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1158, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_signalnum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_illegal_signal_number_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1159, __pyx_L1_error) + + } + + ev_signal_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_signal), __pyx_v_signalnum); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1167, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L6; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L6:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1172, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_6); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.signal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4loop___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4loop___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1053, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.signal.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_4__del__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4loop_4__del__(struct PyGeventSignalObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4args___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_4args___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4args_2__set__(((struct PyGeventSignalObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4args_2__set__(struct PyGeventSignalObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1055, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.signal.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_6signal_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_4args_4__del__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_6signal_4args_4__del__(struct PyGeventSignalObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_6signal_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_6signal_6_flags___get__(((struct PyGeventSignalObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_6signal_6_flags___get__(struct PyGeventSignalObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.signal._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_3ref___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_3ref___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_3ref_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_3ref_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1192, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1193, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.idle.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_8callback___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_8callback___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_8callback_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_8callback_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1214, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.idle.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_stop(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_stop(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1220, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_idle_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.idle.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_8priority___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_8priority___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1234, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.idle.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1236, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.idle.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_8priority_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_8priority_2__set__(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1238, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.idle.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1241, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1241, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1241, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1241, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.idle.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_2feed(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_2feed(struct PyGeventIdleObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1244, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1245, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.idle.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1255, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1255, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.idle.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4start(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4start(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1258, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1260, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1261, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_idle_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.idle.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_6active___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_6active___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_7pending___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_7pending___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1283, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1283, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.idle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1283, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_6__init__(((struct PyGeventIdleObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_6__init__(struct PyGeventIdleObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + ev_idle_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_idle)); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1286, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L3:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1291, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.idle.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4loop___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4loop___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1178, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.idle.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_4__del__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4loop_4__del__(struct PyGeventIdleObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4args___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_4args___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4args_2__set__(((struct PyGeventIdleObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4args_2__set__(struct PyGeventIdleObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1180, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.idle.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4idle_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_4args_4__del__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4idle_4args_4__del__(struct PyGeventIdleObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4idle_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4idle_6_flags___get__(((struct PyGeventIdleObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4idle_6_flags___get__(struct PyGeventIdleObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.idle._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_3ref___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_3ref___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_3ref_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_3ref_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1311, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1312, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_8callback___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_8callback___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_8callback_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_8callback_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1333, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_stop(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_stop(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1339, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_prepare_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_8priority___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_8priority___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1355, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.prepare.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_8priority_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_8priority_2__set__(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1357, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1360, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1360, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1360, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1360, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.prepare.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_2feed(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_2feed(struct PyGeventPrepareObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1363, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1364, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1374, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1374, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.prepare.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4start(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4start(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1377, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1379, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1380, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_prepare_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_6active___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_6active___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_7pending___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_7pending___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1402, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1402, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.prepare.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1402, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_6__init__(((struct PyGeventPrepareObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_6__init__(struct PyGeventPrepareObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + ev_prepare_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_prepare)); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1405, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L3:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1410, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.prepare.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4loop___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1297, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_4__del__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4loop_4__del__(struct PyGeventPrepareObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4args___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_4args___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_2__set__(((struct PyGeventPrepareObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_2__set__(struct PyGeventPrepareObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1299, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.prepare.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_4__del__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_7prepare_4args_4__del__(struct PyGeventPrepareObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_7prepare_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_7prepare_6_flags___get__(((struct PyGeventPrepareObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_7prepare_6_flags___get__(struct PyGeventPrepareObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1300, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.prepare._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_3ref___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_3ref___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_3ref_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_3ref_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1430, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1431, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.check.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_8callback___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_8callback___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_8callback_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_8callback_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1452, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1452, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1452, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.check.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_stop(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_stop(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1458, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_check_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.check.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_8priority___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_8priority___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.check.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1474, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.check.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_8priority_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_8priority_2__set__(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1476, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.check.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1479, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1479, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1479, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1479, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.check.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_2feed(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_2feed(struct PyGeventCheckObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1482, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1483, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.check.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1493, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1493, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.check.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4start(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4start(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1496, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1498, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1499, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_check_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.check.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_6active___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_6active___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_7pending___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_7pending___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1521, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1521, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.check.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1521, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_6__init__(((struct PyGeventCheckObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_6__init__(struct PyGeventCheckObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + ev_check_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_check)); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1524, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L3:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1529, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.check.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4loop___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4loop___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4loop_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_4loop_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1416, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.check.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4loop_4__del__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_4loop_4__del__(struct PyGeventCheckObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4args___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_4args___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4args_2__set__(((struct PyGeventCheckObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_4args_2__set__(struct PyGeventCheckObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1418, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.check.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5check_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_4args_4__del__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5check_4args_4__del__(struct PyGeventCheckObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5check_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5check_6_flags___get__(((struct PyGeventCheckObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5check_6_flags___get__(struct PyGeventCheckObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.check._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_3ref___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_3ref___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_3ref_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_3ref_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1549, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1550, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.fork.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_8callback___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_8callback___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_8callback_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_8callback_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1571, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1571, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1571, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1571, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1571, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.fork.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_stop(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_stop(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1577, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_fork_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.fork.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_8priority___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_8priority___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1591, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.fork.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1593, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.fork.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_8priority_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_8priority_2__set__(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1595, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.fork.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1598, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1598, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1598, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1598, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.fork.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_2feed(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_2feed(struct PyGeventForkObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1601, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1602, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.fork.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1612, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1612, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.fork.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4start(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4start(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1615, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1617, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1618, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_fork_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.fork.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_6active___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_6active___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_7pending___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_7pending___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1640, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1640, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.fork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1640, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_6__init__(((struct PyGeventForkObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_6__init__(struct PyGeventForkObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + ev_fork_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_fork)); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1643, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L3:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1648, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.fork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4loop___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4loop___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1535, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.fork.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_4__del__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4loop_4__del__(struct PyGeventForkObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4args___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_4args___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4args_2__set__(((struct PyGeventForkObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4args_2__set__(struct PyGeventForkObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1537, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.fork.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4fork_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_4args_4__del__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4fork_4args_4__del__(struct PyGeventForkObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4fork_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4fork_6_flags___get__(((struct PyGeventForkObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4fork_6_flags___get__(struct PyGeventForkObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.fork._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_3ref___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_3ref___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_3ref_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_3ref_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1668, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1669, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_8callback___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8callback___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_8callback_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_8callback_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1690, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1690, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1690, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1690, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1690, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.async.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_stop(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_stop(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1696, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_async_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_8priority___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8priority___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1710, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.async.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1712, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.async.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_8priority_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_8priority_2__set__(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1714, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1717, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1717, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1717, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1717, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.async.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_2feed(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_2feed(struct PyGeventAsyncObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1720, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1721, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1731, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1731, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.async.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4start(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4start(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1734, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1736, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1737, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_async_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_6active___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_6active___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_7pending___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_7pending___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_async_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[3] = {0,0,0}; + values[1] = ((PyObject *)Py_True); + values[2] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1758, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_ref = values[1]; + __pyx_v_priority = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1758, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.async.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1758, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_6__init__(((struct PyGeventAsyncObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_6__init__(struct PyGeventAsyncObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + ev_async_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_async)); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1761, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L3:; + + __pyx_t_1 = (__pyx_v_priority != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1766, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_3); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("gevent.libev.corecext.async.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_9send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_9send(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("send (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_8send(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_8send(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("send", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1771, __pyx_L1_error) + + } + + ev_async_send(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.async.send", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4loop___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4loop___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4loop_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_4loop_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1654, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.async.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4loop_4__del__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_4loop_4__del__(struct PyGeventAsyncObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4args___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_4args___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4args_2__set__(((struct PyGeventAsyncObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_4args_2__set__(struct PyGeventAsyncObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1656, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.async.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5async_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_4args_4__del__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5async_4args_4__del__(struct PyGeventAsyncObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5async_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5async_6_flags___get__(((struct PyGeventAsyncObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5async_6_flags___get__(struct PyGeventAsyncObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1657, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.async._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3ref_1__get__(PyObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_3ref___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3ref___get__(struct PyGeventChildObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static int __pyx_pw_6gevent_5libev_8corecext_5child_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_3ref_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_3ref_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1794, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1795, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.child.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_8callback___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8callback___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_8callback_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_8callback_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1816, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1816, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1816, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.child.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_stop(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_stop(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1822, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_child_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.child.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_8priority___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8priority___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1836, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1838, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.child.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_8priority_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_8priority_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1840, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.child.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1843, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1843, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1843, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1843, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.child.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_2feed(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_2feed(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1846, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1847, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.child.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 1857, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1857, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.child.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4start(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4start(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1860, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1862, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1863, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_child_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.child.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_6active___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_6active___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_7pending___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7pending___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + int __pyx_v_pid; + int __pyx_v_trace; + PyObject *__pyx_v_ref = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_pid,&__pyx_n_s_trace,&__pyx_n_s_ref,0}; + PyObject* values[4] = {0,0,0,0}; + values[3] = ((PyObject *)Py_True); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pid)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 1884, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trace); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1884, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_pid = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_pid == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1884, __pyx_L3_error) + if (values[2]) { + __pyx_v_trace = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_trace == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1884, __pyx_L3_error) + } else { + __pyx_v_trace = ((int)0); + } + __pyx_v_ref = values[3]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1884, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 1884, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_6__init__(((struct PyGeventChildObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_pid, __pyx_v_trace, __pyx_v_ref); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_6__init__(struct PyGeventChildObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, int __pyx_v_pid, int __pyx_v_trace, PyObject *__pyx_v_ref) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__init__", 0); + + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_loop), __pyx_n_s_default); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1885, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1885, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = ((!__pyx_t_2) != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 1886, __pyx_L1_error) + + } + + gevent_install_sigchld_handler(); + + ev_child_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_child), __pyx_v_pid, __pyx_v_trace); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1890, __pyx_L1_error) + if (__pyx_t_3) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L4; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_9_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_format (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_8_format(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_8_format(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("_format", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1896, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rstatus); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1896, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1896, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_pid_r_rstatus_r, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1896, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("gevent.libev.corecext.child._format", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_3pid___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.pid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1901, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.pid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4rpid___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rpid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1906, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.rpid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) { + int __pyx_v_value; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_value); { + __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1908, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.child.rpid.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_4rpid_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_v_self->_watcher.rpid = __pyx_v_value; + + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_7rstatus___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_watcher.rstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1914, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.rstatus.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) { + int __pyx_v_value; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_value); { + __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1916, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.child.rstatus.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((int)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_7rstatus_2__set__(struct PyGeventChildObject *__pyx_v_self, int __pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_v_self->_watcher.rstatus = __pyx_v_value; + + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4loop___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4loop___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4loop_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_4loop_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1780, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4loop_4__del__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_4loop_4__del__(struct PyGeventChildObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4args___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_4args___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4args_2__set__(((struct PyGeventChildObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_4args_2__set__(struct PyGeventChildObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1782, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_5child_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_4args_4__del__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_5child_4args_4__del__(struct PyGeventChildObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_5child_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_5child_6_flags___get__(((struct PyGeventChildObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_5child_6_flags___get__(struct PyGeventChildObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1783, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.child._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_3ref___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if (((__pyx_v_self->_flags & 4) != 0)) { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } else { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_3ref_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1939, __pyx_L1_error) + + } + + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1940, __pyx_L1_error) + if (__pyx_t_1) { + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 4) != 0)) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~6)); + + goto __pyx_L4; + } + + /*else*/ { + __pyx_t_1 = ((__pyx_v_self->_flags & 4) != 0); + if (__pyx_t_1) { + + __pyx_r = 0; + goto __pyx_L0; + + } + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 4); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 2) != 0)) != 0); + if (__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_3 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + } + __pyx_L4:; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8callback_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8callback_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8callback___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8callback___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_callback); + __pyx_r = __pyx_v_self->_callback; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_8callback_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8callback_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_8callback_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_2 = ((!(PyCallable_Check(((PyObject*)__pyx_v_callback)) != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_callback != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1961, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_callback); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_not_r, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1961, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1961, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1961, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 1961, __pyx_L1_error) + + } + + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = __pyx_v_callback; + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("gevent.libev.corecext.stat.callback.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_1stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stop (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_stop(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_stop(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("stop", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1967, __pyx_L1_error) + + } + + __pyx_t_1 = ((__pyx_v_self->_flags & 2) != 0); + if (__pyx_t_1) { + + ev_ref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~2)); + + } + + ev_stat_stop(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->_callback); + __Pyx_DECREF(__pyx_v_self->_callback); + __pyx_v_self->_callback = Py_None; + + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + __pyx_t_1 = ((__pyx_v_self->_flags & 1) != 0); + if (__pyx_t_1) { + + Py_DECREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags & (~1)); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.stop", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8priority_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8priority_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8priority___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8priority___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(ev_priority((&__pyx_v_self->_watcher))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1981, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.stat.priority.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_8priority_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_priority) { + int __pyx_v_priority; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + assert(__pyx_arg_priority); { + __pyx_v_priority = __Pyx_PyInt_As_int(__pyx_arg_priority); if (unlikely((__pyx_v_priority == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1983, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.stat.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8priority_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((int)__pyx_v_priority)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_8priority_2__set__(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_priority) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + + __pyx_t_1 = (ev_is_active((&__pyx_v_self->_watcher)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1985, __pyx_L1_error) + + } + + ev_set_priority((&__pyx_v_self->_watcher), __pyx_v_priority); + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.priority.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_3feed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_revents; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("feed (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 2) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_revents,&__pyx_n_s_callback,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_revents)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, 1); __PYX_ERR(0, 1988, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "feed") < 0)) __PYX_ERR(0, 1988, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_revents = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_revents == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1988, __pyx_L3_error) + __pyx_v_callback = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("feed", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1988, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.stat.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_2feed(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_revents, __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_2feed(struct PyGeventStatObject *__pyx_v_self, int __pyx_v_revents, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("feed", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 1991, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1992, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_1 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_1) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_feed_event(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher), __pyx_v_revents); + + __pyx_t_1 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_1) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_5start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("start (wrapper)", 0); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "start") < 0)) __PYX_ERR(0, 2002, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_callback = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("start", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2002, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_AddTraceback("gevent.libev.corecext.stat.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4start(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_args); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4start(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_args) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_RefNannySetupContext("start", 0); + + __pyx_t_1 = ((!(__pyx_v_self->loop->_ptr != 0)) != 0); + if (__pyx_t_1) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 2005, __pyx_L1_error) + + } + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_3 = (__pyx_t_1 != 0); + if (__pyx_t_3) { + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 2007, __pyx_L1_error) + + } + + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 2008, __pyx_L1_error) + + __Pyx_INCREF(__pyx_v_args); + __Pyx_GIVEREF(__pyx_v_args); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = __pyx_v_args; + + __pyx_t_3 = (((__pyx_v_self->_flags & 6) == 4) != 0); + if (__pyx_t_3) { + + ev_unref(__pyx_v_self->loop->_ptr); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 2); + + } + + ev_stat_start(__pyx_v_self->loop->_ptr, (&__pyx_v_self->_watcher)); + + __pyx_t_3 = ((!((__pyx_v_self->_flags & 1) != 0)) != 0); + if (__pyx_t_3) { + + Py_INCREF(((PyObject*)__pyx_v_self)); + + __pyx_v_self->_flags = (__pyx_v_self->_flags | 1); + + } + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.start", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6active_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6active_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_6active___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6active___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_active((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_7pending_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_7pending_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_7pending___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_7pending___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + if ((ev_is_pending((&__pyx_v_self->_watcher)) != 0)) { + __Pyx_INCREF(Py_True); + __pyx_t_1 = Py_True; + } else { + __Pyx_INCREF(Py_False); + __pyx_t_1 = Py_False; + } + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_7__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct PyGeventLoopObject *__pyx_v_loop = 0; + PyObject *__pyx_v_path = 0; + float __pyx_v_interval; + PyObject *__pyx_v_ref = 0; + PyObject *__pyx_v_priority = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_path,&__pyx_n_s_interval,&__pyx_n_s_ref,&__pyx_n_s_priority,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)Py_True); + values[4] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); __PYX_ERR(0, 2031, __pyx_L3_error) + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interval); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_priority); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 2031, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_loop = ((struct PyGeventLoopObject *)values[0]); + __pyx_v_path = ((PyObject*)values[1]); + if (values[2]) { + __pyx_v_interval = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_interval == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 2031, __pyx_L3_error) + } else { + __pyx_v_interval = ((float)0.0); + } + __pyx_v_ref = values[3]; + __pyx_v_priority = values[4]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2031, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("gevent.libev.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loop), __pyx_ptype_6gevent_5libev_8corecext_loop, 1, "loop", 0))) __PYX_ERR(0, 2031, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyString_Type), 1, "path", 1))) __PYX_ERR(0, 2031, __pyx_L1_error) + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_6__init__(((struct PyGeventStatObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_path, __pyx_v_interval, __pyx_v_ref, __pyx_v_priority); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_6__init__(struct PyGeventStatObject *__pyx_v_self, struct PyGeventLoopObject *__pyx_v_loop, PyObject *__pyx_v_path, float __pyx_v_interval, PyObject *__pyx_v_ref, PyObject *__pyx_v_priority) { + PyObject *__pyx_v_paths = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + char *__pyx_t_8; + int __pyx_t_9; + __Pyx_RefNannySetupContext("__init__", 0); + + __Pyx_INCREF(__pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + __Pyx_GOTREF(__pyx_v_self->path); + __Pyx_DECREF(__pyx_v_self->path); + __pyx_v_self->path = __pyx_v_path; + + __pyx_t_1 = PyUnicode_Check(__pyx_v_path); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (__pyx_t_6) { + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else { + __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2038, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_7) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 2038, __pyx_L1_error) + __pyx_v_paths = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + __Pyx_INCREF(__pyx_v_paths); + __Pyx_GIVEREF(__pyx_v_paths); + __Pyx_GOTREF(__pyx_v_self->_paths); + __Pyx_DECREF(__pyx_v_self->_paths); + __pyx_v_self->_paths = __pyx_v_paths; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_t_3 = __pyx_v_path; + __Pyx_INCREF(__pyx_t_3); + __pyx_v_paths = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + __Pyx_INCREF(__pyx_v_paths); + __Pyx_GIVEREF(__pyx_v_paths); + __Pyx_GOTREF(__pyx_v_self->_paths); + __Pyx_DECREF(__pyx_v_self->_paths); + __pyx_v_self->_paths = __pyx_v_paths; + } + __pyx_L3:; + + __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_paths); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 2043, __pyx_L1_error) + ev_stat_init((&__pyx_v_self->_watcher), ((void *)gevent_callback_stat), ((char *)__pyx_t_8), __pyx_v_interval); + + __Pyx_INCREF(((PyObject *)__pyx_v_loop)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_loop)); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = __pyx_v_loop; + + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_ref); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2045, __pyx_L1_error) + if (__pyx_t_2) { + + __pyx_v_self->_flags = 0; + + goto __pyx_L4; + } + + /*else*/ { + __pyx_v_self->_flags = 4; + } + __pyx_L4:; + + __pyx_t_2 = (__pyx_v_priority != Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_priority); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2050, __pyx_L1_error) + ev_set_priority((&__pyx_v_self->_watcher), __pyx_t_9); + + } + + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("gevent.libev.corecext.stat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_paths); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4attr___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_watcher.attr.st_nlink != 0)) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.attr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2057, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.attr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4prev___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __pyx_t_1 = ((!(__pyx_v_self->_watcher.prev.st_nlink != 0)) != 0); + if (__pyx_t_1) { + + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + } + + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = _pystat_fromstructstat((&__pyx_v_self->_watcher.prev)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2064, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("gevent.libev.corecext.stat.prev.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_8interval___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_watcher.interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.stat.interval.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4loop_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4loop___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4loop___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->loop)); + __pyx_r = ((PyObject *)__pyx_v_self->loop); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_6gevent_5libev_8corecext_loop))))) __PYX_ERR(0, 1925, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.stat.loop.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_4__del__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4loop_4__del__(struct PyGeventStatObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->loop); + __Pyx_DECREF(((PyObject *)__pyx_v_self->loop)); + __pyx_v_self->loop = ((struct PyGeventLoopObject *)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4args_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4args_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4args___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4args___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->args); + __pyx_r = __pyx_v_self->args; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4args_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4args_2__set__(((struct PyGeventStatObject *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4args_2__set__(struct PyGeventStatObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__set__", 0); + if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 1927, __pyx_L1_error) + __pyx_t_1 = __pyx_v_value; + __Pyx_INCREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.stat.args.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4args_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_6gevent_5libev_8corecext_4stat_4args_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4args_4__del__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_6gevent_5libev_8corecext_4stat_4args_4__del__(struct PyGeventStatObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->args); + __Pyx_DECREF(__pyx_v_self->args); + __pyx_v_self->args = ((PyObject*)Py_None); + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_flags_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_flags_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_6_flags___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_flags___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1928, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.stat._flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_4path___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->path); + __pyx_r = __pyx_v_self->path; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(((struct PyGeventStatObject *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_4stat_6_paths___get__(struct PyGeventStatObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_paths); + __pyx_r = __pyx_v_self->_paths; + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + + +static void __pyx_f_6gevent_5libev_8corecext__syserr_cb(char *__pyx_v_msg) { + PyObject *__pyx_v_print_exc = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + int __pyx_t_12; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_syserr_cb", 0); + + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_SYSERR_CALLBACK); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_msg); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_7}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_8) { + __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2077, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L10_try_end; + __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + + /*except:*/ { + __Pyx_AddTraceback("gevent.libev.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 2078, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_10); + + __pyx_t_7 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(Py_None, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2079, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2080, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_7, __pyx_n_s_print_exc, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2080, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_v_print_exc = __pyx_t_6; + __pyx_t_6 = 0; + + __pyx_t_11 = (__pyx_v_print_exc != Py_None); + __pyx_t_12 = (__pyx_t_11 != 0); + if (__pyx_t_12) { + + __Pyx_INCREF(__pyx_v_print_exc); + __pyx_t_7 = __pyx_v_print_exc; __pyx_t_8 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (__pyx_t_8) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L5_except_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else { + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L5_except_error) + } + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L4_exception_handled; + } + __pyx_L5_except_error:; + + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + __pyx_L10_try_end:; + } + + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_WriteUnraisable("gevent.libev.corecext._syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_print_exc); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif +} + + +static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/ +static PyObject *__pyx_f_6gevent_5libev_8corecext_set_syserr_cb(PyObject *__pyx_v_callback, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("set_syserr_cb", 0); + + __pyx_t_1 = (__pyx_v_callback == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + ev_set_syserr_cb(NULL); + + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) __PYX_ERR(0, 2089, __pyx_L1_error) + + goto __pyx_L3; + } + + __pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_callback); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 2090, __pyx_L1_error) + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + ev_set_syserr_cb(((void *)__pyx_f_6gevent_5libev_8corecext__syserr_cb)); + + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, __pyx_v_callback) < 0) __PYX_ERR(0, 2092, __pyx_L1_error) + + goto __pyx_L3; + } + + /*else*/ { + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2094, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_callback); + __Pyx_GIVEREF(__pyx_v_callback); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2094, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2094, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2094, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 2094, __pyx_L1_error) + } + __pyx_L3:; + + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("gevent.libev.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback); /*proto*/ +static PyObject *__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb(PyObject *__pyx_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_syserr_cb (wrapper)", 0); + __pyx_r = __pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(__pyx_self, ((PyObject *)__pyx_v_callback)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6gevent_5libev_8corecext_20set_syserr_cb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_callback) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("set_syserr_cb", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6gevent_5libev_8corecext_set_syserr_cb(__pyx_v_callback, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("gevent.libev.corecext.set_syserr_cb", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext__EVENTSType(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext__EVENTSType(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext__EVENTSType[] = { + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_6gevent_5libev_8corecext__EVENTSType = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext._EVENTSType", /*tp_name*/ + sizeof(struct __pyx_obj_6gevent_5libev_8corecext__EVENTSType), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext__EVENTSType, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_5libev_8corecext_11_EVENTSType_1__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext__EVENTSType, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext__EVENTSType, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop __pyx_vtable_6gevent_5libev_8corecext_loop; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_loop(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct PyGeventLoopObject *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct PyGeventLoopObject *)o); + p->__pyx_vtab = __pyx_vtabptr_6gevent_5libev_8corecext_loop; + p->error_handler = Py_None; Py_INCREF(Py_None); + p->_callbacks = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_loop(PyObject *o) { + struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_6gevent_5libev_8corecext_4loop_7__dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->error_handler); + Py_CLEAR(p->_callbacks); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_loop(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; + if (p->error_handler) { + e = (*v)(p->error_handler, a); if (e) return e; + } + if (p->_callbacks) { + e = (*v)(p->_callbacks, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_loop(PyObject *o) { + PyObject* tmp; + struct PyGeventLoopObject *p = (struct PyGeventLoopObject *)o; + tmp = ((PyObject*)p->error_handler); + p->error_handler = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callbacks); + p->_callbacks = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_ptr(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_3ptr_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_WatcherType(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_11WatcherType_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_MAXPRI(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_6MAXPRI_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_MINPRI(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_6MINPRI_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_default(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_7default_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_iteration(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_9iteration_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_depth(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_5depth_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_backend_int(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_11backend_int_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_backend(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_7backend_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_pendingcnt(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_10pendingcnt_1__get__(o); +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_activecnt(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_9activecnt_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_sig_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_11sig_pending_1__get__(o); +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_sigfd(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_5sigfd_1__get__(o); +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_origflags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_9origflags_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_origflags_int(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_13origflags_int_1__get__(o); +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop_error_handler(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4loop_error_handler(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4loop_13error_handler_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4loop__callbacks(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4loop__callbacks(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4loop_10_callbacks_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_loop[] = { + {"_stop_watchers", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_3_stop_watchers, METH_NOARGS, 0}, + {"destroy", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_5destroy, METH_NOARGS, 0}, + {"_handle_syserr", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_9_handle_syserr, METH_VARARGS|METH_KEYWORDS, 0}, + {"handle_error", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_11handle_error, METH_VARARGS|METH_KEYWORDS, 0}, + {"_default_handle_error", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_13_default_handle_error, METH_VARARGS|METH_KEYWORDS, 0}, + {"run", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_15run, METH_VARARGS|METH_KEYWORDS, 0}, + {"reinit", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_17reinit, METH_NOARGS, 0}, + {"ref", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_19ref, METH_NOARGS, 0}, + {"unref", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_21unref, METH_NOARGS, 0}, + {"break_", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_23break_, METH_VARARGS|METH_KEYWORDS, 0}, + {"verify", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_25verify, METH_NOARGS, 0}, + {"now", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_27now, METH_NOARGS, 0}, + {"update", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_29update, METH_NOARGS, 0}, + {"io", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_33io, METH_VARARGS|METH_KEYWORDS, 0}, + {"timer", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_35timer, METH_VARARGS|METH_KEYWORDS, 0}, + {"signal", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_37signal, METH_VARARGS|METH_KEYWORDS, 0}, + {"idle", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_39idle, METH_VARARGS|METH_KEYWORDS, 0}, + {"prepare", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_41prepare, METH_VARARGS|METH_KEYWORDS, 0}, + {"check", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_43check, METH_VARARGS|METH_KEYWORDS, 0}, + {"fork", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_45fork, METH_VARARGS|METH_KEYWORDS, 0}, + {"async", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_47async, METH_VARARGS|METH_KEYWORDS, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + {"stat", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_49stat, METH_VARARGS|METH_KEYWORDS, 0}, + {"run_callback", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback, METH_VARARGS|METH_KEYWORDS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_53_format, METH_NOARGS, 0}, + {"_format_details", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details, METH_NOARGS, 0}, + {"fileno", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno, METH_NOARGS, 0}, +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {"child", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_49child, METH_VARARGS|METH_KEYWORDS, 0}, + {"install_sigchld", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_51install_sigchld, METH_NOARGS, 0}, + {"reset_sigchld", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_53reset_sigchld, METH_NOARGS, 0}, + {"stat", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_55stat, METH_VARARGS|METH_KEYWORDS, 0}, + {"run_callback", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_57run_callback, METH_VARARGS|METH_KEYWORDS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_59_format, METH_NOARGS, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {"_format_details", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details, METH_NOARGS, 0}, + {"fileno", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno, METH_NOARGS, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + {"stat", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_49stat, METH_VARARGS|METH_KEYWORDS, 0}, + {"run_callback", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_51run_callback, METH_VARARGS|METH_KEYWORDS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_53_format, METH_NOARGS, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + {"_format_details", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_55_format_details, METH_NOARGS, 0}, + {"fileno", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_57fileno, METH_NOARGS, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {"_format_details", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_61_format_details, METH_NOARGS, 0}, + {"fileno", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4loop_63fileno, METH_NOARGS, 0}, +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_loop[] = { + {(char *)"ptr", __pyx_getprop_6gevent_5libev_8corecext_4loop_ptr, 0, (char *)0, 0}, + {(char *)"WatcherType", __pyx_getprop_6gevent_5libev_8corecext_4loop_WatcherType, 0, (char *)0, 0}, + {(char *)"MAXPRI", __pyx_getprop_6gevent_5libev_8corecext_4loop_MAXPRI, 0, (char *)0, 0}, + {(char *)"MINPRI", __pyx_getprop_6gevent_5libev_8corecext_4loop_MINPRI, 0, (char *)0, 0}, + {(char *)"default", __pyx_getprop_6gevent_5libev_8corecext_4loop_default, 0, (char *)0, 0}, + {(char *)"iteration", __pyx_getprop_6gevent_5libev_8corecext_4loop_iteration, 0, (char *)0, 0}, + {(char *)"depth", __pyx_getprop_6gevent_5libev_8corecext_4loop_depth, 0, (char *)0, 0}, + {(char *)"backend_int", __pyx_getprop_6gevent_5libev_8corecext_4loop_backend_int, 0, (char *)0, 0}, + {(char *)"backend", __pyx_getprop_6gevent_5libev_8corecext_4loop_backend, 0, (char *)0, 0}, + {(char *)"pendingcnt", __pyx_getprop_6gevent_5libev_8corecext_4loop_pendingcnt, 0, (char *)0, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {(char *)"activecnt", __pyx_getprop_6gevent_5libev_8corecext_4loop_activecnt, 0, (char *)0, 0}, + {(char *)"sig_pending", __pyx_getprop_6gevent_5libev_8corecext_4loop_sig_pending, 0, (char *)0, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + {(char *)"sigfd", __pyx_getprop_6gevent_5libev_8corecext_4loop_sigfd, 0, (char *)0, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {(char *)"origflags", __pyx_getprop_6gevent_5libev_8corecext_4loop_origflags, 0, (char *)0, 0}, + {(char *)"origflags_int", __pyx_getprop_6gevent_5libev_8corecext_4loop_origflags_int, 0, (char *)0, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {(char *)"error_handler", __pyx_getprop_6gevent_5libev_8corecext_4loop_error_handler, __pyx_setprop_6gevent_5libev_8corecext_4loop_error_handler, (char *)0, 0}, + {(char *)"_callbacks", __pyx_getprop_6gevent_5libev_8corecext_4loop__callbacks, __pyx_setprop_6gevent_5libev_8corecext_4loop__callbacks, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventLoop_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.loop", /*tp_name*/ + sizeof(struct PyGeventLoopObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_loop, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_5libev_8corecext_4loop_31__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_loop, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_loop, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_loop, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_loop, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_4loop_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_loop, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_callback(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct PyGeventCallbackObject *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct PyGeventCallbackObject *)o); + p->callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_callback(PyObject *o) { + struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->callback); + Py_CLEAR(p->args); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_callback(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; + if (p->callback) { + e = (*v)(p->callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_callback(PyObject *o) { + PyObject* tmp; + struct PyGeventCallbackObject *p = (struct PyGeventCallbackObject *)o; + tmp = ((PyObject*)p->callback); + p->callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_8callback_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_8callback_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_8callback_8callback_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_8callback_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_8callback_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_8callback_4args_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_callback[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_8callback_3stop, METH_NOARGS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_8callback_9_format, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_callback[] = { + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_8callback_pending, 0, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_8callback_callback, __pyx_setprop_6gevent_5libev_8corecext_8callback_callback, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_8callback_args, __pyx_setprop_6gevent_5libev_8corecext_8callback_args, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_callback = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY + 0, /*nb_divide*/ + #endif + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + __pyx_pw_6gevent_5libev_8corecext_8callback_5__nonzero__, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY + 0, /*nb_coerce*/ + #endif + 0, /*nb_int*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_long*/ + #else + 0, /*reserved*/ + #endif + 0, /*nb_float*/ + #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY + 0, /*nb_oct*/ + #endif + #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY + 0, /*nb_hex*/ + #endif + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY + 0, /*nb_inplace_divide*/ + #endif + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ + 0, /*nb_index*/ + #if PY_VERSION_HEX >= 0x03050000 + 0, /*nb_matrix_multiply*/ + #endif + #if PY_VERSION_HEX >= 0x03050000 + 0, /*nb_inplace_matrix_multiply*/ + #endif +}; + +DL_EXPORT(PyTypeObject) PyGeventCallback_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.callback", /*tp_name*/ + sizeof(struct PyGeventCallbackObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_callback, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_5libev_8corecext_8callback_7__repr__, /*tp_repr*/ + &__pyx_tp_as_number_callback, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_callback, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_callback, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_callback, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_callback, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_8callback_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_callback, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_watcher(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_watcher[] = { + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7watcher_3_format, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventWatcher_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.watcher", /*tp_name*/ + sizeof(struct PyGeventWatcherObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "Abstract base class for all the watchers", /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_watcher, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_watcher, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_io(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventIOObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventIOObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + if (unlikely(__pyx_pw_6gevent_5libev_8corecext_2io_11__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + return o; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + bad: + Py_DECREF(o); o = 0; + return NULL; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_io(PyObject *o) { + struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_6gevent_5libev_8corecext_2io_13__dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_io(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_io)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_io(PyObject *o) { + PyObject* tmp; + struct PyGeventIOObject *p = (struct PyGeventIOObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_io); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_fd(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_2fd_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_fd(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_2fd_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_events(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_6events_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_events(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_6events_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_events_str(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_10events_str_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_2io_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_2io_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_2io_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_2io_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_2io__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_2io_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_io[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_2io_9_format, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_io[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_2io_ref, __pyx_setprop_6gevent_5libev_8corecext_2io_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_2io_callback, __pyx_setprop_6gevent_5libev_8corecext_2io_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_2io_priority, __pyx_setprop_6gevent_5libev_8corecext_2io_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_2io_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_2io_pending, 0, (char *)0, 0}, + {(char *)"fd", __pyx_getprop_6gevent_5libev_8corecext_2io_fd, __pyx_setprop_6gevent_5libev_8corecext_2io_fd, (char *)0, 0}, + {(char *)"events", __pyx_getprop_6gevent_5libev_8corecext_2io_events, __pyx_setprop_6gevent_5libev_8corecext_2io_events, (char *)0, 0}, + {(char *)"events_str", __pyx_getprop_6gevent_5libev_8corecext_2io_events_str, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_2io_loop, __pyx_setprop_6gevent_5libev_8corecext_2io_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_2io_args, __pyx_setprop_6gevent_5libev_8corecext_2io_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_2io__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventIO_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.io", /*tp_name*/ + sizeof(struct PyGeventIOObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_io, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_io, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_io, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_io, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_io, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_2io_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_io, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_timer(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventTimerObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventTimerObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_timer(PyObject *o) { + struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_timer(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_timer)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_timer(PyObject *o) { + PyObject* tmp; + struct PyGeventTimerObject *p = (struct PyGeventTimerObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_timer); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5timer_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5timer_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5timer_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_at(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_2at_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5timer_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5timer_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5timer_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5timer__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5timer_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_timer[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {"again", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5timer_9again, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_timer[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_5timer_ref, __pyx_setprop_6gevent_5libev_8corecext_5timer_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_5timer_callback, __pyx_setprop_6gevent_5libev_8corecext_5timer_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_5timer_priority, __pyx_setprop_6gevent_5libev_8corecext_5timer_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_5timer_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_5timer_pending, 0, (char *)0, 0}, + {(char *)"at", __pyx_getprop_6gevent_5libev_8corecext_5timer_at, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_5timer_loop, __pyx_setprop_6gevent_5libev_8corecext_5timer_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_5timer_args, __pyx_setprop_6gevent_5libev_8corecext_5timer_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_5timer__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventTimer_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.timer", /*tp_name*/ + sizeof(struct PyGeventTimerObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_timer, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_timer, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_timer, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_timer, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_timer, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_5timer_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_timer, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_signal(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventSignalObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventSignalObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_signal(PyObject *o) { + struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_signal(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_signal)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_signal(PyObject *o) { + PyObject* tmp; + struct PyGeventSignalObject *p = (struct PyGeventSignalObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_signal); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_6signal_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_6signal_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_6signal_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_6signal_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_6signal_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_6signal_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_6signal__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_6signal_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_signal[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_6signal_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_6signal_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_6signal_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_signal[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_6signal_ref, __pyx_setprop_6gevent_5libev_8corecext_6signal_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_6signal_callback, __pyx_setprop_6gevent_5libev_8corecext_6signal_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_6signal_priority, __pyx_setprop_6gevent_5libev_8corecext_6signal_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_6signal_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_6signal_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_6signal_loop, __pyx_setprop_6gevent_5libev_8corecext_6signal_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_6signal_args, __pyx_setprop_6gevent_5libev_8corecext_6signal_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_6signal__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventSignal_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.signal", /*tp_name*/ + sizeof(struct PyGeventSignalObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_signal, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_signal, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_signal, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_signal, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_signal, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_6signal_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_signal, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_idle(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventIdleObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventIdleObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_idle(PyObject *o) { + struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_idle(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_idle)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_idle(PyObject *o) { + PyObject* tmp; + struct PyGeventIdleObject *p = (struct PyGeventIdleObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_idle); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4idle_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4idle_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4idle_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4idle_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4idle_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4idle_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4idle__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4idle_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_idle[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4idle_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4idle_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4idle_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_idle[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_4idle_ref, __pyx_setprop_6gevent_5libev_8corecext_4idle_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_4idle_callback, __pyx_setprop_6gevent_5libev_8corecext_4idle_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_4idle_priority, __pyx_setprop_6gevent_5libev_8corecext_4idle_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_4idle_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_4idle_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_4idle_loop, __pyx_setprop_6gevent_5libev_8corecext_4idle_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_4idle_args, __pyx_setprop_6gevent_5libev_8corecext_4idle_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_4idle__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventIdle_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.idle", /*tp_name*/ + sizeof(struct PyGeventIdleObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_idle, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_idle, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_idle, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_idle, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_idle, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_4idle_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_idle, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_prepare(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventPrepareObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventPrepareObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_prepare(PyObject *o) { + struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_prepare(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_prepare)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_prepare(PyObject *o) { + PyObject* tmp; + struct PyGeventPrepareObject *p = (struct PyGeventPrepareObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_prepare); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_7prepare_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_7prepare_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_7prepare_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_7prepare_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_7prepare_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_7prepare__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_7prepare_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_prepare[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7prepare_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7prepare_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7prepare_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_prepare[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_7prepare_ref, __pyx_setprop_6gevent_5libev_8corecext_7prepare_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_7prepare_callback, __pyx_setprop_6gevent_5libev_8corecext_7prepare_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_7prepare_priority, __pyx_setprop_6gevent_5libev_8corecext_7prepare_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_7prepare_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_7prepare_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_7prepare_loop, __pyx_setprop_6gevent_5libev_8corecext_7prepare_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_7prepare_args, __pyx_setprop_6gevent_5libev_8corecext_7prepare_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_7prepare__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventPrepare_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.prepare", /*tp_name*/ + sizeof(struct PyGeventPrepareObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_prepare, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_prepare, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_prepare, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_prepare, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_prepare, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_7prepare_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_prepare, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_check(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventCheckObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventCheckObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_check(PyObject *o) { + struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_check(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_check)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_check(PyObject *o) { + PyObject* tmp; + struct PyGeventCheckObject *p = (struct PyGeventCheckObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_check); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5check_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5check_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5check_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5check_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5check_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5check_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5check_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5check_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5check_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5check_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5check_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5check_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5check__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5check_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_check[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5check_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5check_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5check_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_check[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_5check_ref, __pyx_setprop_6gevent_5libev_8corecext_5check_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_5check_callback, __pyx_setprop_6gevent_5libev_8corecext_5check_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_5check_priority, __pyx_setprop_6gevent_5libev_8corecext_5check_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_5check_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_5check_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_5check_loop, __pyx_setprop_6gevent_5libev_8corecext_5check_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_5check_args, __pyx_setprop_6gevent_5libev_8corecext_5check_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_5check__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventCheck_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.check", /*tp_name*/ + sizeof(struct PyGeventCheckObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_check, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_check, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_check, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_check, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_check, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_5check_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_check, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_fork(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventForkObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventForkObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_fork(PyObject *o) { + struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_fork(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_fork)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_fork(PyObject *o) { + PyObject* tmp; + struct PyGeventForkObject *p = (struct PyGeventForkObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_fork); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4fork_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4fork_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4fork_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4fork_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4fork_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4fork_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4fork__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4fork_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_fork[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4fork_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4fork_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4fork_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_fork[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_4fork_ref, __pyx_setprop_6gevent_5libev_8corecext_4fork_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_4fork_callback, __pyx_setprop_6gevent_5libev_8corecext_4fork_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_4fork_priority, __pyx_setprop_6gevent_5libev_8corecext_4fork_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_4fork_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_4fork_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_4fork_loop, __pyx_setprop_6gevent_5libev_8corecext_4fork_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_4fork_args, __pyx_setprop_6gevent_5libev_8corecext_4fork_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_4fork__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventFork_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.fork", /*tp_name*/ + sizeof(struct PyGeventForkObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_fork, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_fork, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_fork, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_fork, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_fork, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_4fork_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_fork, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_async(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventAsyncObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventAsyncObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_async(PyObject *o) { + struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_async(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_async)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_async(PyObject *o) { + PyObject* tmp; + struct PyGeventAsyncObject *p = (struct PyGeventAsyncObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_async); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5async_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5async_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5async_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5async_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5async_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5async_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5async_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5async_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5async_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5async_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5async_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5async_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5async__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5async_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_async[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5async_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5async_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5async_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {"send", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5async_9send, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_async[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_5async_ref, __pyx_setprop_6gevent_5libev_8corecext_5async_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_5async_callback, __pyx_setprop_6gevent_5libev_8corecext_5async_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_5async_priority, __pyx_setprop_6gevent_5libev_8corecext_5async_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_5async_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_5async_pending, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_5async_loop, __pyx_setprop_6gevent_5libev_8corecext_5async_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_5async_args, __pyx_setprop_6gevent_5libev_8corecext_5async_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_5async__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventAsync_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.async", /*tp_name*/ + sizeof(struct PyGeventAsyncObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_async, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_async, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_async, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_async, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_async, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_5async_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_async, /*tp_new*/ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_child(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventChildObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventChildObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_child(PyObject *o) { + struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_child(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_child)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_child(PyObject *o) { + PyObject* tmp; + struct PyGeventChildObject *p = (struct PyGeventChildObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_child); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_pid(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_3pid_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_rpid(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_rpid(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4rpid_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_rstatus(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_rstatus(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_7rstatus_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5child_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_5child_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_5child_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_5child_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_5child__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_5child_6_flags_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_child[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5child_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5child_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5child_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {"_format", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5child_9_format, METH_NOARGS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_child[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_5child_ref, __pyx_setprop_6gevent_5libev_8corecext_5child_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_5child_callback, __pyx_setprop_6gevent_5libev_8corecext_5child_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_5child_priority, __pyx_setprop_6gevent_5libev_8corecext_5child_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_5child_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_5child_pending, 0, (char *)0, 0}, + {(char *)"pid", __pyx_getprop_6gevent_5libev_8corecext_5child_pid, 0, (char *)0, 0}, + {(char *)"rpid", __pyx_getprop_6gevent_5libev_8corecext_5child_rpid, __pyx_setprop_6gevent_5libev_8corecext_5child_rpid, (char *)0, 0}, + {(char *)"rstatus", __pyx_getprop_6gevent_5libev_8corecext_5child_rstatus, __pyx_setprop_6gevent_5libev_8corecext_5child_rstatus, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_5child_loop, __pyx_setprop_6gevent_5libev_8corecext_5child_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_5child_args, __pyx_setprop_6gevent_5libev_8corecext_5child_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_5child__flags, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventChild_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.child", /*tp_name*/ + sizeof(struct PyGeventChildObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_child, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_child, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_child, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_child, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_child, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_5child_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_child, /*tp_new*/ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext_stat(PyTypeObject *t, PyObject *a, PyObject *k) { + struct PyGeventStatObject *p; + PyObject *o = __pyx_tp_new_6gevent_5libev_8corecext_watcher(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct PyGeventStatObject *)o); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + p->_callback = Py_None; Py_INCREF(Py_None); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->path = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_paths = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext_stat(PyObject *o) { + struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->loop); + Py_CLEAR(p->_callback); + Py_CLEAR(p->args); + Py_CLEAR(p->path); + Py_CLEAR(p->_paths); + #if CYTHON_USE_TYPE_SLOTS + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6gevent_5libev_8corecext_watcher(o); +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext_stat(PyObject *o, visitproc v, void *a) { + int e; + struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; + e = ((likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) ? ((__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse) ? __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6gevent_5libev_8corecext_stat)); if (e) return e; + if (p->loop) { + e = (*v)(((PyObject*)p->loop), a); if (e) return e; + } + if (p->_callback) { + e = (*v)(p->_callback, a); if (e) return e; + } + if (p->args) { + e = (*v)(p->args, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext_stat(PyObject *o) { + PyObject* tmp; + struct PyGeventStatObject *p = (struct PyGeventStatObject *)o; + if (likely(__pyx_ptype_6gevent_5libev_8corecext_watcher)) { if (__pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear) __pyx_ptype_6gevent_5libev_8corecext_watcher->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6gevent_5libev_8corecext_stat); + tmp = ((PyObject*)p->loop); + p->loop = ((struct PyGeventLoopObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_callback); + p->_callback = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->args); + p->args = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_ref(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4stat_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_3ref_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_callback(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_8callback_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4stat_callback(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_8callback_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_priority(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_8priority_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4stat_priority(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_8priority_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_active(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_6active_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_pending(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_7pending_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_attr(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4attr_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_prev(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4prev_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_interval(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_8interval_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_loop(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4stat_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4loop_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_args(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4args_1__get__(o); +} + +static int __pyx_setprop_6gevent_5libev_8corecext_4stat_args(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4args_3__set__(o, v); + } + else { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4args_5__del__(o); + } +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat__flags(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_6_flags_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat_path(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_4path_1__get__(o); +} + +static PyObject *__pyx_getprop_6gevent_5libev_8corecext_4stat__paths(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6gevent_5libev_8corecext_4stat_6_paths_1__get__(o); +} + +static PyMethodDef __pyx_methods_6gevent_5libev_8corecext_stat[] = { + {"stop", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4stat_1stop, METH_NOARGS, 0}, + {"feed", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4stat_3feed, METH_VARARGS|METH_KEYWORDS, 0}, + {"start", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_4stat_5start, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6gevent_5libev_8corecext_stat[] = { + {(char *)"ref", __pyx_getprop_6gevent_5libev_8corecext_4stat_ref, __pyx_setprop_6gevent_5libev_8corecext_4stat_ref, (char *)0, 0}, + {(char *)"callback", __pyx_getprop_6gevent_5libev_8corecext_4stat_callback, __pyx_setprop_6gevent_5libev_8corecext_4stat_callback, (char *)0, 0}, + {(char *)"priority", __pyx_getprop_6gevent_5libev_8corecext_4stat_priority, __pyx_setprop_6gevent_5libev_8corecext_4stat_priority, (char *)0, 0}, + {(char *)"active", __pyx_getprop_6gevent_5libev_8corecext_4stat_active, 0, (char *)0, 0}, + {(char *)"pending", __pyx_getprop_6gevent_5libev_8corecext_4stat_pending, 0, (char *)0, 0}, + {(char *)"attr", __pyx_getprop_6gevent_5libev_8corecext_4stat_attr, 0, (char *)0, 0}, + {(char *)"prev", __pyx_getprop_6gevent_5libev_8corecext_4stat_prev, 0, (char *)0, 0}, + {(char *)"interval", __pyx_getprop_6gevent_5libev_8corecext_4stat_interval, 0, (char *)0, 0}, + {(char *)"loop", __pyx_getprop_6gevent_5libev_8corecext_4stat_loop, __pyx_setprop_6gevent_5libev_8corecext_4stat_loop, (char *)0, 0}, + {(char *)"args", __pyx_getprop_6gevent_5libev_8corecext_4stat_args, __pyx_setprop_6gevent_5libev_8corecext_4stat_args, (char *)0, 0}, + {(char *)"_flags", __pyx_getprop_6gevent_5libev_8corecext_4stat__flags, 0, (char *)0, 0}, + {(char *)"path", __pyx_getprop_6gevent_5libev_8corecext_4stat_path, 0, (char *)0, 0}, + {(char *)"_paths", __pyx_getprop_6gevent_5libev_8corecext_4stat__paths, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) PyGeventStat_Type = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.stat", /*tp_name*/ + sizeof(struct PyGeventStatObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext_stat, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6gevent_5libev_8corecext_7watcher_1__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext_stat, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext_stat, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6gevent_5libev_8corecext_stat, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6gevent_5libev_8corecext_stat, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_6gevent_5libev_8corecext_4stat_7__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext_stat, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *__pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[8]; +static int __pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = 0; + +static PyObject *__pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr)))) { + o = (PyObject*)__pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[--__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr]; + memset(o, 0, sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyObject *o) { + struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_flag); + Py_CLEAR(p->__pyx_v_string); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr)))) { + __pyx_freelist_6gevent_5libev_8corecext___pyx_scope_struct__genexpr[__pyx_freecount_6gevent_5libev_8corecext___pyx_scope_struct__genexpr++] = ((struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o; + if (p->__pyx_v_flag) { + e = (*v)(p->__pyx_v_flag, a); if (e) return e; + } + if (p->__pyx_v_string) { + e = (*v)(p->__pyx_v_string, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6gevent_5libev_8corecext___pyx_scope_struct__genexpr(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *p = (struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr *)o; + tmp = ((PyObject*)p->__pyx_v_flag); + p->__pyx_v_flag = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_string); + p->__pyx_v_string = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyTypeObject __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = { + PyVarObject_HEAD_INIT(0, 0) + "gevent.libev.corecext.__pyx_scope_struct__genexpr", /*tp_name*/ + sizeof(struct __pyx_obj_6gevent_5libev_8corecext___pyx_scope_struct__genexpr), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_traverse*/ + __pyx_tp_clear_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6gevent_5libev_8corecext___pyx_scope_struct__genexpr, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {"_flags_to_list", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_5_flags_to_list, METH_O, 0}, + {"_flags_to_int", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_7_flags_to_int, METH_O, 0}, + {"_check_flags", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_9_check_flags, METH_O, 0}, + {"_events_to_str", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_11_events_to_str, METH_O, 0}, + {"set_syserr_cb", (PyCFunction)__pyx_pw_6gevent_5libev_8corecext_21set_syserr_cb, METH_O, 0}, + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "corecext", + 0, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0}, + {&__pyx_n_s_ASYNC, __pyx_k_ASYNC, sizeof(__pyx_k_ASYNC), 0, 0, 1, 1}, + {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, + {&__pyx_n_s_BACKEND_EPOLL, __pyx_k_BACKEND_EPOLL, sizeof(__pyx_k_BACKEND_EPOLL), 0, 0, 1, 1}, + {&__pyx_n_s_BACKEND_KQUEUE, __pyx_k_BACKEND_KQUEUE, sizeof(__pyx_k_BACKEND_KQUEUE), 0, 0, 1, 1}, + {&__pyx_n_s_BACKEND_POLL, __pyx_k_BACKEND_POLL, sizeof(__pyx_k_BACKEND_POLL), 0, 0, 1, 1}, + {&__pyx_n_s_BACKEND_PORT, __pyx_k_BACKEND_PORT, sizeof(__pyx_k_BACKEND_PORT), 0, 0, 1, 1}, + {&__pyx_n_s_BACKEND_SELECT, __pyx_k_BACKEND_SELECT, sizeof(__pyx_k_BACKEND_SELECT), 0, 0, 1, 1}, + {&__pyx_n_s_CHECK, __pyx_k_CHECK, sizeof(__pyx_k_CHECK), 0, 0, 1, 1}, + {&__pyx_n_s_CHILD, __pyx_k_CHILD, sizeof(__pyx_k_CHILD), 0, 0, 1, 1}, + {&__pyx_n_s_CLEANUP, __pyx_k_CLEANUP, sizeof(__pyx_k_CLEANUP), 0, 0, 1, 1}, + {&__pyx_n_s_CUSTOM, __pyx_k_CUSTOM, sizeof(__pyx_k_CUSTOM), 0, 0, 1, 1}, + {&__pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_k_C_Users_appveyor_AppData_Local_T, sizeof(__pyx_k_C_Users_appveyor_AppData_Local_T), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_set_priority_of_an_active, __pyx_k_Cannot_set_priority_of_an_active, sizeof(__pyx_k_Cannot_set_priority_of_an_active), 0, 0, 1, 0}, + {&__pyx_n_s_EMBED, __pyx_k_EMBED, sizeof(__pyx_k_EMBED), 0, 0, 1, 1}, + {&__pyx_n_s_ERROR, __pyx_k_ERROR, sizeof(__pyx_k_ERROR), 0, 0, 1, 1}, + {&__pyx_n_s_EVENTS, __pyx_k_EVENTS, sizeof(__pyx_k_EVENTS), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_EV_USE_4HEAP, __pyx_k_EV_USE_4HEAP, sizeof(__pyx_k_EV_USE_4HEAP), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_k_EV_USE_CLOCK_SYSCALL, sizeof(__pyx_k_EV_USE_CLOCK_SYSCALL), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_EVENTFD, __pyx_k_EV_USE_EVENTFD, sizeof(__pyx_k_EV_USE_EVENTFD), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_FLOOR, __pyx_k_EV_USE_FLOOR, sizeof(__pyx_k_EV_USE_FLOOR), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_INOTIFY, __pyx_k_EV_USE_INOTIFY, sizeof(__pyx_k_EV_USE_INOTIFY), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_MONOTONIC, __pyx_k_EV_USE_MONOTONIC, sizeof(__pyx_k_EV_USE_MONOTONIC), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_NANOSLEEP, __pyx_k_EV_USE_NANOSLEEP, sizeof(__pyx_k_EV_USE_NANOSLEEP), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_REALTIME, __pyx_k_EV_USE_REALTIME, sizeof(__pyx_k_EV_USE_REALTIME), 0, 0, 1, 1}, + {&__pyx_n_s_EV_USE_SIGNALFD, __pyx_k_EV_USE_SIGNALFD, sizeof(__pyx_k_EV_USE_SIGNALFD), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_Expected_callable_not_r, __pyx_k_Expected_callable_not_r, sizeof(__pyx_k_Expected_callable_not_r), 0, 0, 1, 0}, + {&__pyx_kp_s_Expected_callable_or_None_got_r, __pyx_k_Expected_callable_or_None_got_r, sizeof(__pyx_k_Expected_callable_or_None_got_r), 0, 0, 1, 0}, + {&__pyx_n_s_FORK, __pyx_k_FORK, sizeof(__pyx_k_FORK), 0, 0, 1, 1}, + {&__pyx_n_s_FORKCHECK, __pyx_k_FORKCHECK, sizeof(__pyx_k_FORKCHECK), 0, 0, 1, 1}, + {&__pyx_n_s_IDLE, __pyx_k_IDLE, sizeof(__pyx_k_IDLE), 0, 0, 1, 1}, + {&__pyx_n_s_IOFDSET, __pyx_k_IOFDSET, sizeof(__pyx_k_IOFDSET), 0, 0, 1, 1}, + {&__pyx_kp_s_Invalid_backend_or_flag_s_Possib, __pyx_k_Invalid_backend_or_flag_s_Possib, sizeof(__pyx_k_Invalid_backend_or_flag_s_Possib), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_value_for_backend_0x_x, __pyx_k_Invalid_value_for_backend_0x_x, sizeof(__pyx_k_Invalid_value_for_backend_0x_x), 0, 0, 1, 0}, + {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, + {&__pyx_n_s_LIBEV_EMBED, __pyx_k_LIBEV_EMBED, sizeof(__pyx_k_LIBEV_EMBED), 0, 0, 1, 1}, + {&__pyx_n_s_MAXPRI, __pyx_k_MAXPRI, sizeof(__pyx_k_MAXPRI), 0, 0, 1, 1}, + {&__pyx_n_s_MINPRI, __pyx_k_MINPRI, sizeof(__pyx_k_MINPRI), 0, 0, 1, 1}, + {&__pyx_n_s_NOINOTIFY, __pyx_k_NOINOTIFY, sizeof(__pyx_k_NOINOTIFY), 0, 0, 1, 1}, + {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1}, + {&__pyx_n_s_NOSIGMASK, __pyx_k_NOSIGMASK, sizeof(__pyx_k_NOSIGMASK), 0, 0, 1, 1}, + {&__pyx_n_s_NSIG, __pyx_k_NSIG, sizeof(__pyx_k_NSIG), 0, 0, 1, 1}, + {&__pyx_n_s_PERIODIC, __pyx_k_PERIODIC, sizeof(__pyx_k_PERIODIC), 0, 0, 1, 1}, + {&__pyx_n_s_PREPARE, __pyx_k_PREPARE, sizeof(__pyx_k_PREPARE), 0, 0, 1, 1}, + {&__pyx_n_s_READ, __pyx_k_READ, sizeof(__pyx_k_READ), 0, 0, 1, 1}, + {&__pyx_n_s_READWRITE, __pyx_k_READWRITE, sizeof(__pyx_k_READWRITE), 0, 0, 1, 1}, + {&__pyx_n_s_SIGNAL, __pyx_k_SIGNAL, sizeof(__pyx_k_SIGNAL), 0, 0, 1, 1}, + {&__pyx_n_s_SIGNALFD, __pyx_k_SIGNALFD, sizeof(__pyx_k_SIGNALFD), 0, 0, 1, 1}, + {&__pyx_n_s_STAT, __pyx_k_STAT, sizeof(__pyx_k_STAT), 0, 0, 1, 1}, + {&__pyx_n_s_SYSERR_CALLBACK, __pyx_k_SYSERR_CALLBACK, sizeof(__pyx_k_SYSERR_CALLBACK), 0, 0, 1, 1}, + {&__pyx_n_s_SystemError, __pyx_k_SystemError, sizeof(__pyx_k_SystemError), 0, 0, 1, 1}, + {&__pyx_n_s_TIMER, __pyx_k_TIMER, sizeof(__pyx_k_TIMER), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_n_s_UNDEF, __pyx_k_UNDEF, sizeof(__pyx_k_UNDEF), 0, 0, 1, 1}, + {&__pyx_kp_s_Unsupported_backend_s, __pyx_k_Unsupported_backend_s, sizeof(__pyx_k_Unsupported_backend_s), 0, 0, 1, 0}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_WRITE, __pyx_k_WRITE, sizeof(__pyx_k_WRITE), 0, 0, 1, 1}, + {&__pyx_kp_s__21, __pyx_k__21, sizeof(__pyx_k__21), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + {&__pyx_kp_s__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 0, 1, 0}, + {&__pyx_kp_s__23, __pyx_k__23, sizeof(__pyx_k__23), 0, 0, 1, 0}, +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s__26, __pyx_k__26, sizeof(__pyx_k__26), 0, 0, 1, 0}, +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s__27, __pyx_k__27, sizeof(__pyx_k__27), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + {&__pyx_kp_s__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0}, + {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0}, + {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0}, + {&__pyx_n_s_active, __pyx_k_active, sizeof(__pyx_k_active), 0, 0, 1, 1}, + {&__pyx_kp_s_active_2, __pyx_k_active_2, sizeof(__pyx_k_active_2), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_activecnt, __pyx_k_activecnt, sizeof(__pyx_k_activecnt), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_after, __pyx_k_after, sizeof(__pyx_k_after), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, + {&__pyx_kp_s_args_r, __pyx_k_args_r, sizeof(__pyx_k_args_r), 0, 0, 1, 0}, + {&__pyx_n_s_backend, __pyx_k_backend, sizeof(__pyx_k_backend), 0, 0, 1, 1}, + {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1}, + {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1}, + {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1}, + {&__pyx_kp_s_callback_must_be_callable_not_No, __pyx_k_callback_must_be_callable_not_No, sizeof(__pyx_k_callback_must_be_callable_not_No), 0, 0, 1, 0}, + {&__pyx_kp_s_callback_r, __pyx_k_callback_r, sizeof(__pyx_k_callback_r), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_child_watchers_are_only_availabl, __pyx_k_child_watchers_are_only_availabl, sizeof(__pyx_k_child_watchers_are_only_availabl), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, + {&__pyx_n_s_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 0, 1, 1}, + {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, + {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1}, + {&__pyx_kp_s_default_2, __pyx_k_default_2, sizeof(__pyx_k_default_2), 0, 0, 1, 0}, + {&__pyx_n_s_default_handle_error, __pyx_k_default_handle_error, sizeof(__pyx_k_default_handle_error), 0, 0, 1, 1}, + {&__pyx_n_s_destroyed, __pyx_k_destroyed, sizeof(__pyx_k_destroyed), 0, 0, 1, 1}, + {&__pyx_n_s_embeddable_backends, __pyx_k_embeddable_backends, sizeof(__pyx_k_embeddable_backends), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_epoll, __pyx_k_epoll, sizeof(__pyx_k_epoll), 0, 0, 1, 1}, + {&__pyx_n_s_errno, __pyx_k_errno, sizeof(__pyx_k_errno), 0, 0, 1, 1}, + {&__pyx_kp_s_ev_default_loop_s_failed, __pyx_k_ev_default_loop_s_failed, sizeof(__pyx_k_ev_default_loop_s_failed), 0, 0, 1, 0}, + {&__pyx_kp_s_ev_loop_new_s_failed, __pyx_k_ev_loop_new_s_failed, sizeof(__pyx_k_ev_loop_new_s_failed), 0, 0, 1, 0}, + {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1}, + {&__pyx_n_s_events_2, __pyx_k_events_2, sizeof(__pyx_k_events_2), 0, 0, 1, 1}, + {&__pyx_n_s_events_str, __pyx_k_events_str, sizeof(__pyx_k_events_str), 0, 0, 1, 1}, + {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_fd_must_be_non_negative_r, __pyx_k_fd_must_be_non_negative_r, sizeof(__pyx_k_fd_must_be_non_negative_r), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_fd_s_events_s, __pyx_k_fd_s_events_s, sizeof(__pyx_k_fd_s_events_s), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1}, + {&__pyx_kp_s_fileno_2, __pyx_k_fileno_2, sizeof(__pyx_k_fileno_2), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_flags_2, __pyx_k_flags_2, sizeof(__pyx_k_flags_2), 0, 0, 1, 1}, + {&__pyx_n_s_flags_str2int, __pyx_k_flags_str2int, sizeof(__pyx_k_flags_str2int), 0, 0, 1, 1}, + {&__pyx_n_s_forkcheck, __pyx_k_forkcheck, sizeof(__pyx_k_forkcheck), 0, 0, 1, 1}, + {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_format_details, __pyx_k_format_details, sizeof(__pyx_k_format_details), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1}, + {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1}, + {&__pyx_n_s_get_header_version, __pyx_k_get_header_version, sizeof(__pyx_k_get_header_version), 0, 0, 1, 1}, + {&__pyx_n_s_get_version, __pyx_k_get_version, sizeof(__pyx_k_get_version), 0, 0, 1, 1}, + {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1}, + {&__pyx_kp_s_gevent_core_EVENTS, __pyx_k_gevent_core_EVENTS, sizeof(__pyx_k_gevent_core_EVENTS), 0, 0, 1, 0}, + {&__pyx_n_s_gevent_libev_corecext, __pyx_k_gevent_libev_corecext, sizeof(__pyx_k_gevent_libev_corecext), 0, 0, 1, 1}, + {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1}, + {&__pyx_n_s_handle_syserr, __pyx_k_handle_syserr, sizeof(__pyx_k_handle_syserr), 0, 0, 1, 1}, + {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1}, + {&__pyx_n_s_how, __pyx_k_how, sizeof(__pyx_k_how), 0, 0, 1, 1}, + {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, + {&__pyx_kp_s_illegal_event_mask_r, __pyx_k_illegal_event_mask_r, sizeof(__pyx_k_illegal_event_mask_r), 0, 0, 1, 0}, + {&__pyx_kp_s_illegal_signal_number_r, __pyx_k_illegal_signal_number_r, sizeof(__pyx_k_illegal_signal_number_r), 0, 0, 1, 0}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 0, 1, 1}, + {&__pyx_kp_s_io_watcher_attribute_events_is, __pyx_k_io_watcher_attribute_events_is, sizeof(__pyx_k_io_watcher_attribute_events_is), 0, 0, 1, 0}, + {&__pyx_kp_s_io_watcher_attribute_fd_is_read, __pyx_k_io_watcher_attribute_fd_is_read, sizeof(__pyx_k_io_watcher_attribute_fd_is_read), 0, 0, 1, 0}, + {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1}, + {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, + {&__pyx_n_s_kqueue, __pyx_k_kqueue, sizeof(__pyx_k_kqueue), 0, 0, 1, 1}, + {&__pyx_n_s_level, __pyx_k_level, sizeof(__pyx_k_level), 0, 0, 1, 1}, + {&__pyx_kp_s_libev_d_02d, __pyx_k_libev_d_02d, sizeof(__pyx_k_libev_d_02d), 0, 0, 1, 0}, + {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1}, + {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_noenv, __pyx_k_noenv, sizeof(__pyx_k_noenv), 0, 0, 1, 1}, + {&__pyx_n_s_noinotify, __pyx_k_noinotify, sizeof(__pyx_k_noinotify), 0, 0, 1, 1}, + {&__pyx_n_s_nosigmask, __pyx_k_nosigmask, sizeof(__pyx_k_nosigmask), 0, 0, 1, 1}, + {&__pyx_n_s_nowait, __pyx_k_nowait, sizeof(__pyx_k_nowait), 0, 0, 1, 1}, + {&__pyx_n_s_once, __pyx_k_once, sizeof(__pyx_k_once), 0, 0, 1, 1}, + {&__pyx_kp_s_operation_on_destroyed_loop, __pyx_k_operation_on_destroyed_loop, sizeof(__pyx_k_operation_on_destroyed_loop), 0, 0, 1, 0}, + {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, + {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1}, + {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1}, + {&__pyx_n_s_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 0, 0, 1, 1}, + {&__pyx_kp_s_pending_2, __pyx_k_pending_2, sizeof(__pyx_k_pending_2), 0, 0, 1, 0}, + {&__pyx_kp_s_pending_s, __pyx_k_pending_s, sizeof(__pyx_k_pending_s), 0, 0, 1, 0}, + {&__pyx_n_s_pendingcnt, __pyx_k_pendingcnt, sizeof(__pyx_k_pendingcnt), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1}, + {&__pyx_kp_s_pid_r_rstatus_r, __pyx_k_pid_r_rstatus_r, sizeof(__pyx_k_pid_r_rstatus_r), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_poll, __pyx_k_poll, sizeof(__pyx_k_poll), 0, 0, 1, 1}, + {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1}, + {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1}, + {&__pyx_n_s_print_exception, __pyx_k_print_exception, sizeof(__pyx_k_print_exception), 0, 0, 1, 1}, + {&__pyx_n_s_priority, __pyx_k_priority, sizeof(__pyx_k_priority), 0, 0, 1, 1}, + {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_recommended_backends, __pyx_k_recommended_backends, sizeof(__pyx_k_recommended_backends), 0, 0, 1, 1}, + {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_ref_2, __pyx_k_ref_2, sizeof(__pyx_k_ref_2), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1}, + {&__pyx_kp_s_repeat_must_be_positive_or_zero, __pyx_k_repeat_must_be_positive_or_zero, sizeof(__pyx_k_repeat_must_be_positive_or_zero), 0, 0, 1, 0}, + {&__pyx_n_s_revents, __pyx_k_revents, sizeof(__pyx_k_revents), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_rstatus, __pyx_k_rstatus, sizeof(__pyx_k_rstatus), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_kp_s_s_at_0x_x_s, __pyx_k_s_at_0x_x_s, sizeof(__pyx_k_s_at_0x_x_s), 0, 0, 1, 0}, + {&__pyx_kp_s_s_at_0x_x_s_2, __pyx_k_s_at_0x_x_s_2, sizeof(__pyx_k_s_at_0x_x_s_2), 0, 0, 1, 0}, + {&__pyx_n_s_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 1, 1}, + {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_sigfd, __pyx_k_sigfd, sizeof(__pyx_k_sigfd), 0, 0, 1, 1}, + {&__pyx_kp_s_sigfd_2, __pyx_k_sigfd_2, sizeof(__pyx_k_sigfd_2), 0, 0, 1, 0}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_signal, __pyx_k_signal, sizeof(__pyx_k_signal), 0, 0, 1, 1}, + {&__pyx_n_s_signalfd, __pyx_k_signalfd, sizeof(__pyx_k_signalfd), 0, 0, 1, 1}, + {&__pyx_n_s_signalmodule, __pyx_k_signalmodule, sizeof(__pyx_k_signalmodule), 0, 0, 1, 1}, + {&__pyx_n_s_signalnum, __pyx_k_signalnum, sizeof(__pyx_k_signalnum), 0, 0, 1, 1}, + {&__pyx_n_s_signum, __pyx_k_signum, sizeof(__pyx_k_signum), 0, 0, 1, 1}, + {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, + {&__pyx_n_s_stop_watchers, __pyx_k_stop_watchers, sizeof(__pyx_k_stop_watchers), 0, 0, 1, 1}, + {&__pyx_kp_s_stopped, __pyx_k_stopped, sizeof(__pyx_k_stopped), 0, 0, 1, 0}, + {&__pyx_n_s_strerror, __pyx_k_strerror, sizeof(__pyx_k_strerror), 0, 0, 1, 1}, + {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1}, + {&__pyx_n_s_supported_backends, __pyx_k_supported_backends, sizeof(__pyx_k_supported_backends), 0, 0, 1, 1}, + {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, + {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, + {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_trace, __pyx_k_trace, sizeof(__pyx_k_trace), 0, 0, 1, 1}, +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1}, + {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, + {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, + {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin___import__ = __Pyx_GetBuiltinName(__pyx_n_s_import); if (!__pyx_builtin___import__) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 183, __pyx_L1_error) + __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 189, __pyx_L1_error) + __pyx_builtin_SystemError = __Pyx_GetBuiltinName(__pyx_n_s_SystemError); if (!__pyx_builtin_SystemError) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 431, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 561, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 759, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 381, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 397, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 403, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 409, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 415, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 421, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 438, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 446, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 454, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 462, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + + __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 470, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); + + __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 482, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); + + __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 534, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 587, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + + __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 595, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 604, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 613, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 613, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 621, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__25); + __Pyx_GIVEREF(__pyx_tuple__25); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 621, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 789, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__27); + __Pyx_GIVEREF(__pyx_tuple__27); + + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 737, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 765, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 783, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 789, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 789, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 803, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 805, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__34); + __Pyx_GIVEREF(__pyx_tuple__34); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_fd_is_read); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 871, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__35); + __Pyx_GIVEREF(__pyx_tuple__35); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_io_watcher_attribute_events_is); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 883, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__36); + __Pyx_GIVEREF(__pyx_tuple__36); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 922, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 950, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__38); + __Pyx_GIVEREF(__pyx_tuple__38); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 968, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 974, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__40); + __Pyx_GIVEREF(__pyx_tuple__40); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 988, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__41); + __Pyx_GIVEREF(__pyx_tuple__41); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 990, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__42); + __Pyx_GIVEREF(__pyx_tuple__42); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1036, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__43); + __Pyx_GIVEREF(__pyx_tuple__43); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1067, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__44); + __Pyx_GIVEREF(__pyx_tuple__44); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1095, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__45); + __Pyx_GIVEREF(__pyx_tuple__45); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 1113, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__46); + __Pyx_GIVEREF(__pyx_tuple__46); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1119, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__47); + __Pyx_GIVEREF(__pyx_tuple__47); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 1133, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__48); + __Pyx_GIVEREF(__pyx_tuple__48); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1135, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__49); + __Pyx_GIVEREF(__pyx_tuple__49); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1192, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__50); + __Pyx_GIVEREF(__pyx_tuple__50); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 1220, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__51); + __Pyx_GIVEREF(__pyx_tuple__51); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1238, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__52); + __Pyx_GIVEREF(__pyx_tuple__52); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1244, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__53); + __Pyx_GIVEREF(__pyx_tuple__53); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1258, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__54); + __Pyx_GIVEREF(__pyx_tuple__54); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1260, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__55); + __Pyx_GIVEREF(__pyx_tuple__55); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 1311, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__56); + __Pyx_GIVEREF(__pyx_tuple__56); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1339, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__57); + __Pyx_GIVEREF(__pyx_tuple__57); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 1357, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__58); + __Pyx_GIVEREF(__pyx_tuple__58); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1363, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__59); + __Pyx_GIVEREF(__pyx_tuple__59); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 1377, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__60); + __Pyx_GIVEREF(__pyx_tuple__60); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 1379, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__61); + __Pyx_GIVEREF(__pyx_tuple__61); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1430, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__62); + __Pyx_GIVEREF(__pyx_tuple__62); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 1458, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__63); + __Pyx_GIVEREF(__pyx_tuple__63); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 1476, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__64); + __Pyx_GIVEREF(__pyx_tuple__64); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1482, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__65); + __Pyx_GIVEREF(__pyx_tuple__65); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 1496, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__66); + __Pyx_GIVEREF(__pyx_tuple__66); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1498, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__67); + __Pyx_GIVEREF(__pyx_tuple__67); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 1549, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__68); + __Pyx_GIVEREF(__pyx_tuple__68); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1577, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__69); + __Pyx_GIVEREF(__pyx_tuple__69); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 1595, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__70); + __Pyx_GIVEREF(__pyx_tuple__70); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1601, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__71); + __Pyx_GIVEREF(__pyx_tuple__71); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 1615, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__72); + __Pyx_GIVEREF(__pyx_tuple__72); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1617, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__73); + __Pyx_GIVEREF(__pyx_tuple__73); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 1668, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__74); + __Pyx_GIVEREF(__pyx_tuple__74); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1696, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__75); + __Pyx_GIVEREF(__pyx_tuple__75); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1714, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__76); + __Pyx_GIVEREF(__pyx_tuple__76); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1720, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__77); + __Pyx_GIVEREF(__pyx_tuple__77); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 1734, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__78); + __Pyx_GIVEREF(__pyx_tuple__78); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1736, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__79); + __Pyx_GIVEREF(__pyx_tuple__79); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1771, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__80); + __Pyx_GIVEREF(__pyx_tuple__80); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1794, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__81); + __Pyx_GIVEREF(__pyx_tuple__81); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1822, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__82); + __Pyx_GIVEREF(__pyx_tuple__82); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1840, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__83); + __Pyx_GIVEREF(__pyx_tuple__83); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1846, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__84); + __Pyx_GIVEREF(__pyx_tuple__84); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 1860, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__85); + __Pyx_GIVEREF(__pyx_tuple__85); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 1862, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__86 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__86); + __Pyx_GIVEREF(__pyx_tuple__86); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_child_watchers_are_only_availabl); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 1886, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__87); + __Pyx_GIVEREF(__pyx_tuple__87); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 1939, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__88 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__88); + __Pyx_GIVEREF(__pyx_tuple__88); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 1967, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__89); + __Pyx_GIVEREF(__pyx_tuple__89); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_priority_of_an_active); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 1985, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__90); + __Pyx_GIVEREF(__pyx_tuple__90); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 1991, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__91 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__91); + __Pyx_GIVEREF(__pyx_tuple__91); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_operation_on_destroyed_loop); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 2005, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__92 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__92); + __Pyx_GIVEREF(__pyx_tuple__92); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_s_callback_must_be_callable_not_No); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(0, 2007, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__89 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__89)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__93 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__93); + __Pyx_GIVEREF(__pyx_tuple__93); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_sys); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__94); + __Pyx_GIVEREF(__pyx_tuple__94); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__95 = PyTuple_Pack(1, __pyx_n_s_os); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__95 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__95); + __Pyx_GIVEREF(__pyx_tuple__95); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__96 = PyTuple_Pack(1, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__96 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_tuple__96); + __Pyx_GIVEREF(__pyx_tuple__96); + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_tuple__97 = PyTuple_Pack(1, __pyx_n_s_signal); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 19, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__97); + __Pyx_GIVEREF(__pyx_tuple__97); + + __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_version, 107, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 107, __pyx_L1_error) + + __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_get_header_version, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 111, __pyx_L1_error) + + __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_supported_backends, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 220, __pyx_L1_error) + + __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_recommended_backends, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(0, 224, __pyx_L1_error) + + __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_embeddable_backends, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 228, __pyx_L1_error) + + __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Users_appveyor_AppData_Local_T, __pyx_n_s_time, 232, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(0, 232, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initcorecext(void); /*proto*/ +PyMODINIT_FUNC initcorecext(void) +#else +PyMODINIT_FUNC PyInit_corecext(void); /*proto*/ +PyMODINIT_FUNC PyInit_corecext(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_corecext(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("corecext", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_gevent__libev__corecext) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "gevent.libev.corecext")) { + if (unlikely(PyDict_SetItemString(modules, "gevent.libev.corecext", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + __pyx_v_6gevent_5libev_8corecext_integer_types = ((PyObject*)Py_None); Py_INCREF(Py_None); + GEVENT_CORE_EVENTS = Py_None; Py_INCREF(Py_None); + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + if (PyType_Ready(&__pyx_type_6gevent_5libev_8corecext__EVENTSType) < 0) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_type_6gevent_5libev_8corecext__EVENTSType.tp_print = 0; + __pyx_ptype_6gevent_5libev_8corecext__EVENTSType = &__pyx_type_6gevent_5libev_8corecext__EVENTSType; + __pyx_vtabptr_6gevent_5libev_8corecext_loop = &__pyx_vtable_6gevent_5libev_8corecext_loop; + __pyx_vtable_6gevent_5libev_8corecext_loop._run_callbacks = (PyObject *(*)(struct PyGeventLoopObject *))__pyx_f_6gevent_5libev_8corecext_4loop__run_callbacks; + __pyx_vtable_6gevent_5libev_8corecext_loop.handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop_handle_error; + __pyx_vtable_6gevent_5libev_8corecext_loop._default_handle_error = (PyObject *(*)(struct PyGeventLoopObject *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6gevent_5libev_8corecext_4loop__default_handle_error; + if (PyType_Ready(&PyGeventLoop_Type) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + PyGeventLoop_Type.tp_print = 0; + if (__Pyx_SetVtable(PyGeventLoop_Type.tp_dict, __pyx_vtabptr_6gevent_5libev_8corecext_loop) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "loop", (PyObject *)&PyGeventLoop_Type) < 0) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_loop = &PyGeventLoop_Type; + if (PyType_Ready(&PyGeventCallback_Type) < 0) __PYX_ERR(0, 627, __pyx_L1_error) + PyGeventCallback_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "callback", (PyObject *)&PyGeventCallback_Type) < 0) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_callback = &PyGeventCallback_Type; + if (PyType_Ready(&PyGeventWatcher_Type) < 0) __PYX_ERR(0, 695, __pyx_L1_error) + PyGeventWatcher_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "watcher", (PyObject *)&PyGeventWatcher_Type) < 0) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_watcher = &PyGeventWatcher_Type; + PyGeventIO_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventIO_Type) < 0) __PYX_ERR(0, 720, __pyx_L1_error) + PyGeventIO_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "io", (PyObject *)&PyGeventIO_Type) < 0) __PYX_ERR(0, 720, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_io = &PyGeventIO_Type; + PyGeventTimer_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventTimer_Type) < 0) __PYX_ERR(0, 905, __pyx_L1_error) + PyGeventTimer_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "timer", (PyObject *)&PyGeventTimer_Type) < 0) __PYX_ERR(0, 905, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_timer = &PyGeventTimer_Type; + PyGeventSignal_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventSignal_Type) < 0) __PYX_ERR(0, 1050, __pyx_L1_error) + PyGeventSignal_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "signal", (PyObject *)&PyGeventSignal_Type) < 0) __PYX_ERR(0, 1050, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_signal = &PyGeventSignal_Type; + PyGeventIdle_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventIdle_Type) < 0) __PYX_ERR(0, 1175, __pyx_L1_error) + PyGeventIdle_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "idle", (PyObject *)&PyGeventIdle_Type) < 0) __PYX_ERR(0, 1175, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_idle = &PyGeventIdle_Type; + PyGeventPrepare_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventPrepare_Type) < 0) __PYX_ERR(0, 1294, __pyx_L1_error) + PyGeventPrepare_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "prepare", (PyObject *)&PyGeventPrepare_Type) < 0) __PYX_ERR(0, 1294, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_prepare = &PyGeventPrepare_Type; + PyGeventCheck_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventCheck_Type) < 0) __PYX_ERR(0, 1413, __pyx_L1_error) + PyGeventCheck_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "check", (PyObject *)&PyGeventCheck_Type) < 0) __PYX_ERR(0, 1413, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_check = &PyGeventCheck_Type; + PyGeventFork_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventFork_Type) < 0) __PYX_ERR(0, 1532, __pyx_L1_error) + PyGeventFork_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "fork", (PyObject *)&PyGeventFork_Type) < 0) __PYX_ERR(0, 1532, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_fork = &PyGeventFork_Type; + PyGeventAsync_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventAsync_Type) < 0) __PYX_ERR(0, 1651, __pyx_L1_error) + PyGeventAsync_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "async", (PyObject *)&PyGeventAsync_Type) < 0) __PYX_ERR(0, 1651, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_async = &PyGeventAsync_Type; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyGeventChild_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventChild_Type) < 0) __PYX_ERR(0, 1777, __pyx_L1_error) + PyGeventChild_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "child", (PyObject *)&PyGeventChild_Type) < 0) __PYX_ERR(0, 1777, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_child = &PyGeventChild_Type; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + PyGeventStat_Type.tp_base = __pyx_ptype_6gevent_5libev_8corecext_watcher; + if (PyType_Ready(&PyGeventStat_Type) < 0) __PYX_ERR(0, 1922, __pyx_L1_error) + PyGeventStat_Type.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "stat", (PyObject *)&PyGeventStat_Type) < 0) __PYX_ERR(0, 1922, __pyx_L1_error) + __pyx_ptype_6gevent_5libev_8corecext_stat = &PyGeventStat_Type; + if (PyType_Ready(&__pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr) < 0) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr.tp_print = 0; + __pyx_ptype_6gevent_5libev_8corecext___pyx_scope_struct__genexpr = &__pyx_type_6gevent_5libev_8corecext___pyx_scope_struct__genexpr; + /*--- Type import code ---*/ + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__94, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__87, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__82, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__86, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__93, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__95, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__88, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__90, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__83, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__87, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__94, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__96, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__91, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__84, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__88, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__95, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_traceback, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_level, __pyx_int_0) < 0) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__97, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__90, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__92, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__85, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__89, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin___import__, __pyx_tuple__96, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_signalmodule, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_get_version); + __Pyx_GIVEREF(__pyx_n_s_get_version); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_version); + __Pyx_INCREF(__pyx_n_s_get_header_version); + __Pyx_GIVEREF(__pyx_n_s_get_header_version); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_get_header_version); + __Pyx_INCREF(__pyx_n_s_supported_backends); + __Pyx_GIVEREF(__pyx_n_s_supported_backends); + PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_supported_backends); + __Pyx_INCREF(__pyx_n_s_recommended_backends); + __Pyx_GIVEREF(__pyx_n_s_recommended_backends); + PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_recommended_backends); + __Pyx_INCREF(__pyx_n_s_embeddable_backends); + __Pyx_GIVEREF(__pyx_n_s_embeddable_backends); + PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_embeddable_backends); + __Pyx_INCREF(__pyx_n_s_time); + __Pyx_GIVEREF(__pyx_n_s_time); + PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_time); + __Pyx_INCREF(__pyx_n_s_loop); + __Pyx_GIVEREF(__pyx_n_s_loop); + PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_loop); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_3) { + + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)(&PyInt_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyInt_Type))); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type))); + __Pyx_XGOTREF(__pyx_v_6gevent_5libev_8corecext_integer_types); + __Pyx_DECREF_SET(__pyx_v_6gevent_5libev_8corecext_integer_types, ((PyObject*)__pyx_t_2)); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + goto __pyx_L2; + } + + /*else*/ { + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)(&PyInt_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyInt_Type))); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type))); + __Pyx_INCREF(((PyObject *)(&PyLong_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyLong_Type))); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyLong_Type))); + __Pyx_XGOTREF(__pyx_v_6gevent_5libev_8corecext_integer_types); + __Pyx_DECREF_SET(__pyx_v_6gevent_5libev_8corecext_integer_types, ((PyObject*)__pyx_t_2)); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + } + __pyx_L2:; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_UNDEF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_UNDEF, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_NONE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONE, __pyx_t_2) < 0) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_READ, __pyx_t_2) < 0) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_WRITE, __pyx_t_2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_TIMER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMER, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PERIODIC, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNAL, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHILD, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_STAT, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDLE, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PREPARE, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHECK, __pyx_t_2) < 0) __PYX_ERR(0, 72, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMBED, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORK, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CLEANUP, __pyx_t_2) < 0) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ASYNC, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUSTOM, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ERROR, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int((EV_READ | EV_WRITE)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_READWRITE, __pyx_t_2) < 0) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_MINPRI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_MINPRI, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EV_MAXPRI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAXPRI, __pyx_t_2) < 0) __PYX_ERR(0, 83, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_PORT, __pyx_t_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_KQUEUE, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_EPOLL, __pyx_t_2) < 0) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_POLL, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BACKEND_SELECT, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_FORKCHECK, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOINOTIFY, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SIGNALFD, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOSIGMASK, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_5libev_8corecext__EVENTSType), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(GEVENT_CORE_EVENTS); + __Pyx_DECREF_SET(GEVENT_CORE_EVENTS, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EVENTS, GEVENT_CORE_EVENTS) < 0) __PYX_ERR(0, 104, __pyx_L1_error) + + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_1get_version, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_2) < 0) __PYX_ERR(0, 107, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_3get_header_version, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_header_version, __pyx_t_2) < 0) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_PORT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_port); + __Pyx_GIVEREF(__pyx_n_s_port); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_port); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_KQUEUE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_kqueue); + __Pyx_GIVEREF(__pyx_n_s_kqueue); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_kqueue); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_EPOLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_epoll); + __Pyx_GIVEREF(__pyx_n_s_epoll); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_epoll); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_POLL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_poll); + __Pyx_GIVEREF(__pyx_n_s_poll); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_poll); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVBACKEND_SELECT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_select); + __Pyx_GIVEREF(__pyx_n_s_select); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_select); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOENV); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_noenv); + __Pyx_GIVEREF(__pyx_n_s_noenv); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_noenv); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_FORKCHECK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_forkcheck); + __Pyx_GIVEREF(__pyx_n_s_forkcheck); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_forkcheck); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOINOTIFY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_noinotify); + __Pyx_GIVEREF(__pyx_n_s_noinotify); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_noinotify); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_SIGNALFD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_signalfd); + __Pyx_GIVEREF(__pyx_n_s_signalfd); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_signalfd); + __pyx_t_2 = 0; + + __pyx_t_2 = __Pyx_PyInt_From_int(EVFLAG_NOSIGMASK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + __Pyx_INCREF(__pyx_n_s_nosigmask); + __Pyx_GIVEREF(__pyx_n_s_nosigmask); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_nosigmask); + __pyx_t_2 = 0; + + __pyx_t_2 = PyList_New(10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_8); + PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_9); + PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_10); + PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12); + __pyx_t_1 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_8 = 0; + __pyx_t_9 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_12 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_2) < 0) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_t_2 = __pyx_pf_6gevent_5libev_8corecext_22genexpr(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags_str2int, __pyx_t_12) < 0) __PYX_ERR(0, 128, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_READ); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_READ); + __Pyx_GIVEREF(__pyx_n_s_READ); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_READ); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_WRITE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_WRITE); + __Pyx_GIVEREF(__pyx_n_s_WRITE); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_WRITE); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV__IOFDSET); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_IOFDSET); + __Pyx_GIVEREF(__pyx_n_s_IOFDSET); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_IOFDSET); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_PERIODIC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_PERIODIC); + __Pyx_GIVEREF(__pyx_n_s_PERIODIC); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_PERIODIC); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_SIGNAL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_SIGNAL); + __Pyx_GIVEREF(__pyx_n_s_SIGNAL); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_SIGNAL); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHILD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_CHILD); + __Pyx_GIVEREF(__pyx_n_s_CHILD); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_CHILD); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_STAT); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_STAT); + __Pyx_GIVEREF(__pyx_n_s_STAT); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_STAT); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_IDLE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_IDLE); + __Pyx_GIVEREF(__pyx_n_s_IDLE); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_IDLE); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_PREPARE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_PREPARE); + __Pyx_GIVEREF(__pyx_n_s_PREPARE); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_PREPARE); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_CHECK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_CHECK); + __Pyx_GIVEREF(__pyx_n_s_CHECK); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CHECK); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_EMBED); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_EMBED); + __Pyx_GIVEREF(__pyx_n_s_EMBED); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_EMBED); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_FORK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 142, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_FORK); + __Pyx_GIVEREF(__pyx_n_s_FORK); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_FORK); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_CLEANUP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_CLEANUP); + __Pyx_GIVEREF(__pyx_n_s_CLEANUP); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_CLEANUP); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_ASYNC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 144, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_16); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_ASYNC); + __Pyx_GIVEREF(__pyx_n_s_ASYNC); + PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ASYNC); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_CUSTOM); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_17); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_CUSTOM); + __Pyx_GIVEREF(__pyx_n_s_CUSTOM); + PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_CUSTOM); + __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_ERROR); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_18); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_n_s_ERROR); + __Pyx_GIVEREF(__pyx_n_s_ERROR); + PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ERROR); + __pyx_t_12 = 0; + + __pyx_t_12 = PyList_New(16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_2); + PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_11); + PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_10); + PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_9); + PyList_SET_ITEM(__pyx_t_12, 3, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_8); + PyList_SET_ITEM(__pyx_t_12, 4, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_7); + PyList_SET_ITEM(__pyx_t_12, 5, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_6); + PyList_SET_ITEM(__pyx_t_12, 6, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); + PyList_SET_ITEM(__pyx_t_12, 7, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_12, 8, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyList_SET_ITEM(__pyx_t_12, 9, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_13); + PyList_SET_ITEM(__pyx_t_12, 10, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_14); + PyList_SET_ITEM(__pyx_t_12, 11, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_15); + PyList_SET_ITEM(__pyx_t_12, 12, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_16); + PyList_SET_ITEM(__pyx_t_12, 13, __pyx_t_16); + __Pyx_GIVEREF(__pyx_t_17); + PyList_SET_ITEM(__pyx_t_12, 14, __pyx_t_17); + __Pyx_GIVEREF(__pyx_t_18); + PyList_SET_ITEM(__pyx_t_12, 15, __pyx_t_18); + __pyx_t_2 = 0; + __pyx_t_11 = 0; + __pyx_t_10 = 0; + __pyx_t_9 = 0; + __pyx_t_8 = 0; + __pyx_t_7 = 0; + __pyx_t_6 = 0; + __pyx_t_5 = 0; + __pyx_t_4 = 0; + __pyx_t_1 = 0; + __pyx_t_13 = 0; + __pyx_t_14 = 0; + __pyx_t_15 = 0; + __pyx_t_16 = 0; + __pyx_t_17 = 0; + __pyx_t_18 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_events, __pyx_t_12) < 0) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_version_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_18); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_18, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __pyx_t_18 = PyObject_RichCompare(__pyx_t_12, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + if (__pyx_t_3) { + + __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_18); + __Pyx_INCREF(((PyObject *)(&PyBytes_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyBytes_Type))); + PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)(&PyBytes_Type))); + __Pyx_INCREF(((PyObject *)(&PyString_Type))); + __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); + PyTuple_SET_ITEM(__pyx_t_18, 1, ((PyObject *)(&PyString_Type))); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_18) < 0) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + + goto __pyx_L3; + } + + /*else*/ { + __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_18); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_basestring); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_basestring, __pyx_t_12) < 0) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + __pyx_L3:; + + __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_13supported_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_supported_backends, __pyx_t_12) < 0) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_15recommended_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_recommended_backends, __pyx_t_12) < 0) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_17embeddable_backends, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_embeddable_backends, __pyx_t_12) < 0) __PYX_ERR(0, 228, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = PyCFunction_NewEx(&__pyx_mdef_6gevent_5libev_8corecext_19time, NULL, __pyx_n_s_gevent_libev_corecext); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 232, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_12) < 0) __PYX_ERR(0, 232, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_v_6gevent_5libev_8corecext__default_loop_destroyed = 0; + + __pyx_k__9 = EVBREAK_ONE; + + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYSERR_CALLBACK, Py_None) < 0) __PYX_ERR(0, 2072, __pyx_L1_error) + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBEV_EMBED, Py_False) < 0) __PYX_ERR(0, 2109, __pyx_L1_error) +#endif /* (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBEV_EMBED, Py_True) < 0) __PYX_ERR(0, 2098, __pyx_L1_error) + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_FLOOR); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2099, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_FLOOR, __pyx_t_12) < 0) __PYX_ERR(0, 2099, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_CLOCK_SYSCALL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2100, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_CLOCK_SYSCALL, __pyx_t_12) < 0) __PYX_ERR(0, 2100, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_REALTIME); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_REALTIME, __pyx_t_12) < 0) __PYX_ERR(0, 2101, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_MONOTONIC); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_MONOTONIC, __pyx_t_12) < 0) __PYX_ERR(0, 2102, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_NANOSLEEP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_NANOSLEEP, __pyx_t_12) < 0) __PYX_ERR(0, 2103, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_INOTIFY); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_INOTIFY, __pyx_t_12) < 0) __PYX_ERR(0, 2104, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_SIGNALFD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2105, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_SIGNALFD, __pyx_t_12) < 0) __PYX_ERR(0, 2105, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_EVENTFD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2106, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_EVENTFD, __pyx_t_12) < 0) __PYX_ERR(0, 2106, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + __pyx_t_12 = __Pyx_PyInt_From_int(EV_USE_4HEAP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2107, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_EV_USE_4HEAP, __pyx_t_12) < 0) __PYX_ERR(0, 2107, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + + __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_12) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_16); + __Pyx_XDECREF(__pyx_t_17); + __Pyx_XDECREF(__pyx_t_18); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init gevent.libev.corecext", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init gevent.libev.corecext"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* GetModuleGlobalName */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* IterFinish */ + static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +/* UnpackItemEndCheck */ + static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); +/* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); +} +#endif // CYTHON_FAST_PYCCALL + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = PyThreadState_GET(); + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); +/* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { +/* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif // CPython < 3.6 +#endif // CYTHON_FAST_PYCALL + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { + PyObject *exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + return PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* StringJoin */ + #if !CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) { + return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL); +} +#endif + +/* PyErrFetchRestore */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* RaiseDoubleKeywords */ + static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ + static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* RaiseArgTupleInvalid */ + static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* WriteUnraisableException */ + static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* GetItemInt */ + static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* GetAttr */ + static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { +#if CYTHON_COMPILING_IN_CPYTHON +#if PY_MAJOR_VERSION >= 3 + if (likely(PyUnicode_Check(n))) +#else + if (likely(PyString_Check(n))) +#endif + return __Pyx_PyObject_GetAttrStr(o, n); +#endif + return PyObject_GetAttr(o, n); +} + +/* GetAttr3 */ + static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + goto bad; + PyErr_Clear(); + r = d; + Py_INCREF(d); + } + return r; +bad: + return NULL; +} + +/* ArgTypeTest */ + static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; + } + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; +} + +/* SwapException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) +/* KeywordStringCheck */ + static CYTHON_INLINE int __Pyx_CheckKeywordStrings( + PyObject *kwdict, + const char* function_name, + int kw_allowed) +{ + PyObject* key = 0; + Py_ssize_t pos = 0; +#if CYTHON_COMPILING_IN_PYPY + if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) + goto invalid_keyword; + return 1; +#else + while (PyDict_Next(kwdict, &pos, &key, 0)) { + #if PY_MAJOR_VERSION < 3 + if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + #endif + if (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; + } + if ((!kw_allowed) && unlikely(key)) + goto invalid_keyword; + return 1; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + return 0; +#endif +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif + return 0; +} + +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) +/* CallNextTpTraverse */ + static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { + PyTypeObject* type = Py_TYPE(obj); + while (type && type->tp_traverse != current_tp_traverse) + type = type->tp_base; + while (type && type->tp_traverse == current_tp_traverse) + type = type->tp_base; + if (type && type->tp_traverse) + return type->tp_traverse(obj, v, a); + return 0; +} + +/* CallNextTpClear */ + static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { + PyTypeObject* type = Py_TYPE(obj); + while (type && type->tp_clear != current_tp_clear) + type = type->tp_base; + while (type && type->tp_clear == current_tp_clear) + type = type->tp_base; + if (type && type->tp_clear) + type->tp_clear(obj); +} + +/* SetVTable */ + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(unsigned int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(unsigned int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(unsigned int), +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_vfd_socket_t(vfd_socket_t value) { + const vfd_socket_t neg_one = (vfd_socket_t) -1, const_zero = (vfd_socket_t) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(vfd_socket_t) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(vfd_socket_t) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(vfd_socket_t) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(vfd_socket_t) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(vfd_socket_t) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(vfd_socket_t), +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(unsigned int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (unsigned int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { + return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { + return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { + return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(unsigned int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) + case -2: + if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(unsigned int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + unsigned int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (unsigned int) -1; + } + } else { + unsigned int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (unsigned int) -1; + val = __Pyx_PyInt_As_unsigned_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned int"); + return (unsigned int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned int"); + return (unsigned int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { + const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(size_t) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (size_t) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (size_t) 0; + case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) + case 2: + if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { + return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { + return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { + return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (size_t) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(size_t) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (size_t) 0; + case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) + case -2: + if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { + return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + } +#endif + if (sizeof(size_t) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + size_t val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (size_t) -1; + } + } else { + size_t val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (size_t) -1; + val = __Pyx_PyInt_As_size_t(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to size_t"); + return (size_t) -1; +} + +/* CIntFromPy */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) + static CYTHON_INLINE vfd_socket_t __Pyx_PyInt_As_vfd_socket_t(PyObject *x) { + const vfd_socket_t neg_one = (vfd_socket_t) -1, const_zero = (vfd_socket_t) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(vfd_socket_t) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (vfd_socket_t) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (vfd_socket_t) 0; + case 1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, digit, digits[0]) + case 2: + if (8 * sizeof(vfd_socket_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) >= 2 * PyLong_SHIFT) { + return (vfd_socket_t) (((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(vfd_socket_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) >= 3 * PyLong_SHIFT) { + return (vfd_socket_t) (((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(vfd_socket_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) >= 4 * PyLong_SHIFT) { + return (vfd_socket_t) (((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (vfd_socket_t) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(vfd_socket_t) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(vfd_socket_t) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (vfd_socket_t) 0; + case -1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(vfd_socket_t, digit, +digits[0]) + case -2: + if (8 * sizeof(vfd_socket_t) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { + return (vfd_socket_t) (((vfd_socket_t)-1)*(((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(vfd_socket_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { + return (vfd_socket_t) ((((((vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(vfd_socket_t) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { + return (vfd_socket_t) (((vfd_socket_t)-1)*(((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(vfd_socket_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { + return (vfd_socket_t) ((((((((vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(vfd_socket_t) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 4 * PyLong_SHIFT) { + return (vfd_socket_t) (((vfd_socket_t)-1)*(((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(vfd_socket_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(vfd_socket_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(vfd_socket_t) - 1 > 4 * PyLong_SHIFT) { + return (vfd_socket_t) ((((((((((vfd_socket_t)digits[3]) << PyLong_SHIFT) | (vfd_socket_t)digits[2]) << PyLong_SHIFT) | (vfd_socket_t)digits[1]) << PyLong_SHIFT) | (vfd_socket_t)digits[0]))); + } + } + break; + } +#endif + if (sizeof(vfd_socket_t) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(vfd_socket_t) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(vfd_socket_t, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + vfd_socket_t val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (vfd_socket_t) -1; + } + } else { + vfd_socket_t val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (vfd_socket_t) -1; + val = __Pyx_PyInt_As_vfd_socket_t(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to vfd_socket_t"); + return (vfd_socket_t) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to vfd_socket_t"); + return (vfd_socket_t) -1; +} + +/* CIntFromPy */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) */ +#if (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FetchCommonType */ + static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } +done: + Py_DECREF(fake_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + +/* PyObjectCallMethod1 */ + static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { + PyObject *method, *result = NULL; + method = __Pyx_PyObject_GetAttrStr(obj, method_name); + if (unlikely(!method)) goto done; +#if CYTHON_UNPACK_METHODS + if (likely(PyMethod_Check(method))) { + PyObject *self = PyMethod_GET_SELF(method); + if (likely(self)) { + PyObject *args; + PyObject *function = PyMethod_GET_FUNCTION(method); + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyFunction_FastCall(function, args, 2); + goto done; + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {self, arg}; + result = __Pyx_PyCFunction_FastCall(function, args, 2); + goto done; + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 1, arg); + Py_INCREF(function); + Py_DECREF(method); method = NULL; + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); + return result; + } + } +#endif + result = __Pyx_PyObject_CallOneArg(method, arg); +done: + Py_XDECREF(method); + return result; +} + +/* CoroutineBase */ + #include <structmember.h> +#include <frameobject.h> +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); +static PyObject *__Pyx_Coroutine_Close(PyObject *self); +static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); +#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) +#if 1 || PY_VERSION_HEX < 0x030300B0 +static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { + PyObject *et, *ev, *tb; + PyObject *value = NULL; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&et, &ev, &tb); + if (!et) { + Py_XDECREF(tb); + Py_XDECREF(ev); + Py_INCREF(Py_None); + *pvalue = Py_None; + return 0; + } + if (likely(et == PyExc_StopIteration)) { + if (!ev) { + Py_INCREF(Py_None); + value = Py_None; + } +#if PY_VERSION_HEX >= 0x030300A0 + else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); + } +#endif + else if (unlikely(PyTuple_Check(ev))) { + if (PyTuple_GET_SIZE(ev) >= 1) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + value = PyTuple_GET_ITEM(ev, 0); + Py_INCREF(value); +#else + value = PySequence_ITEM(ev, 0); +#endif + } else { + Py_INCREF(Py_None); + value = Py_None; + } + Py_DECREF(ev); + } + else if (!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { + value = ev; + } + if (likely(value)) { + Py_XDECREF(tb); + Py_DECREF(et); + *pvalue = value; + return 0; + } + } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + PyErr_NormalizeException(&et, &ev, &tb); + if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + Py_XDECREF(tb); + Py_DECREF(et); +#if PY_VERSION_HEX >= 0x030300A0 + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); +#else + { + PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); + Py_DECREF(ev); + if (likely(args)) { + value = PySequence_GetItem(args, 0); + Py_DECREF(args); + } + if (unlikely(!value)) { + __Pyx_ErrRestore(NULL, NULL, NULL); + Py_INCREF(Py_None); + value = Py_None; + } + } +#endif + *pvalue = value; + return 0; +} +#endif +static CYTHON_INLINE +void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) { + PyObject *exc_type = self->exc_type; + PyObject *exc_value = self->exc_value; + PyObject *exc_traceback = self->exc_traceback; + self->exc_type = NULL; + self->exc_value = NULL; + self->exc_traceback = NULL; + Py_XDECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_traceback); +} +static CYTHON_INLINE +int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) { + if (unlikely(gen->is_running)) { + PyErr_SetString(PyExc_ValueError, + "generator already executing"); + return 1; + } + return 0; +} +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) { + PyObject *retval; + __Pyx_PyThreadState_declare + assert(!self->is_running); + if (unlikely(self->resume_label == 0)) { + if (unlikely(value && value != Py_None)) { + PyErr_SetString(PyExc_TypeError, + "can't send non-None value to a " + "just-started generator"); + return NULL; + } + } + if (unlikely(self->resume_label == -1)) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + __Pyx_PyThreadState_assign + if (value) { +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON +#else + if (self->exc_traceback) { + PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; + PyFrameObject *f = tb->tb_frame; + Py_XINCREF(__pyx_tstate->frame); + assert(f->f_back == NULL); + f->f_back = __pyx_tstate->frame; + } +#endif + __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, + &self->exc_traceback); + } else { + __Pyx_Coroutine_ExceptionClear(self); + } + self->is_running = 1; + retval = self->body((PyObject *) self, value); + self->is_running = 0; + if (retval) { + __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, + &self->exc_traceback); +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON +#else + if (self->exc_traceback) { + PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); + } +#endif + } else { + __Pyx_Coroutine_ExceptionClear(self); + } + return retval; +} +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) { + if (unlikely(!retval && !PyErr_Occurred())) { + PyErr_SetNone(PyExc_StopIteration); + } + return retval; +} +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { + PyObject *ret; + PyObject *val = NULL; + __Pyx_Coroutine_Undelegate(gen); + __Pyx_PyGen_FetchStopIterationValue(&val); + ret = __Pyx_Coroutine_SendEx(gen, val); + Py_XDECREF(val); + return ret; +} +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { + PyObject *retval; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_CheckExact(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + { + if (value == Py_None) + ret = Py_TYPE(yf)->tp_iternext(yf); + else + ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); + } + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + retval = __Pyx_Coroutine_FinishDelegation(gen); + } else { + retval = __Pyx_Coroutine_SendEx(gen, value); + } + return __Pyx_Coroutine_MethodReturn(retval); +} +static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { + PyObject *retval = NULL; + int err = 0; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_CheckExact(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + #endif + { + PyObject *meth; + gen->is_running = 1; + meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close); + if (unlikely(!meth)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_WriteUnraisable(yf); + } + PyErr_Clear(); + } else { + retval = PyObject_CallFunction(meth, NULL); + Py_DECREF(meth); + if (!retval) + err = -1; + } + gen->is_running = 0; + } + Py_XDECREF(retval); + return err; +} +static PyObject *__Pyx_Generator_Next(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Next(yf); + } else + #endif + ret = Py_TYPE(yf)->tp_iternext(yf); + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + return __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_SendEx(gen, Py_None); +} +static PyObject *__Pyx_Coroutine_Close(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *retval, *raised_exception; + PyObject *yf = gen->yieldfrom; + int err = 0; + if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) + return NULL; + if (yf) { + Py_INCREF(yf); + err = __Pyx_Coroutine_CloseIter(gen, yf); + __Pyx_Coroutine_Undelegate(gen); + Py_DECREF(yf); + } + if (err == 0) + PyErr_SetNone(PyExc_GeneratorExit); + retval = __Pyx_Coroutine_SendEx(gen, NULL); + if (retval) { + Py_DECREF(retval); + PyErr_SetString(PyExc_RuntimeError, + "generator ignored GeneratorExit"); + return NULL; + } + raised_exception = PyErr_Occurred(); + if (!raised_exception + || raised_exception == PyExc_StopIteration + || raised_exception == PyExc_GeneratorExit + || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit) + || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration)) + { + if (raised_exception) PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + return NULL; +} +static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *typ; + PyObject *tb = NULL; + PyObject *val = NULL; + PyObject *yf = gen->yieldfrom; + if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) + return NULL; + if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) + return NULL; + if (yf) { + PyObject *ret; + Py_INCREF(yf); + if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) { + int err = __Pyx_Coroutine_CloseIter(gen, yf); + Py_DECREF(yf); + __Pyx_Coroutine_Undelegate(gen); + if (err < 0) + return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); + goto throw_here; + } + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Coroutine_Throw(yf, args); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_CheckExact(yf)) { + ret = __Pyx_Coroutine_Throw(yf, args); + } else + #endif + { + PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); + if (unlikely(!meth)) { + Py_DECREF(yf); + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + gen->is_running = 0; + return NULL; + } + PyErr_Clear(); + __Pyx_Coroutine_Undelegate(gen); + gen->is_running = 0; + goto throw_here; + } + ret = PyObject_CallObject(meth, args); + Py_DECREF(meth); + } + gen->is_running = 0; + Py_DECREF(yf); + if (!ret) { + ret = __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_MethodReturn(ret); + } +throw_here: + __Pyx_Raise(typ, val, tb, NULL); + return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); +} +static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + Py_VISIT(gen->closure); + Py_VISIT(gen->classobj); + Py_VISIT(gen->yieldfrom); + Py_VISIT(gen->exc_type); + Py_VISIT(gen->exc_value); + Py_VISIT(gen->exc_traceback); + return 0; +} +static int __Pyx_Coroutine_clear(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + Py_CLEAR(gen->closure); + Py_CLEAR(gen->classobj); + Py_CLEAR(gen->yieldfrom); + Py_CLEAR(gen->exc_type); + Py_CLEAR(gen->exc_value); + Py_CLEAR(gen->exc_traceback); + Py_CLEAR(gen->gi_name); + Py_CLEAR(gen->gi_qualname); + return 0; +} +static void __Pyx_Coroutine_dealloc(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject_GC_UnTrack(gen); + if (gen->gi_weakreflist != NULL) + PyObject_ClearWeakRefs(self); + if (gen->resume_label > 0) { + PyObject_GC_Track(self); +#if PY_VERSION_HEX >= 0x030400a1 + if (PyObject_CallFinalizerFromDealloc(self)) +#else + Py_TYPE(gen)->tp_del(self); + if (self->ob_refcnt > 0) +#endif + { + return; + } + PyObject_GC_UnTrack(self); + } + __Pyx_Coroutine_clear(self); + PyObject_GC_Del(gen); +} +static void __Pyx_Coroutine_del(PyObject *self) { + PyObject *res; + PyObject *error_type, *error_value, *error_traceback; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + __Pyx_PyThreadState_declare + if (gen->resume_label <= 0) + return ; +#if PY_VERSION_HEX < 0x030400a1 + assert(self->ob_refcnt == 0); + self->ob_refcnt = 1; +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); + res = __Pyx_Coroutine_Close(self); + if (res == NULL) + PyErr_WriteUnraisable(self); + else + Py_DECREF(res); + __Pyx_ErrRestore(error_type, error_value, error_traceback); +#if PY_VERSION_HEX < 0x030400a1 + assert(self->ob_refcnt > 0); + if (--self->ob_refcnt == 0) { + return; + } + { + Py_ssize_t refcnt = self->ob_refcnt; + _Py_NewReference(self); + self->ob_refcnt = refcnt; + } +#if CYTHON_COMPILING_IN_CPYTHON + assert(PyType_IS_GC(self->ob_type) && + _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); + _Py_DEC_REFTOTAL; +#endif +#ifdef COUNT_ALLOCS + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; +#endif +#endif +} +static PyObject * +__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self) +{ + PyObject *name = self->gi_name; + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = self->gi_name; + Py_INCREF(value); + self->gi_name = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self) +{ + PyObject *name = self->gi_qualname; + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) { +#else + if (unlikely(value == NULL || !PyString_Check(value))) { +#endif + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = self->gi_qualname; + Py_INCREF(value); + self->gi_qualname = value; + Py_XDECREF(tmp); + return 0; +} +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); + if (gen == NULL) + return NULL; + gen->body = body; + gen->closure = closure; + Py_XINCREF(closure); + gen->is_running = 0; + gen->resume_label = 0; + gen->classobj = NULL; + gen->yieldfrom = NULL; + gen->exc_type = NULL; + gen->exc_value = NULL; + gen->exc_traceback = NULL; + gen->gi_weakreflist = NULL; + Py_XINCREF(qualname); + gen->gi_qualname = qualname; + Py_XINCREF(name); + gen->gi_name = name; + Py_XINCREF(module_name); + gen->gi_modulename = module_name; + PyObject_GC_Track(gen); + return gen; +} + +/* PatchModuleWithCoroutine */ + static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + int result; + PyObject *globals, *result_obj; + globals = PyDict_New(); if (unlikely(!globals)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_coroutine_type", + #ifdef __Pyx_Coroutine_USED + (PyObject*)__pyx_CoroutineType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_generator_type", + #ifdef __Pyx_Generator_USED + (PyObject*)__pyx_GeneratorType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; + result_obj = PyRun_String(py_code, Py_file_input, globals, globals); + if (unlikely(!result_obj)) goto ignore; + Py_DECREF(result_obj); + Py_DECREF(globals); + return module; +ignore: + Py_XDECREF(globals); + PyErr_WriteUnraisable(module); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { + Py_DECREF(module); + module = NULL; + } +#else + py_code++; +#endif + return module; +} + +/* PatchGeneratorABC */ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) +static PyObject* __Pyx_patch_abc_module(PyObject *module); +static PyObject* __Pyx_patch_abc_module(PyObject *module) { + module = __Pyx_Coroutine_patch_module( + module, "" +"if _cython_generator_type is not None:\n" +" try: Generator = _module.Generator\n" +" except AttributeError: pass\n" +" else: Generator.register(_cython_generator_type)\n" +"if _cython_coroutine_type is not None:\n" +" try: Coroutine = _module.Coroutine\n" +" except AttributeError: pass\n" +" else: Coroutine.register(_cython_coroutine_type)\n" + ); + return module; +} +#endif +static int __Pyx_patch_abc(void) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + static int abc_patched = 0; + if (!abc_patched) { + PyObject *module; + module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections"); + if (!module) { + PyErr_WriteUnraisable(NULL); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, + ((PY_VERSION_HEX >= 0x03030000) ? + "Cython module failed to register with collections.abc module" : + "Cython module failed to register with collections module"), 1) < 0)) { + return -1; + } + } else { + module = __Pyx_patch_abc_module(module); + abc_patched = 1; + if (unlikely(!module)) + return -1; + Py_DECREF(module); + } + module = PyImport_ImportModule("backports_abc"); + if (module) { + module = __Pyx_patch_abc_module(module); + Py_XDECREF(module); + } + if (!module) { + PyErr_Clear(); + } + } +#else + if (0) __Pyx_Coroutine_patch_module(NULL, NULL); +#endif + return 0; +} + +/* Generator */ + static PyMethodDef __pyx_Generator_methods[] = { + {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, + {0, 0, 0, 0} +}; +static PyMemberDef __pyx_Generator_memberlist[] = { + {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, + {0, 0, 0, 0, 0} +}; +static PyGetSetDef __pyx_Generator_getsets[] = { + {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the generator"), 0}, + {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the generator"), 0}, + {0, 0, 0, 0, 0} +}; +static PyTypeObject __pyx_GeneratorType_type = { + PyVarObject_HEAD_INIT(0, 0) + "generator", + sizeof(__pyx_CoroutineObject), + 0, + (destructor) __Pyx_Coroutine_dealloc, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, + 0, + (traverseproc) __Pyx_Coroutine_traverse, + 0, + 0, + offsetof(__pyx_CoroutineObject, gi_weakreflist), + 0, + (iternextfunc) __Pyx_Generator_Next, + __pyx_Generator_methods, + __pyx_Generator_memberlist, + __pyx_Generator_getsets, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if PY_VERSION_HEX >= 0x030400a1 + 0, +#else + __Pyx_Coroutine_del, +#endif + 0, +#if PY_VERSION_HEX >= 0x030400a1 + __Pyx_Coroutine_del, +#endif +}; +static int __pyx_Generator_init(void) { + __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr; + __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; + __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); + if (unlikely(!__pyx_GeneratorType)) { + return -1; + } + return 0; +} + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +#endif + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } + #else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } + #endif +#else + res = PyNumber_Int(x); +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ +#endif /* (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) || (EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)) || (!EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && defined(_WIN32)) || (!EV_USE_SIGNALFD && defined(LIBEV_EMBED) && !defined(_WIN32)) */ +/* Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. */ +#ifdef Py_PYTHON_H + +/* the name changes depending on our file layout and --module-name option */ +#define _GEVENTLOOP struct __pyx_vtabstruct_6gevent_5libev_8corecext_loop + + +static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* context) { + PyThreadState *tstate; + PyObject *type, *value, *traceback, *result; + tstate = PyThreadState_GET(); + type = tstate->curexc_type; + if (!type) + return; + value = tstate->curexc_value; + traceback = tstate->curexc_traceback; + if (!value) value = Py_None; + if (!traceback) traceback = Py_None; + + Py_INCREF(type); + Py_INCREF(value); + Py_INCREF(traceback); + + PyErr_Clear(); + + result = ((_GEVENTLOOP *)loop->__pyx_vtab)->handle_error(loop, context, type, value, traceback, 0); + + if (result) { + Py_DECREF(result); + } + else { + PyErr_Print(); + PyErr_Clear(); + } + + Py_DECREF(type); + Py_DECREF(value); + Py_DECREF(traceback); +} + + +static CYTHON_INLINE void gevent_check_signals(struct PyGeventLoopObject* loop) { + if (!ev_is_default_loop(loop->_ptr)) { + /* only reporting signals on the default loop */ + return; + } + PyErr_CheckSignals(); + if (PyErr_Occurred()) gevent_handle_error(loop, Py_None); +} + +#define GET_OBJECT(PY_TYPE, EV_PTR, MEMBER) \ + ((struct PY_TYPE *)(((char *)EV_PTR) - offsetof(struct PY_TYPE, MEMBER))) + + +#ifdef WITH_THREAD +#define GIL_DECLARE PyGILState_STATE ___save +#define GIL_ENSURE ___save = PyGILState_Ensure(); +#define GIL_RELEASE PyGILState_Release(___save); +#else +#define GIL_DECLARE +#define GIL_ENSURE +#define GIL_RELEASE +#endif + + +static void gevent_stop(PyObject* watcher, struct PyGeventLoopObject* loop) { + PyObject *result, *method; + int error; + error = 1; + method = PyObject_GetAttrString(watcher, "stop"); + if (method) { + result = PyObject_Call(method, __pyx_empty_tuple, NULL); + if (result) { + Py_DECREF(result); + error = 0; + } + Py_DECREF(method); + } + if (error) { + gevent_handle_error(loop, watcher); + } +} + + +static void gevent_callback(struct PyGeventLoopObject* loop, PyObject* callback, PyObject* args, PyObject* watcher, void *c_watcher, int revents) { + GIL_DECLARE; + PyObject *result, *py_events; + long length; + py_events = 0; + GIL_ENSURE; + Py_INCREF(loop); + Py_INCREF(callback); + Py_INCREF(args); + Py_INCREF(watcher); + gevent_check_signals(loop); + if (args == Py_None) { + args = __pyx_empty_tuple; + } + length = PyTuple_Size(args); + if (length < 0) { + gevent_handle_error(loop, watcher); + goto end; + } + if (length > 0 && PyTuple_GET_ITEM(args, 0) == GEVENT_CORE_EVENTS) { + py_events = PyInt_FromLong(revents); + if (!py_events) { + gevent_handle_error(loop, watcher); + goto end; + } + PyTuple_SET_ITEM(args, 0, py_events); + } + else { + py_events = NULL; + } + result = PyObject_Call(callback, args, NULL); + if (result) { + Py_DECREF(result); + } + else { + gevent_handle_error(loop, watcher); + if (revents & (EV_READ|EV_WRITE)) { + /* io watcher: not stopping it may cause the failing callback to be called repeatedly */ + gevent_stop(watcher, loop); + goto end; + } + } + if (!ev_is_active(c_watcher)) { + /* Watcher was stopped, maybe by libev. Let's call stop() to clean up + * 'callback' and 'args' properties, do Py_DECREF() and ev_ref() if necessary. + * BTW, we don't need to check for EV_ERROR, because libev stops the watcher in that case. */ + gevent_stop(watcher, loop); + } +end: + if (py_events) { + Py_DECREF(py_events); + PyTuple_SET_ITEM(args, 0, GEVENT_CORE_EVENTS); + } + Py_DECREF(watcher); + Py_DECREF(args); + Py_DECREF(callback); + Py_DECREF(loop); + GIL_RELEASE; +} + + +static void gevent_call(struct PyGeventLoopObject* loop, struct PyGeventCallbackObject* cb) { + /* no need for GIL here because it is only called from run_callbacks which already has GIL */ + PyObject *result, *callback, *args; + if (!loop || !cb) + return; + callback = cb->callback; + args = cb->args; + if (!callback || !args) + return; + if (callback == Py_None || args == Py_None) + return; + Py_INCREF(loop); + Py_INCREF(callback); + Py_INCREF(args); + + Py_INCREF(Py_None); + Py_DECREF(cb->callback); + cb->callback = Py_None; + + result = PyObject_Call(callback, args, NULL); + if (result) { + Py_DECREF(result); + } + else { + gevent_handle_error(loop, (PyObject*)cb); + } + + Py_INCREF(Py_None); + Py_DECREF(cb->args); + cb->args = Py_None; + + Py_DECREF(callback); + Py_DECREF(args); + Py_DECREF(loop); +} + + +#undef DEFINE_CALLBACK +#define DEFINE_CALLBACK(WATCHER_LC, WATCHER_TYPE) \ + static void gevent_callback_##WATCHER_LC(struct ev_loop *_loop, void *c_watcher, int revents) { \ + struct PyGevent##WATCHER_TYPE##Object* watcher = GET_OBJECT(PyGevent##WATCHER_TYPE##Object, c_watcher, _watcher); \ + gevent_callback(watcher->loop, watcher->_callback, watcher->args, (PyObject*)watcher, c_watcher, revents); \ + } + + +DEFINE_CALLBACKS + + +static void gevent_run_callbacks(struct ev_loop *_loop, void *watcher, int revents) { + struct PyGeventLoopObject* loop; + PyObject *result; + GIL_DECLARE; + GIL_ENSURE; + loop = GET_OBJECT(PyGeventLoopObject, watcher, _prepare); + Py_INCREF(loop); + gevent_check_signals(loop); + result = ((_GEVENTLOOP *)loop->__pyx_vtab)->_run_callbacks(loop); + if (result) { + Py_DECREF(result); + } + else { + PyErr_Print(); + PyErr_Clear(); + } + Py_DECREF(loop); + GIL_RELEASE; +} + +#if defined(_WIN32) + +static void gevent_periodic_signal_check(struct ev_loop *_loop, void *watcher, int revents) { + GIL_DECLARE; + GIL_ENSURE; + gevent_check_signals(GET_OBJECT(PyGeventLoopObject, watcher, _periodic_signal_checker)); + GIL_RELEASE; +} + +#endif /* _WIN32 */ + +#endif /* Py_PYTHON_H */ diff --git a/python/gevent/libev/libev.h b/python/gevent/libev/libev.h new file mode 100644 index 0000000..657aaad --- /dev/null +++ b/python/gevent/libev/libev.h @@ -0,0 +1,66 @@ +#if defined(LIBEV_EMBED) +#include "ev.c" +#else +#include "ev.h" + +#ifndef _WIN32 +#include <signal.h> +#endif + +#endif + +#ifndef _WIN32 + +static struct sigaction libev_sigchld; +/* + * Track the state of whether we have installed + * the libev sigchld handler specifically. + * If it's non-zero, libev_sigchld will be valid and set to the action + * that libev needs to do. + * If it's 1, we need to install libev_sigchld to make libev + * child handlers work (on request). + */ +static int sigchld_state = 0; + +static struct ev_loop* gevent_ev_default_loop(unsigned int flags) +{ + struct ev_loop* result; + struct sigaction tmp; + + if (sigchld_state) + return ev_default_loop(flags); + + // Request the old SIGCHLD handler + sigaction(SIGCHLD, NULL, &tmp); + // Get the loop, which will install a SIGCHLD handler + result = ev_default_loop(flags); + // XXX what if SIGCHLD received there? + // Now restore the previous SIGCHLD handler + sigaction(SIGCHLD, &tmp, &libev_sigchld); + sigchld_state = 1; + return result; +} + + +static void gevent_install_sigchld_handler(void) { + if (sigchld_state == 1) { + sigaction(SIGCHLD, &libev_sigchld, NULL); + sigchld_state = 2; + } +} + +static void gevent_reset_sigchld_handler(void) { + // We could have any state at this point, depending on + // whether the default loop has been used. If it has, + // then always be in state 1 ("need to install) + if (sigchld_state) { + sigchld_state = 1; + } +} + +#else + +#define gevent_ev_default_loop ev_default_loop +static void gevent_install_sigchld_handler(void) { } + +#endif diff --git a/python/gevent/libev/libev.pxd b/python/gevent/libev/libev.pxd new file mode 100644 index 0000000..d8914b6 --- /dev/null +++ b/python/gevent/libev/libev.pxd @@ -0,0 +1,208 @@ +cdef extern from "libev_vfd.h": +#ifdef _WIN32 +#ifdef _WIN64 + ctypedef long long vfd_socket_t +#else + ctypedef long vfd_socket_t +#endif +#else + ctypedef int vfd_socket_t +#endif + long vfd_get(int) + int vfd_open(long) except -1 + void vfd_free(int) + +cdef extern from "libev.h": + int EV_MINPRI + int EV_MAXPRI + + int EV_VERSION_MAJOR + int EV_VERSION_MINOR + + int EV_USE_FLOOR + int EV_USE_CLOCK_SYSCALL + int EV_USE_REALTIME + int EV_USE_MONOTONIC + int EV_USE_NANOSLEEP + int EV_USE_SELECT + int EV_USE_POLL + int EV_USE_EPOLL + int EV_USE_KQUEUE + int EV_USE_PORT + int EV_USE_INOTIFY + int EV_USE_SIGNALFD + int EV_USE_EVENTFD + int EV_USE_4HEAP + int EV_USE_IOCP + int EV_SELECT_IS_WINSOCKET + + int EV_UNDEF + int EV_NONE + int EV_READ + int EV_WRITE + int EV__IOFDSET + int EV_TIMER + int EV_PERIODIC + int EV_SIGNAL + int EV_CHILD + int EV_STAT + int EV_IDLE + int EV_PREPARE + int EV_CHECK + int EV_EMBED + int EV_FORK + int EV_CLEANUP + int EV_ASYNC + int EV_CUSTOM + int EV_ERROR + + int EVFLAG_AUTO + int EVFLAG_NOENV + int EVFLAG_FORKCHECK + int EVFLAG_NOINOTIFY + int EVFLAG_SIGNALFD + int EVFLAG_NOSIGMASK + + int EVBACKEND_SELECT + int EVBACKEND_POLL + int EVBACKEND_EPOLL + int EVBACKEND_KQUEUE + int EVBACKEND_DEVPOLL + int EVBACKEND_PORT + int EVBACKEND_IOCP + int EVBACKEND_ALL + int EVBACKEND_MASK + + int EVRUN_NOWAIT + int EVRUN_ONCE + + int EVBREAK_CANCEL + int EVBREAK_ONE + int EVBREAK_ALL + + struct ev_loop: + int activecnt + int sig_pending + int backend_fd + int sigfd + unsigned int origflags + + struct ev_io: + int fd + int events + + struct ev_timer: + double at + + struct ev_signal: + pass + + struct ev_idle: + pass + + struct ev_prepare: + pass + + struct ev_check: + pass + + struct ev_fork: + pass + + struct ev_async: + pass + + struct ev_child: + int pid + int rpid + int rstatus + + struct stat: + int st_nlink + + struct ev_stat: + stat attr + stat prev + double interval + + int ev_version_major() + int ev_version_minor() + + unsigned int ev_supported_backends() + unsigned int ev_recommended_backends() + unsigned int ev_embeddable_backends() + + double ev_time() + void ev_set_syserr_cb(void *) + + int ev_priority(void*) + void ev_set_priority(void*, int) + + int ev_is_pending(void*) + int ev_is_active(void*) + void ev_io_init(ev_io*, void* callback, int fd, int events) + void ev_io_start(ev_loop*, ev_io*) + void ev_io_stop(ev_loop*, ev_io*) + void ev_feed_event(ev_loop*, void*, int) + + void ev_timer_init(ev_timer*, void* callback, double, double) + void ev_timer_start(ev_loop*, ev_timer*) + void ev_timer_stop(ev_loop*, ev_timer*) + void ev_timer_again(ev_loop*, ev_timer*) + + void ev_signal_init(ev_signal*, void* callback, int) + void ev_signal_start(ev_loop*, ev_signal*) + void ev_signal_stop(ev_loop*, ev_signal*) + + void ev_idle_init(ev_idle*, void* callback) + void ev_idle_start(ev_loop*, ev_idle*) + void ev_idle_stop(ev_loop*, ev_idle*) + + void ev_prepare_init(ev_prepare*, void* callback) + void ev_prepare_start(ev_loop*, ev_prepare*) + void ev_prepare_stop(ev_loop*, ev_prepare*) + + void ev_check_init(ev_check*, void* callback) + void ev_check_start(ev_loop*, ev_check*) + void ev_check_stop(ev_loop*, ev_check*) + + void ev_fork_init(ev_fork*, void* callback) + void ev_fork_start(ev_loop*, ev_fork*) + void ev_fork_stop(ev_loop*, ev_fork*) + + void ev_async_init(ev_async*, void* callback) + void ev_async_start(ev_loop*, ev_async*) + void ev_async_stop(ev_loop*, ev_async*) + void ev_async_send(ev_loop*, ev_async*) + int ev_async_pending(ev_async*) + + void ev_child_init(ev_child*, void* callback, int, int) + void ev_child_start(ev_loop*, ev_child*) + void ev_child_stop(ev_loop*, ev_child*) + + void ev_stat_init(ev_stat*, void* callback, char*, double) + void ev_stat_start(ev_loop*, ev_stat*) + void ev_stat_stop(ev_loop*, ev_stat*) + + ev_loop* ev_default_loop(unsigned int flags) + ev_loop* ev_loop_new(unsigned int flags) + void ev_loop_destroy(ev_loop*) + void ev_loop_fork(ev_loop*) + int ev_is_default_loop(ev_loop*) + unsigned int ev_iteration(ev_loop*) + unsigned int ev_depth(ev_loop*) + unsigned int ev_backend(ev_loop*) + void ev_verify(ev_loop*) + void ev_run(ev_loop*, int flags) nogil + + double ev_now(ev_loop*) + void ev_now_update(ev_loop*) + + void ev_ref(ev_loop*) + void ev_unref(ev_loop*) + void ev_break(ev_loop*, int) + unsigned int ev_pending_count(ev_loop*) + + ev_loop* gevent_ev_default_loop(unsigned int flags) + void gevent_install_sigchld_handler() + void gevent_reset_sigchld_handler() diff --git a/python/gevent/libev/libev_vfd.h b/python/gevent/libev/libev_vfd.h new file mode 100644 index 0000000..ec16a28 --- /dev/null +++ b/python/gevent/libev/libev_vfd.h @@ -0,0 +1,223 @@ +#ifdef _WIN32 +#ifdef _WIN64 +typedef PY_LONG_LONG vfd_socket_t; +#define vfd_socket_object PyLong_FromLongLong +#else +typedef long vfd_socket_t; +#define vfd_socket_object PyInt_FromLong +#endif +#ifdef LIBEV_EMBED +/* + * If libev on win32 is embedded, then we can use an + * arbitrary mapping between integer fds and OS + * handles. Then by defining special macros libev + * will use our functions. + */ + +#define WIN32_LEAN_AND_MEAN +#include <winsock2.h> +#include <windows.h> + +typedef struct vfd_entry_t +{ + vfd_socket_t handle; /* OS handle, i.e. SOCKET */ + int count; /* Reference count, 0 if free */ + int next; /* Next free fd, -1 if last */ +} vfd_entry; + +#define VFD_INCREMENT 128 +static int vfd_num = 0; /* num allocated fds */ +static int vfd_max = 0; /* max allocated fds */ +static int vfd_next = -1; /* next free fd for reuse */ +static PyObject* vfd_map = NULL; /* map OS handle -> virtual fd */ +static vfd_entry* vfd_entries = NULL; /* list of virtual fd entries */ + +#ifdef WITH_THREAD +static CRITICAL_SECTION* volatile vfd_lock = NULL; +static CRITICAL_SECTION* vfd_make_lock() +{ + if (vfd_lock == NULL) { + /* must use malloc and not PyMem_Malloc here */ + CRITICAL_SECTION* lock = malloc(sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(lock); + if (InterlockedCompareExchangePointer(&vfd_lock, lock, NULL) != NULL) { + /* another thread initialized lock first */ + DeleteCriticalSection(lock); + free(lock); + } + } + return vfd_lock; +} +#define VFD_LOCK_ENTER EnterCriticalSection(vfd_make_lock()) +#define VFD_LOCK_LEAVE LeaveCriticalSection(vfd_lock) +#define VFD_GIL_DECLARE PyGILState_STATE ___save +#define VFD_GIL_ENSURE ___save = PyGILState_Ensure() +#define VFD_GIL_RELEASE PyGILState_Release(___save) +#else +#define VFD_LOCK_ENTER +#define VFD_LOCK_LEAVE +#define VFD_GIL_DECLARE +#define VFD_GIL_ENSURE +#define VFD_GIL_RELEASE +#endif + +/* + * Given a virtual fd returns an OS handle or -1 + * This function is speed critical, so it cannot use GIL + */ +static vfd_socket_t vfd_get(int fd) +{ + int handle = -1; + VFD_LOCK_ENTER; + if (vfd_entries != NULL && fd >= 0 && fd < vfd_num) + handle = vfd_entries[fd].handle; + VFD_LOCK_LEAVE; + return handle; +} + +#define EV_FD_TO_WIN32_HANDLE(fd) vfd_get((fd)) + +/* + * Given an OS handle finds or allocates a virtual fd + * Returns -1 on failure and sets Python exception if pyexc is non-zero + */ +static int vfd_open_(vfd_socket_t handle, int pyexc) +{ + VFD_GIL_DECLARE; + int fd = -1; + unsigned long arg; + PyObject* key = NULL; + PyObject* value; + + if (!pyexc) { + VFD_GIL_ENSURE; + } + if (ioctlsocket(handle, FIONREAD, &arg) != 0) { + if (pyexc) + PyErr_Format(PyExc_IOError, +#ifdef _WIN64 + "%lld is not a socket (files are not supported)", +#else + "%ld is not a socket (files are not supported)", +#endif + handle); + goto done; + } + if (vfd_map == NULL) { + vfd_map = PyDict_New(); + if (vfd_map == NULL) + goto done; + } + key = vfd_socket_object(handle); + /* check if it's already in the dict */ + value = PyDict_GetItem(vfd_map, key); + if (value != NULL) { + /* is it safe to use PyInt_AS_LONG(value) here? */ + fd = PyInt_AsLong(value); + if (fd >= 0) { + ++vfd_entries[fd].count; + goto done; + } + } + /* use the free entry, if available */ + if (vfd_next >= 0) { + fd = vfd_next; + vfd_next = vfd_entries[fd].next; + VFD_LOCK_ENTER; + goto allocated; + } + /* check if it would be out of bounds */ + if (vfd_num >= FD_SETSIZE) { + /* libev's select doesn't support more that FD_SETSIZE fds */ + if (pyexc) + PyErr_Format(PyExc_IOError, "cannot watch more than %d sockets", (int)FD_SETSIZE); + goto done; + } + /* allocate more space if needed */ + VFD_LOCK_ENTER; + if (vfd_num >= vfd_max) { + int newsize = vfd_max + VFD_INCREMENT; + vfd_entry* entries = PyMem_Realloc(vfd_entries, sizeof(vfd_entry) * newsize); + if (entries == NULL) { + VFD_LOCK_LEAVE; + if (pyexc) + PyErr_NoMemory(); + goto done; + } + vfd_entries = entries; + vfd_max = newsize; + } + fd = vfd_num++; +allocated: + /* vfd_lock must be acquired when entering here */ + vfd_entries[fd].handle = handle; + vfd_entries[fd].count = 1; + VFD_LOCK_LEAVE; + value = PyInt_FromLong(fd); + PyDict_SetItem(vfd_map, key, value); + Py_DECREF(value); +done: + Py_XDECREF(key); + if (!pyexc) { + VFD_GIL_RELEASE; + } + return fd; +} + +#define vfd_open(fd) vfd_open_((fd), 1) +#define EV_WIN32_HANDLE_TO_FD(handle) vfd_open_((handle), 0) + +static void vfd_free_(int fd, int needclose) +{ + VFD_GIL_DECLARE; + PyObject* key; + + if (needclose) { + VFD_GIL_ENSURE; + } + if (fd < 0 || fd >= vfd_num) + goto done; /* out of bounds */ + if (vfd_entries[fd].count <= 0) + goto done; /* free entry, ignore */ + if (!--vfd_entries[fd].count) { + /* fd has just been freed */ + vfd_socket_t handle = vfd_entries[fd].handle; + vfd_entries[fd].handle = -1; + vfd_entries[fd].next = vfd_next; + vfd_next = fd; + if (needclose) + closesocket(handle); + /* vfd_map is assumed to be != NULL */ + key = vfd_socket_object(handle); + PyDict_DelItem(vfd_map, key); + Py_DECREF(key); + } +done: + if (needclose) { + VFD_GIL_RELEASE; + } +} + +#define vfd_free(fd) vfd_free_((fd), 0) +#define EV_WIN32_CLOSE_FD(fd) vfd_free_((fd), 1) + +#else +/* + * If libev on win32 is not embedded in gevent, then + * the only way to map vfds is to use the default of + * using runtime fds in libev. Note that it will leak + * fds, because there's no way of closing them safely + */ +#define vfd_get(fd) _get_osfhandle((fd)) +#define vfd_open(fd) _open_osfhandle((fd), 0) +#define vfd_free(fd) +#endif +#else +/* + * On non-win32 platforms vfd_* are noop macros + */ +typedef int vfd_socket_t; +#define vfd_get(fd) (fd) +#define vfd_open(fd) ((int)(fd)) +#define vfd_free(fd) +#endif diff --git a/python/gevent/libev/stathelper.c b/python/gevent/libev/stathelper.c new file mode 100644 index 0000000..1a70b55 --- /dev/null +++ b/python/gevent/libev/stathelper.c @@ -0,0 +1,187 @@ +/* copied from Python-2.7.2/Modules/posixmodule.c */ +#include "structseq.h" + +#define STRUCT_STAT struct stat + +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE +#define ST_BLKSIZE_IDX 13 +#else +#define ST_BLKSIZE_IDX 12 +#endif + +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS +#define ST_BLOCKS_IDX (ST_BLKSIZE_IDX+1) +#else +#define ST_BLOCKS_IDX ST_BLKSIZE_IDX +#endif + +#ifdef HAVE_STRUCT_STAT_ST_RDEV +#define ST_RDEV_IDX (ST_BLOCKS_IDX+1) +#else +#define ST_RDEV_IDX ST_BLOCKS_IDX +#endif + +#ifdef HAVE_STRUCT_STAT_ST_FLAGS +#define ST_FLAGS_IDX (ST_RDEV_IDX+1) +#else +#define ST_FLAGS_IDX ST_RDEV_IDX +#endif + +#ifdef HAVE_STRUCT_STAT_ST_GEN +#define ST_GEN_IDX (ST_FLAGS_IDX+1) +#else +#define ST_GEN_IDX ST_FLAGS_IDX +#endif + +#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME +#define ST_BIRTHTIME_IDX (ST_GEN_IDX+1) +#else +#define ST_BIRTHTIME_IDX ST_GEN_IDX +#endif + + + +static PyObject* posixmodule = NULL; +static PyTypeObject* pStatResultType = NULL; + + +static PyObject* import_posixmodule(void) +{ + if (!posixmodule) { + posixmodule = PyImport_ImportModule("posix"); + } + return posixmodule; +} + + +static PyObject* import_StatResultType(void) +{ + PyObject* p = NULL; + if (!pStatResultType) { + PyObject* module; + module = import_posixmodule(); + if (module) { + p = PyObject_GetAttrString(module, "stat_result"); + } + } + return p; +} + +static void +fill_time(PyObject *v, int index, time_t sec, unsigned long nsec) +{ + PyObject *fval,*ival; +#if SIZEOF_TIME_T > SIZEOF_LONG + ival = PyLong_FromLongLong((PY_LONG_LONG)sec); +#else + ival = PyInt_FromLong((long)sec); +#endif + if (!ival) + return; + fval = PyFloat_FromDouble(sec + 1e-9*nsec); + PyStructSequence_SET_ITEM(v, index, ival); + PyStructSequence_SET_ITEM(v, index+3, fval); +} + +/* pack a system stat C structure into the Python stat tuple + (used by posix_stat() and posix_fstat()) */ +static PyObject* +_pystat_fromstructstat(STRUCT_STAT *st) +{ + unsigned long ansec, mnsec, cnsec; + PyObject *v; + + PyTypeObject* StatResultType = (PyTypeObject*)import_StatResultType(); + if (StatResultType == NULL) { + return NULL; + } + + v = PyStructSequence_New(StatResultType); + if (v == NULL) + return NULL; + + PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st->st_mode)); +#ifdef HAVE_LARGEFILE_SUPPORT + PyStructSequence_SET_ITEM(v, 1, + PyLong_FromLongLong((PY_LONG_LONG)st->st_ino)); +#else + PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino)); +#endif +#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) + PyStructSequence_SET_ITEM(v, 2, + PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); +#else + PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev)); +#endif + PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink)); + PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid)); + PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid)); +#ifdef HAVE_LARGEFILE_SUPPORT + PyStructSequence_SET_ITEM(v, 6, + PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); +#else + PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st->st_size)); +#endif + +#if defined(HAVE_STAT_TV_NSEC) + ansec = st->st_atim.tv_nsec; + mnsec = st->st_mtim.tv_nsec; + cnsec = st->st_ctim.tv_nsec; +#elif defined(HAVE_STAT_TV_NSEC2) + ansec = st->st_atimespec.tv_nsec; + mnsec = st->st_mtimespec.tv_nsec; + cnsec = st->st_ctimespec.tv_nsec; +#elif defined(HAVE_STAT_NSEC) + ansec = st->st_atime_nsec; + mnsec = st->st_mtime_nsec; + cnsec = st->st_ctime_nsec; +#else + ansec = mnsec = cnsec = 0; +#endif + fill_time(v, 7, st->st_atime, ansec); + fill_time(v, 8, st->st_mtime, mnsec); + fill_time(v, 9, st->st_ctime, cnsec); + +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE + PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX, + PyInt_FromLong((long)st->st_blksize)); +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS + PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX, + PyInt_FromLong((long)st->st_blocks)); +#endif +#ifdef HAVE_STRUCT_STAT_ST_RDEV + PyStructSequence_SET_ITEM(v, ST_RDEV_IDX, + PyInt_FromLong((long)st->st_rdev)); +#endif +#ifdef HAVE_STRUCT_STAT_ST_GEN + PyStructSequence_SET_ITEM(v, ST_GEN_IDX, + PyInt_FromLong((long)st->st_gen)); +#endif +#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME + { + PyObject *val; + unsigned long bsec,bnsec; + bsec = (long)st->st_birthtime; +#ifdef HAVE_STAT_TV_NSEC2 + bnsec = st->st_birthtimespec.tv_nsec; +#else + bnsec = 0; +#endif + val = PyFloat_FromDouble(bsec + 1e-9*bnsec); + PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX, + val); + } +#endif +#ifdef HAVE_STRUCT_STAT_ST_FLAGS + PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX, + PyInt_FromLong((long)st->st_flags)); +#endif + + if (PyErr_Occurred()) { + Py_DECREF(v); + return NULL; + } + + return v; +} diff --git a/python/gevent/local.py b/python/gevent/local.py new file mode 100644 index 0000000..955c320 --- /dev/null +++ b/python/gevent/local.py @@ -0,0 +1,293 @@ +""" +Greenlet-local objects. + +This module is based on `_threading_local.py`__ from the standard +library of Python 3.4. + +__ https://github.com/python/cpython/blob/3.4/Lib/_threading_local.py + +Greenlet-local objects support the management of greenlet-local data. +If you have data that you want to be local to a greenlet, simply create +a greenlet-local object and use its attributes: + + >>> mydata = local() + >>> mydata.number = 42 + >>> mydata.number + 42 + +You can also access the local-object's dictionary: + + >>> mydata.__dict__ + {'number': 42} + >>> mydata.__dict__.setdefault('widgets', []) + [] + >>> mydata.widgets + [] + +What's important about greenlet-local objects is that their data are +local to a greenlet. If we access the data in a different greenlet: + + >>> log = [] + >>> def f(): + ... items = list(mydata.__dict__.items()) + ... items.sort() + ... log.append(items) + ... mydata.number = 11 + ... log.append(mydata.number) + >>> greenlet = gevent.spawn(f) + >>> greenlet.join() + >>> log + [[], 11] + +we get different data. Furthermore, changes made in the other greenlet +don't affect data seen in this greenlet: + + >>> mydata.number + 42 + +Of course, values you get from a local object, including a __dict__ +attribute, are for whatever greenlet was current at the time the +attribute was read. For that reason, you generally don't want to save +these values across greenlets, as they apply only to the greenlet they +came from. + +You can create custom local objects by subclassing the local class: + + >>> class MyLocal(local): + ... number = 2 + ... initialized = False + ... def __init__(self, **kw): + ... if self.initialized: + ... raise SystemError('__init__ called too many times') + ... self.initialized = True + ... self.__dict__.update(kw) + ... def squared(self): + ... return self.number ** 2 + +This can be useful to support default values, methods and +initialization. Note that if you define an __init__ method, it will be +called each time the local object is used in a separate greenlet. This +is necessary to initialize each greenlet's dictionary. + +Now if we create a local object: + + >>> mydata = MyLocal(color='red') + +Now we have a default number: + + >>> mydata.number + 2 + +an initial color: + + >>> mydata.color + 'red' + >>> del mydata.color + +And a method that operates on the data: + + >>> mydata.squared() + 4 + +As before, we can access the data in a separate greenlet: + + >>> log = [] + >>> greenlet = gevent.spawn(f) + >>> greenlet.join() + >>> log + [[('color', 'red'), ('initialized', True)], 11] + +without affecting this greenlet's data: + + >>> mydata.number + 2 + >>> mydata.color + Traceback (most recent call last): + ... + AttributeError: 'MyLocal' object has no attribute 'color' + +Note that subclasses can define slots, but they are not greenlet +local. They are shared across greenlets:: + + >>> class MyLocal(local): + ... __slots__ = 'number' + + >>> mydata = MyLocal() + >>> mydata.number = 42 + >>> mydata.color = 'red' + +So, the separate greenlet: + + >>> greenlet = gevent.spawn(f) + >>> greenlet.join() + +affects what we see: + + >>> mydata.number + 11 + +>>> del mydata + +.. versionchanged:: 1.1a2 + Update the implementation to match Python 3.4 instead of Python 2.5. + This results in locals being eligible for garbage collection as soon + as their greenlet exits. + +""" + +from copy import copy +from weakref import ref +from contextlib import contextmanager +from gevent.hub import getcurrent +from gevent._compat import PYPY +from gevent.lock import RLock + +__all__ = ["local"] + + +class _wrefdict(dict): + """A dict that can be weak referenced""" + + +class _localimpl(object): + """A class managing thread-local dicts""" + __slots__ = 'key', 'dicts', 'localargs', 'locallock', '__weakref__' + + def __init__(self): + # The key used in the Thread objects' attribute dicts. + # We keep it a string for speed but make it unlikely to clash with + # a "real" attribute. + self.key = '_threading_local._localimpl.' + str(id(self)) + # { id(Thread) -> (ref(Thread), thread-local dict) } + self.dicts = _wrefdict() + + def get_dict(self): + """Return the dict for the current thread. Raises KeyError if none + defined.""" + thread = getcurrent() + return self.dicts[id(thread)][1] + + def create_dict(self): + """Create a new dict for the current thread, and return it.""" + localdict = {} + key = self.key + thread = getcurrent() + idt = id(thread) + + # If we are working with a gevent.greenlet.Greenlet, we can + # pro-actively clear out with a link. Use rawlink to avoid + # spawning any more greenlets + try: + rawlink = thread.rawlink + except AttributeError: + # Otherwise we need to do it with weak refs + def local_deleted(_, key=key): + # When the localimpl is deleted, remove the thread attribute. + thread = wrthread() + if thread is not None: + del thread.__dict__[key] + + def thread_deleted(_, idt=idt): + # When the thread is deleted, remove the local dict. + # Note that this is suboptimal if the thread object gets + # caught in a reference loop. We would like to be called + # as soon as the OS-level thread ends instead. + _local = wrlocal() + if _local is not None: + _local.dicts.pop(idt, None) + wrlocal = ref(self, local_deleted) + wrthread = ref(thread, thread_deleted) + thread.__dict__[key] = wrlocal + else: + wrdicts = ref(self.dicts) + + def clear(_): + dicts = wrdicts() + if dicts: + dicts.pop(idt, None) + rawlink(clear) + wrthread = None + + self.dicts[idt] = wrthread, localdict + return localdict + + +@contextmanager +def _patch(self): + impl = object.__getattribute__(self, '_local__impl') + orig_dct = object.__getattribute__(self, '__dict__') + try: + dct = impl.get_dict() + except KeyError: + # it's OK to acquire the lock here and not earlier, because the above code won't switch out + # however, subclassed __init__ might switch, so we do need to acquire the lock here + dct = impl.create_dict() + args, kw = impl.localargs + with impl.locallock: + self.__init__(*args, **kw) + with impl.locallock: + object.__setattr__(self, '__dict__', dct) + yield + object.__setattr__(self, '__dict__', orig_dct) + + +class local(object): + """ + An object whose attributes are greenlet-local. + """ + __slots__ = '_local__impl', '__dict__' + + def __new__(cls, *args, **kw): + if args or kw: + if (PYPY and cls.__init__ == object.__init__) or (not PYPY and cls.__init__ is object.__init__): + raise TypeError("Initialization arguments are not supported") + self = object.__new__(cls) + impl = _localimpl() + impl.localargs = (args, kw) + impl.locallock = RLock() + object.__setattr__(self, '_local__impl', impl) + # We need to create the thread dict in anticipation of + # __init__ being called, to make sure we don't call it + # again ourselves. + impl.create_dict() + return self + + def __getattribute__(self, name): + with _patch(self): + return object.__getattribute__(self, name) + + def __setattr__(self, name, value): + if name == '__dict__': + raise AttributeError( + "%r object attribute '__dict__' is read-only" + % self.__class__.__name__) + with _patch(self): + return object.__setattr__(self, name, value) + + def __delattr__(self, name): + if name == '__dict__': + raise AttributeError( + "%r object attribute '__dict__' is read-only" + % self.__class__.__name__) + with _patch(self): + return object.__delattr__(self, name) + + def __copy__(self): + impl = object.__getattribute__(self, '_local__impl') + current = getcurrent() + currentId = id(current) + d = impl.get_dict() + duplicate = copy(d) + + cls = type(self) + if (PYPY and cls.__init__ != object.__init__) or (not PYPY and cls.__init__ is not object.__init__): + args, kw = impl.localargs + instance = cls(*args, **kw) + else: + instance = cls() + + new_impl = object.__getattribute__(instance, '_local__impl') + tpl = new_impl.dicts[currentId] + new_impl.dicts[currentId] = (tpl[0], duplicate) + + return instance diff --git a/python/gevent/lock.py b/python/gevent/lock.py new file mode 100644 index 0000000..506d8c5 --- /dev/null +++ b/python/gevent/lock.py @@ -0,0 +1,260 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +"""Locking primitives""" +from __future__ import absolute_import + +from gevent.hub import getcurrent +from gevent._compat import PYPY +from gevent._semaphore import Semaphore, BoundedSemaphore # pylint:disable=no-name-in-module,import-error + + +__all__ = [ + 'Semaphore', + 'DummySemaphore', + 'BoundedSemaphore', + 'RLock', +] + +# On PyPy, we don't compile the Semaphore class with Cython. Under +# Cython, each individual method holds the GIL for its entire +# duration, ensuring that no other thread can interrupt us in an +# unsafe state (only when we _do_wait do we call back into Python and +# allow switching threads). Simulate that here through the use of a manual +# lock. (We use a separate lock for each semaphore to allow sys.settrace functions +# to use locks *other* than the one being traced.) +if PYPY: + # TODO: Need to use monkey.get_original? + try: + from _thread import allocate_lock as _allocate_lock # pylint:disable=import-error,useless-suppression + from _thread import get_ident as _get_ident # pylint:disable=import-error,useless-suppression + except ImportError: + # Python 2 + from thread import allocate_lock as _allocate_lock # pylint:disable=import-error,useless-suppression + from thread import get_ident as _get_ident # pylint:disable=import-error,useless-suppression + _sem_lock = _allocate_lock() + + def untraceable(f): + # Don't allow re-entry to these functions in a single thread, as can + # happen if a sys.settrace is used + def wrapper(self): + me = _get_ident() + try: + count = self._locking[me] + except KeyError: + count = self._locking[me] = 1 + else: + count = self._locking[me] = count + 1 + if count: + return + + try: + return f(self) + finally: + count = count - 1 + if not count: + del self._locking[me] + else: + self._locking[me] = count + return wrapper + + class _OwnedLock(object): + + def __init__(self): + self._owner = None + self._block = _allocate_lock() + self._locking = {} + self._count = 0 + + @untraceable + def acquire(self): + me = _get_ident() + if self._owner == me: + self._count += 1 + return + + self._owner = me + self._block.acquire() + self._count = 1 + + @untraceable + def release(self): + self._count = count = self._count - 1 + if not count: + self._block.release() + self._owner = None + + # acquire, wait, and release all acquire the lock on entry and release it + # on exit. acquire and wait can call _do_wait, which must release it on entry + # and re-acquire it for them on exit. + class _around(object): + __slots__ = ('before', 'after') + + def __init__(self, before, after): + self.before = before + self.after = after + + def __enter__(self): + self.before() + + def __exit__(self, t, v, tb): + self.after() + + def _decorate(func, cmname): + # functools.wrap? + def wrapped(self, *args, **kwargs): + with getattr(self, cmname): + return func(self, *args, **kwargs) + return wrapped + + Semaphore._py3k_acquire = Semaphore.acquire = _decorate(Semaphore.acquire, '_lock_locked') + Semaphore.release = _decorate(Semaphore.release, '_lock_locked') + Semaphore.wait = _decorate(Semaphore.wait, '_lock_locked') + Semaphore._do_wait = _decorate(Semaphore._do_wait, '_lock_unlocked') + + _Sem_init = Semaphore.__init__ + + def __init__(self, *args, **kwargs): + l = self._lock_lock = _OwnedLock() + self._lock_locked = _around(l.acquire, l.release) + self._lock_unlocked = _around(l.release, l.acquire) + + _Sem_init(self, *args, **kwargs) + + Semaphore.__init__ = __init__ + + del _decorate + del untraceable + + +class DummySemaphore(object): + """ + DummySemaphore(value=None) -> DummySemaphore + + A Semaphore initialized with "infinite" initial value. None of its + methods ever block. + + This can be used to parameterize on whether or not to actually + guard access to a potentially limited resource. If the resource is + actually limited, such as a fixed-size thread pool, use a real + :class:`Semaphore`, but if the resource is unbounded, use an + instance of this class. In that way none of the supporting code + needs to change. + + Similarly, it can be used to parameterize on whether or not to + enforce mutual exclusion to some underlying object. If the + underlying object is known to be thread-safe itself mutual + exclusion is not needed and a ``DummySemaphore`` can be used, but + if that's not true, use a real ``Semaphore``. + """ + + # Internally this is used for exactly the purpose described in the + # documentation. gevent.pool.Pool uses it instead of a Semaphore + # when the pool size is unlimited, and + # gevent.fileobject.FileObjectThread takes a parameter that + # determines whether it should lock around IO to the underlying + # file object. + + def __init__(self, value=None): + """ + .. versionchanged:: 1.1rc3 + Accept and ignore a *value* argument for compatibility with Semaphore. + """ + pass + + def __str__(self): + return '<%s>' % self.__class__.__name__ + + def locked(self): + """A DummySemaphore is never locked so this always returns False.""" + return False + + def release(self): + """Releasing a dummy semaphore does nothing.""" + pass + + def rawlink(self, callback): + # XXX should still work and notify? + pass + + def unlink(self, callback): + pass + + def wait(self, timeout=None): + """Waiting for a DummySemaphore returns immediately.""" + pass + + def acquire(self, blocking=True, timeout=None): + """ + A DummySemaphore can always be acquired immediately so this always + returns True and ignores its arguments. + + .. versionchanged:: 1.1a1 + Always return *true*. + """ + # pylint:disable=unused-argument + return True + + def __enter__(self): + pass + + def __exit__(self, typ, val, tb): + pass + + +class RLock(object): + + def __init__(self): + self._block = Semaphore(1) + self._owner = None + self._count = 0 + + def __repr__(self): + return "<%s at 0x%x _block=%s _count=%r _owner=%r)>" % ( + self.__class__.__name__, + id(self), + self._block, + self._count, + self._owner) + + def acquire(self, blocking=1): + me = getcurrent() + if self._owner is me: + self._count = self._count + 1 + return 1 + rc = self._block.acquire(blocking) + if rc: + self._owner = me + self._count = 1 + return rc + + def __enter__(self): + return self.acquire() + + def release(self): + if self._owner is not getcurrent(): + raise RuntimeError("cannot release un-aquired lock") + self._count = count = self._count - 1 + if not count: + self._owner = None + self._block.release() + + def __exit__(self, typ, value, tb): + self.release() + + # Internal methods used by condition variables + + def _acquire_restore(self, count_owner): + count, owner = count_owner + self._block.acquire() + self._count = count + self._owner = owner + + def _release_save(self): + count = self._count + self._count = 0 + owner = self._owner + self._owner = None + self._block.release() + return (count, owner) + + def _is_owned(self): + return self._owner is getcurrent() diff --git a/python/gevent/monkey.py b/python/gevent/monkey.py new file mode 100644 index 0000000..1f04455 --- /dev/null +++ b/python/gevent/monkey.py @@ -0,0 +1,702 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +# pylint: disable=redefined-outer-name +""" +Make the standard library cooperative. + +Patching +======== + +The primary purpose of this module is to carefully patch, in place, +portions of the standard library with gevent-friendly functions that +behave in the same way as the original (at least as closely as possible). + +The primary interface to this is the :func:`patch_all` function, which +performs all the available patches. It accepts arguments to limit the +patching to certain modules, but most programs **should** use the +default values as they receive the most wide-spread testing, and some monkey +patches have dependencies on others. + +Patching **should be done as early as possible** in the lifecycle of the +program. For example, the main module (the one that tests against +``__main__`` or is otherwise the first imported) should begin with +this code, ideally before any other imports:: + + from gevent import monkey + monkey.patch_all() + +.. tip:: + + Some frameworks, such as gunicorn, handle monkey-patching for you. + Check their documentation to be sure. + +Querying +-------- + +Sometimes it is helpful to know if objects have been monkey-patched, and in +advanced cases even to have access to the original standard library functions. This +module provides functions for that purpose. + +- :func:`is_module_patched` +- :func:`is_object_patched` +- :func:`get_original` + +Use as a module +=============== + +Sometimes it is useful to run existing python scripts or modules that +were not built to be gevent aware under gevent. To do so, this module +can be run as the main module, passing the script and its arguments. +For details, see the :func:`main` function. + +Functions +========= +""" +from __future__ import absolute_import +from __future__ import print_function +import sys + +__all__ = [ + 'patch_all', + 'patch_builtins', + 'patch_dns', + 'patch_os', + 'patch_select', + 'patch_signal', + 'patch_socket', + 'patch_ssl', + 'patch_subprocess', + 'patch_sys', + 'patch_thread', + 'patch_time', + # query functions + 'get_original', + 'is_module_patched', + 'is_object_patched', + # module functions + 'main', +] + + +if sys.version_info[0] >= 3: + string_types = (str,) + PY3 = True +else: + import __builtin__ # pylint:disable=import-error + string_types = (__builtin__.basestring,) + PY3 = False + +WIN = sys.platform.startswith("win") + +# maps module name -> {attribute name: original item} +# e.g. "time" -> {"sleep": built-in function sleep} +saved = {} + + +def is_module_patched(modname): + """Check if a module has been replaced with a cooperative version.""" + return modname in saved + + +def is_object_patched(modname, objname): + """Check if an object in a module has been replaced with a cooperative version.""" + return is_module_patched(modname) and objname in saved[modname] + + +def _get_original(name, items): + d = saved.get(name, {}) + values = [] + module = None + for item in items: + if item in d: + values.append(d[item]) + else: + if module is None: + module = __import__(name) + values.append(getattr(module, item)) + return values + + +def get_original(mod_name, item_name): + """Retrieve the original object from a module. + + If the object has not been patched, then that object will still be retrieved. + + :param item_name: A string or sequence of strings naming the attribute(s) on the module + ``mod_name`` to return. + :return: The original value if a string was given for ``item_name`` or a sequence + of original values if a sequence was passed. + """ + if isinstance(item_name, string_types): + return _get_original(mod_name, [item_name])[0] + return _get_original(mod_name, item_name) + +_NONE = object() + + +def patch_item(module, attr, newitem): + olditem = getattr(module, attr, _NONE) + if olditem is not _NONE: + saved.setdefault(module.__name__, {}).setdefault(attr, olditem) + setattr(module, attr, newitem) + + +def remove_item(module, attr): + olditem = getattr(module, attr, _NONE) + if olditem is _NONE: + return + saved.setdefault(module.__name__, {}).setdefault(attr, olditem) + delattr(module, attr) + + +def patch_module(name, items=None): + gevent_module = getattr(__import__('gevent.' + name), name) + module_name = getattr(gevent_module, '__target__', name) + module = __import__(module_name) + if items is None: + items = getattr(gevent_module, '__implements__', None) + if items is None: + raise AttributeError('%r does not have __implements__' % gevent_module) + for attr in items: + patch_item(module, attr, getattr(gevent_module, attr)) + return module + + +def _queue_warning(message, _warnings): + # Queues a warning to show after the monkey-patching process is all done. + # Done this way to avoid extra imports during the process itself, just + # in case. If we're calling a function one-off (unusual) go ahead and do it + if _warnings is None: + _process_warnings([message]) + else: + _warnings.append(message) + + +def _process_warnings(_warnings): + import warnings + for warning in _warnings: + warnings.warn(warning, RuntimeWarning, stacklevel=3) + + +def _patch_sys_std(name): + from gevent.fileobject import FileObjectThread + orig = getattr(sys, name) + if not isinstance(orig, FileObjectThread): + patch_item(sys, name, FileObjectThread(orig)) + + +def patch_sys(stdin=True, stdout=True, stderr=True): + """Patch sys.std[in,out,err] to use a cooperative IO via a threadpool. + + This is relatively dangerous and can have unintended consequences such as hanging + the process or `misinterpreting control keys`_ when ``input`` and ``raw_input`` + are used. + + This method does nothing on Python 3. The Python 3 interpreter wants to flush + the TextIOWrapper objects that make up stderr/stdout at shutdown time, but + using a threadpool at that time leads to a hang. + + .. _`misinterpreting control keys`: https://github.com/gevent/gevent/issues/274 + """ + # test__issue6.py demonstrates the hang if these lines are removed; + # strangely enough that test passes even without monkey-patching sys + if PY3: + return + + if stdin: + _patch_sys_std('stdin') + if stdout: + _patch_sys_std('stdout') + if stderr: + _patch_sys_std('stderr') + + +def patch_os(): + """ + Replace :func:`os.fork` with :func:`gevent.fork`, and, on POSIX, + :func:`os.waitpid` with :func:`gevent.os.waitpid` (if the + environment variable ``GEVENT_NOWAITPID`` is not defined). Does + nothing if fork is not available. + + .. caution:: This method must be used with :func:`patch_signal` to have proper SIGCHLD + handling and thus correct results from ``waitpid``. + :func:`patch_all` calls both by default. + + .. caution:: For SIGCHLD handling to work correctly, the event loop must run. + The easiest way to help ensure this is to use :func:`patch_all`. + """ + patch_module('os') + + +def patch_time(): + """Replace :func:`time.sleep` with :func:`gevent.sleep`.""" + from gevent.hub import sleep + import time + patch_item(time, 'sleep', sleep) + + +def _patch_existing_locks(threading): + if len(list(threading.enumerate())) != 1: + return + try: + tid = threading.get_ident() + except AttributeError: + tid = threading._get_ident() + rlock_type = type(threading.RLock()) + try: + import importlib._bootstrap + except ImportError: + class _ModuleLock(object): + pass + else: + _ModuleLock = importlib._bootstrap._ModuleLock # python 2 pylint: disable=no-member + # It might be possible to walk up all the existing stack frames to find + # locked objects...at least if they use `with`. To be sure, we look at every object + # Since we're supposed to be done very early in the process, there shouldn't be + # too many. + + # By definition there's only one thread running, so the various + # owner attributes were the old (native) thread id. Make it our + # current greenlet id so that when it wants to unlock and compare + # self.__owner with _get_ident(), they match. + gc = __import__('gc') + for o in gc.get_objects(): + if isinstance(o, rlock_type): + if hasattr(o, '_owner'): # Py3 + if o._owner is not None: + o._owner = tid + else: + if o._RLock__owner is not None: + o._RLock__owner = tid + elif isinstance(o, _ModuleLock): + if o.owner is not None: + o.owner = tid + + +def patch_thread(threading=True, _threading_local=True, Event=False, logging=True, + existing_locks=True, + _warnings=None): + """ + Replace the standard :mod:`thread` module to make it greenlet-based. + + - If *threading* is true (the default), also patch ``threading``. + - If *_threading_local* is true (the default), also patch ``_threading_local.local``. + - If *logging* is True (the default), also patch locks taken if the logging module has + been configured. + - If *existing_locks* is True (the default), and the process is still single threaded, + make sure than any :class:`threading.RLock` (and, under Python 3, :class:`importlib._bootstrap._ModuleLock`) + instances that are currently locked can be properly unlocked. + + .. caution:: + Monkey-patching :mod:`thread` and using + :class:`multiprocessing.Queue` or + :class:`concurrent.futures.ProcessPoolExecutor` (which uses a + ``Queue``) will hang the process. + + .. versionchanged:: 1.1b1 + Add *logging* and *existing_locks* params. + """ + # XXX: Simplify + # pylint:disable=too-many-branches,too-many-locals + + # Description of the hang: + # There is an incompatibility with patching 'thread' and the 'multiprocessing' module: + # The problem is that multiprocessing.queues.Queue uses a half-duplex multiprocessing.Pipe, + # which is implemented with os.pipe() and _multiprocessing.Connection. os.pipe isn't patched + # by gevent, as it returns just a fileno. _multiprocessing.Connection is an internal implementation + # class implemented in C, which exposes a 'poll(timeout)' method; under the covers, this issues a + # (blocking) select() call: hence the need for a real thread. Except for that method, we could + # almost replace Connection with gevent.fileobject.SocketAdapter, plus a trivial + # patch to os.pipe (below). Sigh, so close. (With a little work, we could replicate that method) + + # import os + # import fcntl + # os_pipe = os.pipe + # def _pipe(): + # r, w = os_pipe() + # fcntl.fcntl(r, fcntl.F_SETFL, os.O_NONBLOCK) + # fcntl.fcntl(w, fcntl.F_SETFL, os.O_NONBLOCK) + # return r, w + # os.pipe = _pipe + + # The 'threading' module copies some attributes from the + # thread module the first time it is imported. If we patch 'thread' + # before that happens, then we store the wrong values in 'saved', + # So if we're going to patch threading, we either need to import it + # before we patch thread, or manually clean up the attributes that + # are in trouble. The latter is tricky because of the different names + # on different versions. + if threading: + threading_mod = __import__('threading') + # Capture the *real* current thread object before + # we start returning DummyThread objects, for comparison + # to the main thread. + orig_current_thread = threading_mod.current_thread() + else: + threading_mod = None + orig_current_thread = None + + patch_module('thread') + + if threading: + patch_module('threading') + + if Event: + from gevent.event import Event + patch_item(threading_mod, 'Event', Event) + + if existing_locks: + _patch_existing_locks(threading_mod) + + if logging and 'logging' in sys.modules: + logging = __import__('logging') + patch_item(logging, '_lock', threading_mod.RLock()) + for wr in logging._handlerList: + # In py26, these are actual handlers, not weakrefs + handler = wr() if callable(wr) else wr + if handler is None: + continue + if not hasattr(handler, 'lock'): + raise TypeError("Unknown/unsupported handler %r" % handler) + handler.lock = threading_mod.RLock() + + if _threading_local: + _threading_local = __import__('_threading_local') + from gevent.local import local + patch_item(_threading_local, 'local', local) + + def make_join_func(thread, thread_greenlet): + from gevent.hub import sleep + from time import time + + def join(timeout=None): + end = None + if threading_mod.current_thread() is thread: + raise RuntimeError("Cannot join current thread") + if thread_greenlet is not None and thread_greenlet.dead: + return + if not thread.is_alive(): + return + + if timeout: + end = time() + timeout + + while thread.is_alive(): + if end is not None and time() > end: + return + sleep(0.01) + return join + + if threading: + from gevent.threading import main_native_thread + + for thread in threading_mod._active.values(): + if thread == main_native_thread(): + continue + thread.join = make_join_func(thread, None) + + if sys.version_info[:2] >= (3, 4): + + # Issue 18808 changes the nature of Thread.join() to use + # locks. This means that a greenlet spawned in the main thread + # (which is already running) cannot wait for the main thread---it + # hangs forever. We patch around this if possible. See also + # gevent.threading. + greenlet = __import__('greenlet') + + if orig_current_thread == threading_mod.main_thread(): + main_thread = threading_mod.main_thread() + _greenlet = main_thread._greenlet = greenlet.getcurrent() + + main_thread.join = make_join_func(main_thread, _greenlet) + + # Patch up the ident of the main thread to match. This + # matters if threading was imported before monkey-patching + # thread + oldid = main_thread.ident + main_thread._ident = threading_mod.get_ident() + if oldid in threading_mod._active: + threading_mod._active[main_thread.ident] = threading_mod._active[oldid] + if oldid != main_thread.ident: + del threading_mod._active[oldid] + else: + _queue_warning("Monkey-patching not on the main thread; " + "threading.main_thread().join() will hang from a greenlet", + _warnings) + + +def patch_socket(dns=True, aggressive=True): + """Replace the standard socket object with gevent's cooperative sockets. + + If ``dns`` is true, also patch dns functions in :mod:`socket`. + """ + from gevent import socket + # Note: although it seems like it's not strictly necessary to monkey patch 'create_connection', + # it's better to do it. If 'create_connection' was not monkey patched, but the rest of socket module + # was, create_connection would still use "green" getaddrinfo and "green" socket. + # However, because gevent.socket.socket.connect is a Python function, the exception raised by it causes + # _socket object to be referenced by the frame, thus causing the next invocation of bind(source_address) to fail. + if dns: + items = socket.__implements__ # pylint:disable=no-member + else: + items = set(socket.__implements__) - set(socket.__dns__) # pylint:disable=no-member + patch_module('socket', items=items) + if aggressive: + if 'ssl' not in socket.__implements__: # pylint:disable=no-member + remove_item(socket, 'ssl') + + +def patch_dns(): + """Replace DNS functions in :mod:`socket` with cooperative versions. + + This is only useful if :func:`patch_socket` has been called and is done automatically + by that method if requested. + """ + from gevent import socket + patch_module('socket', items=socket.__dns__) # pylint:disable=no-member + + +def patch_ssl(): + """Replace SSLSocket object and socket wrapping functions in :mod:`ssl` with cooperative versions. + + This is only useful if :func:`patch_socket` has been called. + """ + patch_module('ssl') + + +def patch_select(aggressive=True): + """ + Replace :func:`select.select` with :func:`gevent.select.select` + and :func:`select.poll` with :class:`gevent.select.poll` (where available). + + If ``aggressive`` is true (the default), also remove other + blocking functions from :mod:`select` and (on Python 3.4 and + above) :mod:`selectors`: + + - :func:`select.epoll` + - :func:`select.kqueue` + - :func:`select.kevent` + - :func:`select.devpoll` (Python 3.5+) + - :class:`selectors.EpollSelector` + - :class:`selectors.KqueueSelector` + - :class:`selectors.DevpollSelector` (Python 3.5+) + """ + patch_module('select') + if aggressive: + select = __import__('select') + # since these are blocking we're removing them here. This makes some other + # modules (e.g. asyncore) non-blocking, as they use select that we provide + # when none of these are available. + remove_item(select, 'epoll') + remove_item(select, 'kqueue') + remove_item(select, 'kevent') + remove_item(select, 'devpoll') + + if sys.version_info[:2] >= (3, 4): + # Python 3 wants to use `select.select` as a member function, + # leading to this error in selectors.py (because gevent.select.select is + # not a builtin and doesn't get the magic auto-static that they do) + # r, w, _ = self._select(self._readers, self._writers, [], timeout) + # TypeError: select() takes from 3 to 4 positional arguments but 5 were given + # Note that this obviously only happens if selectors was imported after we had patched + # select; but there is a code path that leads to it being imported first (but now we've + # patched select---so we can't compare them identically) + select = __import__('select') # Should be gevent-patched now + orig_select_select = get_original('select', 'select') + assert select.select is not orig_select_select + selectors = __import__('selectors') + if selectors.SelectSelector._select in (select.select, orig_select_select): + def _select(self, *args, **kwargs): # pylint:disable=unused-argument + return select.select(*args, **kwargs) + selectors.SelectSelector._select = _select + _select._gevent_monkey = True + + if aggressive: + # If `selectors` had already been imported before we removed + # select.epoll|kqueue|devpoll, these may have been defined in terms + # of those functions. They'll fail at runtime. + remove_item(selectors, 'EpollSelector') + remove_item(selectors, 'KqueueSelector') + remove_item(selectors, 'DevpollSelector') + selectors.DefaultSelector = selectors.SelectSelector + + +def patch_subprocess(): + """ + Replace :func:`subprocess.call`, :func:`subprocess.check_call`, + :func:`subprocess.check_output` and :class:`subprocess.Popen` with + :mod:`cooperative versions <gevent.subprocess>`. + + .. note:: + On Windows under Python 3, the API support may not completely match + the standard library. + + """ + patch_module('subprocess') + + +def patch_builtins(): + """ + Make the builtin __import__ function `greenlet safe`_ under Python 2. + + .. note:: + This does nothing under Python 3 as it is not necessary. Python 3 features + improved import locks that are per-module, not global. + + .. _greenlet safe: https://github.com/gevent/gevent/issues/108 + + """ + if sys.version_info[:2] < (3, 3): + patch_module('builtins') + + +def patch_signal(): + """ + Make the signal.signal function work with a monkey-patched os. + + .. caution:: This method must be used with :func:`patch_os` to have proper SIGCHLD + handling. :func:`patch_all` calls both by default. + + .. caution:: For proper SIGCHLD handling, you must yield to the event loop. + Using :func:`patch_all` is the easiest way to ensure this. + + .. seealso:: :mod:`gevent.signal` + """ + patch_module("signal") + + +def _check_repatching(**module_settings): + _warnings = [] + key = '_gevent_saved_patch_all' + if saved.get(key, module_settings) != module_settings: + _queue_warning("Patching more than once will result in the union of all True" + " parameters being patched", + _warnings) + + first_time = key not in saved + saved[key] = module_settings + return _warnings, first_time + + +def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False, + subprocess=True, sys=False, aggressive=True, Event=False, + builtins=True, signal=True): + """ + Do all of the default monkey patching (calls every other applicable + function in this module). + + .. versionchanged:: 1.1 + Issue a :mod:`warning <warnings>` if this function is called multiple times + with different arguments. The second and subsequent calls will only add more + patches, they can never remove existing patches by setting an argument to ``False``. + .. versionchanged:: 1.1 + Issue a :mod:`warning <warnings>` if this function is called with ``os=False`` + and ``signal=True``. This will cause SIGCHLD handlers to not be called. This may + be an error in the future. + """ + # pylint:disable=too-many-locals,too-many-branches + + # Check to see if they're changing the patched list + _warnings, first_time = _check_repatching(**locals()) + if not _warnings and not first_time: + # Nothing to do, identical args to what we just + # did + return + + # order is important + if os: + patch_os() + if time: + patch_time() + if thread: + patch_thread(Event=Event, _warnings=_warnings) + # sys must be patched after thread. in other cases threading._shutdown will be + # initiated to _MainThread with real thread ident + if sys: + patch_sys() + if socket: + patch_socket(dns=dns, aggressive=aggressive) + if select: + patch_select(aggressive=aggressive) + if ssl: + patch_ssl() + if httplib: + raise ValueError('gevent.httplib is no longer provided, httplib must be False') + if subprocess: + patch_subprocess() + if builtins: + patch_builtins() + if signal: + if not os: + _queue_warning('Patching signal but not os will result in SIGCHLD handlers' + ' installed after this not being called and os.waitpid may not' + ' function correctly if gevent.subprocess is used. This may raise an' + ' error in the future.', + _warnings) + patch_signal() + + _process_warnings(_warnings) + + +def main(): + args = {} + argv = sys.argv[1:] + verbose = False + script_help, patch_all_args, modules = _get_script_help() + while argv and argv[0].startswith('--'): + option = argv[0][2:] + if option == 'verbose': + verbose = True + elif option.startswith('no-') and option.replace('no-', '') in patch_all_args: + args[option[3:]] = False + elif option in patch_all_args: + args[option] = True + if option in modules: + for module in modules: + args.setdefault(module, False) + else: + sys.exit(script_help + '\n\n' + 'Cannot patch %r' % option) + del argv[0] + # TODO: break on -- + if verbose: + import pprint + import os + print('gevent.monkey.patch_all(%s)' % ', '.join('%s=%s' % item for item in args.items())) + print('sys.version=%s' % (sys.version.strip().replace('\n', ' '), )) + print('sys.path=%s' % pprint.pformat(sys.path)) + print('sys.modules=%s' % pprint.pformat(sorted(sys.modules.keys()))) + print('cwd=%s' % os.getcwd()) + + patch_all(**args) + if argv: + sys.argv = argv + __package__ = None + assert __package__ is None + globals()['__file__'] = sys.argv[0] # issue #302 + globals()['__package__'] = None # issue #975: make script be its own package + with open(sys.argv[0]) as f: + # Be sure to exec in globals to avoid import pollution. Also #975. + exec(f.read(), globals()) + else: + print(script_help) + + +def _get_script_help(): + from inspect import getargspec + patch_all_args = getargspec(patch_all)[0] # pylint:disable=deprecated-method + modules = [x for x in patch_all_args if 'patch_' + x in globals()] + script_help = """gevent.monkey - monkey patch the standard modules to use gevent. + +USAGE: python -m gevent.monkey [MONKEY OPTIONS] script [SCRIPT OPTIONS] + +If no OPTIONS present, monkey patches all the modules it can patch. +You can exclude a module with --no-module, e.g. --no-thread. You can +specify a module to patch with --module, e.g. --socket. In the latter +case only the modules specified on the command line will be patched. + +MONKEY OPTIONS: --verbose %s""" % ', '.join('--[no-]%s' % m for m in modules) + return script_help, patch_all_args, modules + +main.__doc__ = _get_script_help()[0] + +if __name__ == '__main__': + main() diff --git a/python/gevent/os.py b/python/gevent/os.py new file mode 100644 index 0000000..fffd0dc --- /dev/null +++ b/python/gevent/os.py @@ -0,0 +1,468 @@ +""" +Low-level operating system functions from :mod:`os`. + +Cooperative I/O +=============== + +This module provides cooperative versions of :func:`os.read` and +:func:`os.write`. These functions are *not* monkey-patched; you +must explicitly call them or monkey patch them yourself. + +POSIX functions +--------------- + +On POSIX, non-blocking IO is available. + +- :func:`nb_read` +- :func:`nb_write` +- :func:`make_nonblocking` + +All Platforms +------------- + +On non-POSIX platforms (e.g., Windows), non-blocking IO is not +available. On those platforms (and on POSIX), cooperative IO can +be done with the threadpool. + +- :func:`tp_read` +- :func:`tp_write` + +Child Processes +=============== + +The functions :func:`fork` and (on POSIX) :func:`forkpty` and :func:`waitpid` can be used +to manage child processes. + +.. warning:: + + Forking a process that uses greenlets does not eliminate all non-running + greenlets. Any that were scheduled in the hub of the forking thread in the parent + remain scheduled in the child; compare this to how normal threads operate. (This behaviour + may change is a subsequent major release.) +""" + +from __future__ import absolute_import + +import os +import sys +from gevent.hub import get_hub, reinit +from gevent._compat import PY3 +from gevent._util import copy_globals +import errno + +EAGAIN = getattr(errno, 'EAGAIN', 11) + +try: + import fcntl +except ImportError: + fcntl = None + +__implements__ = ['fork'] +__extensions__ = ['tp_read', 'tp_write'] + +_read = os.read +_write = os.write + + +ignored_errors = [EAGAIN, errno.EINTR] + + +if fcntl: + + __extensions__ += ['make_nonblocking', 'nb_read', 'nb_write'] + + def make_nonblocking(fd): + """Put the file descriptor *fd* into non-blocking mode if possible. + + :return: A boolean value that evaluates to True if successful.""" + flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) + if not bool(flags & os.O_NONBLOCK): + fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) + return True + + def nb_read(fd, n): + """Read up to `n` bytes from file descriptor `fd`. Return a string + containing the bytes read. If end-of-file is reached, an empty string + is returned. + + The descriptor must be in non-blocking mode. + """ + hub, event = None, None + while True: + try: + return _read(fd, n) + except OSError as e: + if e.errno not in ignored_errors: + raise + if not PY3: + sys.exc_clear() + if hub is None: + hub = get_hub() + event = hub.loop.io(fd, 1) + hub.wait(event) + + def nb_write(fd, buf): + """Write bytes from buffer `buf` to file descriptor `fd`. Return the + number of bytes written. + + The file descriptor must be in non-blocking mode. + """ + hub, event = None, None + while True: + try: + return _write(fd, buf) + except OSError as e: + if e.errno not in ignored_errors: + raise + if not PY3: + sys.exc_clear() + if hub is None: + hub = get_hub() + event = hub.loop.io(fd, 2) + hub.wait(event) + + +def tp_read(fd, n): + """Read up to *n* bytes from file descriptor *fd*. Return a string + containing the bytes read. If end-of-file is reached, an empty string + is returned. + + Reading is done using the threadpool. + """ + return get_hub().threadpool.apply(_read, (fd, n)) + + +def tp_write(fd, buf): + """Write bytes from buffer *buf* to file descriptor *fd*. Return the + number of bytes written. + + Writing is done using the threadpool. + """ + return get_hub().threadpool.apply(_write, (fd, buf)) + + +if hasattr(os, 'fork'): + # pylint:disable=function-redefined,redefined-outer-name + + _raw_fork = os.fork + + def fork_gevent(): + """ + Forks the process using :func:`os.fork` and prepares the + child process to continue using gevent before returning. + + .. note:: + + The PID returned by this function may not be waitable with + either the original :func:`os.waitpid` or this module's + :func:`waitpid` and it may not generate SIGCHLD signals if + libev child watchers are or ever have been in use. For + example, the :mod:`gevent.subprocess` module uses libev + child watchers (which parts of gevent use libev child + watchers is subject to change at any time). Most + applications should use :func:`fork_and_watch`, which is + monkey-patched as the default replacement for + :func:`os.fork` and implements the ``fork`` function of + this module by default, unless the environment variable + ``GEVENT_NOWAITPID`` is defined before this module is + imported. + + .. versionadded:: 1.1b2 + """ + result = _raw_fork() + if not result: + reinit() + return result + + def fork(): + """ + A wrapper for :func:`fork_gevent` for non-POSIX platforms. + """ + return fork_gevent() + + if hasattr(os, 'forkpty'): + _raw_forkpty = os.forkpty + + def forkpty_gevent(): + """ + Forks the process using :func:`os.forkpty` and prepares the + child process to continue using gevent before returning. + + Returns a tuple (pid, master_fd). The `master_fd` is *not* put into + non-blocking mode. + + Availability: Some Unix systems. + + .. seealso:: This function has the same limitations as :func:`fork_gevent`. + + .. versionadded:: 1.1b5 + """ + pid, master_fd = _raw_forkpty() + if not pid: + reinit() + return pid, master_fd + + forkpty = forkpty_gevent + + __implements__.append('forkpty') + __extensions__.append("forkpty_gevent") + + if hasattr(os, 'WNOWAIT') or hasattr(os, 'WNOHANG'): + # We can only do this on POSIX + import time + + _waitpid = os.waitpid + _WNOHANG = os.WNOHANG + + # replaced by the signal module. + _on_child_hook = lambda: None + + # {pid -> watcher or tuple(pid, rstatus, timestamp)} + _watched_children = {} + + def _on_child(watcher, callback): + # XXX: Could handle tracing here by not stopping + # until the pid is terminated + watcher.stop() + _watched_children[watcher.pid] = (watcher.pid, watcher.rstatus, time.time()) + if callback: + callback(watcher) + # dispatch an "event"; used by gevent.signal.signal + _on_child_hook() + # now is as good a time as any to reap children + _reap_children() + + def _reap_children(timeout=60): + # Remove all the dead children that haven't been waited on + # for the *timeout* seconds. + # Some platforms queue delivery of SIGCHLD for all children that die; + # in that case, a well-behaved application should call waitpid() for each + # signal. + # Some platforms (linux) only guarantee one delivery if multiple children + # die. On that platform, the well-behave application calls waitpid() in a loop + # until it gets back -1, indicating no more dead children need to be waited for. + # In either case, waitpid should be called the same number of times as dead children, + # thus removing all the watchers when a SIGCHLD arrives. The (generous) timeout + # is to work with applications that neglect to call waitpid and prevent "unlimited" + # growth. + # Note that we don't watch for the case of pid wraparound. That is, we fork a new + # child with the same pid as an existing watcher, but the child is already dead, + # just not waited on yet. + now = time.time() + oldest_allowed = now - timeout + dead = [pid for pid, val + in _watched_children.items() + if isinstance(val, tuple) and val[2] < oldest_allowed] + for pid in dead: + del _watched_children[pid] + + def waitpid(pid, options): + """ + Wait for a child process to finish. + + If the child process was spawned using + :func:`fork_and_watch`, then this function behaves + cooperatively. If not, it *may* have race conditions; see + :func:`fork_gevent` for more information. + + The arguments are as for the underlying + :func:`os.waitpid`. Some combinations of *options* may not + be supported cooperatively (as of 1.1 that includes + WUNTRACED). Using a *pid* of 0 to request waiting on only processes + from the current process group is not cooperative. + + Availability: POSIX. + + .. versionadded:: 1.1b1 + .. versionchanged:: 1.2a1 + More cases are handled in a cooperative manner. + """ + # XXX Does not handle tracing children + + # So long as libev's loop doesn't run, it's OK to add + # child watchers. The SIGCHLD handler only feeds events + # for the next iteration of the loop to handle. (And the + # signal handler itself is only called from the next loop + # iteration.) + + if pid <= 0: + # magic functions for multiple children. + if pid == -1: + # Any child. If we have one that we're watching and that finished, + # we will use that one. Otherwise, let the OS take care of it. + for k, v in _watched_children.items(): + if isinstance(v, tuple): + pid = k + break + if pid <= 0: + # We didn't have one that was ready. If there are + # no funky options set, and the pid was -1 + # (meaning any process, not 0, which means process + # group--- libev doesn't know about process + # groups) then we can use a child watcher of pid 0; otherwise, + # pass through to the OS. + if pid == -1 and options == 0: + hub = get_hub() + watcher = hub.loop.child(0, False) + hub.wait(watcher) + return watcher.rpid, watcher.rstatus + # There were funky options/pid, so we must go to the OS. + return _waitpid(pid, options) + + if pid in _watched_children: + # yes, we're watching it + if options & _WNOHANG or isinstance(_watched_children[pid], tuple): + # We're either asked not to block, or it already finished, in which + # case blocking doesn't matter + result = _watched_children[pid] + if isinstance(result, tuple): + # it finished. libev child watchers + # are one-shot + del _watched_children[pid] + return result[:2] + # it's not finished + return (0, 0) + else: + # Ok, we need to "block". Do so via a watcher so that we're + # cooperative. We know it's our child, etc, so this should work. + watcher = _watched_children[pid] + # We can't start a watcher that's already started, + # so we can't reuse the existing watcher. + new_watcher = watcher.loop.child(pid, False) + get_hub().wait(new_watcher) + # Ok, so now the new watcher is done. That means + # the old watcher's callback (_on_child) should + # have fired, potentially taking this child out of + # _watched_children (but that could depend on how + # many callbacks there were to run, so use the + # watcher object directly; libev sets all the + # watchers at the same time). + return watcher.rpid, watcher.rstatus + + # we're not watching it and it may not even be our child, + # so we must go to the OS to be sure to get the right semantics (exception) + return _waitpid(pid, options) + + def fork_and_watch(callback=None, loop=None, ref=False, fork=fork_gevent): + """ + Fork a child process and start a child watcher for it in the parent process. + + This call cooperates with :func:`waitpid` to enable cooperatively waiting + for children to finish. When monkey-patching, these functions are patched in as + :func:`os.fork` and :func:`os.waitpid`, respectively. + + In the child process, this function calls :func:`gevent.hub.reinit` before returning. + + Availability: POSIX. + + :keyword callback: If given, a callable that will be called with the child watcher + when the child finishes. + :keyword loop: The loop to start the watcher in. Defaults to the + loop of the current hub. + :keyword fork: The fork function. Defaults to :func:`the one defined in this + module <gevent.os.fork_gevent>` (which automatically calls :func:`gevent.hub.reinit`). + Pass the builtin :func:`os.fork` function if you do not need to + initialize gevent in the child process. + + .. versionadded:: 1.1b1 + .. seealso:: + :func:`gevent.monkey.get_original` To access the builtin :func:`os.fork`. + """ + pid = fork() + if pid: + # parent + loop = loop or get_hub().loop + watcher = loop.child(pid, ref=ref) + _watched_children[pid] = watcher + watcher.start(_on_child, watcher, callback) + return pid + + __extensions__.append('fork_and_watch') + __extensions__.append('fork_gevent') + + if 'forkpty' in __implements__: + def forkpty_and_watch(callback=None, loop=None, ref=False, forkpty=forkpty_gevent): + """ + Like :func:`fork_and_watch`, except using :func:`forkpty_gevent`. + + Availability: Some Unix systems. + + .. versionadded:: 1.1b5 + """ + result = [] + + def _fork(): + pid_and_fd = forkpty() + result.append(pid_and_fd) + return pid_and_fd[0] + fork_and_watch(callback, loop, ref, _fork) + return result[0] + + __extensions__.append('forkpty_and_watch') + + # Watch children by default + if not os.getenv('GEVENT_NOWAITPID'): + # Broken out into separate functions instead of simple name aliases + # for documentation purposes. + def fork(*args, **kwargs): + """ + Forks a child process and starts a child watcher for it in the + parent process so that ``waitpid`` and SIGCHLD work as expected. + + This implementation of ``fork`` is a wrapper for :func:`fork_and_watch` + when the environment variable ``GEVENT_NOWAITPID`` is *not* defined. + This is the default and should be used by most applications. + + .. versionchanged:: 1.1b2 + """ + # take any args to match fork_and_watch + return fork_and_watch(*args, **kwargs) + + if 'forkpty' in __implements__: + def forkpty(*args, **kwargs): + """ + Like :func:`fork`, but using :func:`forkpty_gevent`. + + This implementation of ``forkpty`` is a wrapper for :func:`forkpty_and_watch` + when the environment variable ``GEVENT_NOWAITPID`` is *not* defined. + This is the default and should be used by most applications. + + .. versionadded:: 1.1b5 + """ + # take any args to match fork_and_watch + return forkpty_and_watch(*args, **kwargs) + __implements__.append("waitpid") + else: + def fork(): + """ + Forks a child process, initializes gevent in the child, + but *does not* prepare the parent to wait for the child or receive SIGCHLD. + + This implementation of ``fork`` is a wrapper for :func:`fork_gevent` + when the environment variable ``GEVENT_NOWAITPID`` *is* defined. + This is not recommended for most applications. + """ + return fork_gevent() + + if 'forkpty' in __implements__: + def forkpty(): + """ + Like :func:`fork`, but using :func:`os.forkpty` + + This implementation of ``forkpty`` is a wrapper for :func:`forkpty_gevent` + when the environment variable ``GEVENT_NOWAITPID`` *is* defined. + This is not recommended for most applications. + + .. versionadded:: 1.1b5 + """ + return forkpty_gevent() + __extensions__.append("waitpid") + +else: + __implements__.remove('fork') + +__imports__ = copy_globals(os, globals(), + names_to_ignore=__implements__ + __extensions__, + dunder_names_to_keep=()) + +__all__ = list(set(__implements__ + __extensions__)) diff --git a/python/gevent/pool.py b/python/gevent/pool.py new file mode 100644 index 0000000..d0c5cbb --- /dev/null +++ b/python/gevent/pool.py @@ -0,0 +1,759 @@ +# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details. +""" +Managing greenlets in a group. + +The :class:`Group` class in this module abstracts a group of running +greenlets. When a greenlet dies, it's automatically removed from the +group. All running greenlets in a group can be waited on with +:meth:`Group.join`, or all running greenlets can be killed with +:meth:`Group.kill`. + +The :class:`Pool` class, which is a subclass of :class:`Group`, +provides a way to limit concurrency: its :meth:`spawn <Pool.spawn>` +method blocks if the number of greenlets in the pool has already +reached the limit, until there is a free slot. +""" + +from bisect import insort_right +try: + from itertools import izip +except ImportError: + # Python 3 + izip = zip + +from gevent.hub import GreenletExit, getcurrent, kill as _kill +from gevent.greenlet import joinall, Greenlet +from gevent.timeout import Timeout +from gevent.event import Event +from gevent.lock import Semaphore, DummySemaphore + +__all__ = ['Group', 'Pool'] + + +class IMapUnordered(Greenlet): + """ + At iterator of map results. + """ + + _zipped = False + + def __init__(self, func, iterable, spawn=None, maxsize=None, _zipped=False): + """ + An iterator that. + + :keyword int maxsize: If given and not-None, specifies the maximum number of + finished results that will be allowed to accumulated awaiting the reader; + more than that number of results will cause map function greenlets to begin + to block. This is most useful is there is a great disparity in the speed of + the mapping code and the consumer and the results consume a great deal of resources. + Using a bound is more computationally expensive than not using a bound. + + .. versionchanged:: 1.1b3 + Added the *maxsize* parameter. + """ + from gevent.queue import Queue + Greenlet.__init__(self) + if spawn is not None: + self.spawn = spawn + if _zipped: + self._zipped = _zipped + self.func = func + self.iterable = iterable + self.queue = Queue() + if maxsize: + # Bounding the queue is not enough if we want to keep from + # accumulating objects; the result value will be around as + # the greenlet's result, blocked on self.queue.put(), and + # we'll go on to spawn another greenlet, which in turn can + # create the result. So we need a semaphore to prevent a + # greenlet from exiting while the queue is full so that we + # don't spawn the next greenlet (assuming that self.spawn + # is of course bounded). (Alternatively we could have the + # greenlet itself do the insert into the pool, but that + # takes some rework). + # + # Given the use of a semaphore at this level, sizing the queue becomes + # redundant, and that lets us avoid having to use self.link() instead + # of self.rawlink() to avoid having blocking methods called in the + # hub greenlet. + factory = Semaphore + else: + factory = DummySemaphore + self._result_semaphore = factory(maxsize) + + self.count = 0 + self.finished = False + # If the queue size is unbounded, then we want to call all + # the links (_on_finish and _on_result) directly in the hub greenlet + # for efficiency. However, if the queue is bounded, we can't do that if + # the queue might block (because if there's no waiter the hub can switch to, + # the queue simply raises Full). Therefore, in that case, we use + # the safer, somewhat-slower (because it spawns a greenlet) link() methods. + # This means that _on_finish and _on_result can be called and interleaved in any order + # if the call to self.queue.put() blocks.. + # Note that right now we're not bounding the queue, instead using a semaphore. + self.rawlink(self._on_finish) + + def __iter__(self): + return self + + def next(self): + self._result_semaphore.release() + value = self._inext() + if isinstance(value, Failure): + raise value.exc + return value + __next__ = next + + def _inext(self): + return self.queue.get() + + def _ispawn(self, func, item): + self._result_semaphore.acquire() + self.count += 1 + g = self.spawn(func, item) if not self._zipped else self.spawn(func, *item) + g.rawlink(self._on_result) + return g + + def _run(self): # pylint:disable=method-hidden + try: + func = self.func + for item in self.iterable: + self._ispawn(func, item) + finally: + self.__dict__.pop('spawn', None) + self.__dict__.pop('func', None) + self.__dict__.pop('iterable', None) + + def _on_result(self, greenlet): + # This method can either be called in the hub greenlet (if the + # queue is unbounded) or its own greenlet. If it's called in + # its own greenlet, the calls to put() may block and switch + # greenlets, which in turn could mutate our state. So any + # state on this object that we need to look at, notably + # self.count, we need to capture or mutate *before* we put. + # (Note that right now we're not bounding the queue, but we may + # choose to do so in the future so this implementation will be left in case.) + self.count -= 1 + count = self.count + finished = self.finished + ready = self.ready() + put_finished = False + + if ready and count <= 0 and not finished: + finished = self.finished = True + put_finished = True + + if greenlet.successful(): + self.queue.put(self._iqueue_value_for_success(greenlet)) + else: + self.queue.put(self._iqueue_value_for_failure(greenlet)) + + if put_finished: + self.queue.put(self._iqueue_value_for_finished()) + + def _on_finish(self, _self): + if self.finished: + return + + if not self.successful(): + self.finished = True + self.queue.put(self._iqueue_value_for_self_failure()) + return + + if self.count <= 0: + self.finished = True + self.queue.put(self._iqueue_value_for_finished()) + + def _iqueue_value_for_success(self, greenlet): + return greenlet.value + + def _iqueue_value_for_failure(self, greenlet): + return Failure(greenlet.exception, getattr(greenlet, '_raise_exception')) + + def _iqueue_value_for_finished(self): + return Failure(StopIteration) + + def _iqueue_value_for_self_failure(self): + return Failure(self.exception, self._raise_exception) + + +class IMap(IMapUnordered): + # A specialization of IMapUnordered that returns items + # in the order in which they were generated, not + # the order in which they finish. + # We do this by storing tuples (order, value) in the queue + # not just value. + + def __init__(self, *args, **kwargs): + self.waiting = [] # QQQ maybe deque will work faster there? + self.index = 0 + self.maxindex = -1 + IMapUnordered.__init__(self, *args, **kwargs) + + def _inext(self): + while True: + if self.waiting and self.waiting[0][0] <= self.index: + _, value = self.waiting.pop(0) + else: + index, value = self.queue.get() + if index > self.index: + insort_right(self.waiting, (index, value)) + continue + self.index += 1 + return value + + def _ispawn(self, func, item): + g = IMapUnordered._ispawn(self, func, item) + self.maxindex += 1 + g.index = self.maxindex + return g + + def _iqueue_value_for_success(self, greenlet): + return (greenlet.index, IMapUnordered._iqueue_value_for_success(self, greenlet)) + + def _iqueue_value_for_failure(self, greenlet): + return (greenlet.index, IMapUnordered._iqueue_value_for_failure(self, greenlet)) + + def _iqueue_value_for_finished(self): + self.maxindex += 1 + return (self.maxindex, IMapUnordered._iqueue_value_for_finished(self)) + + def _iqueue_value_for_self_failure(self): + self.maxindex += 1 + return (self.maxindex, IMapUnordered._iqueue_value_for_self_failure(self)) + + +class GroupMappingMixin(object): + # Internal, non-public API class. + # Provides mixin methods for implementing mapping pools. Subclasses must define: + + # - self.spawn(func, *args, **kwargs): a function that runs `func` with `args` + # and `awargs`, potentially asynchronously. Return a value with a `get` method that + # blocks until the results of func are available, and a `link` method. + + # - self._apply_immediately(): should the function passed to apply be called immediately, + # synchronously? + + # - self._apply_async_use_greenlet(): Should apply_async directly call + # Greenlet.spawn(), bypassing self.spawn? Return true when self.spawn would block + + # - self._apply_async_cb_spawn(callback, result): Run the given callback function, possiblly + # asynchronously, possibly synchronously. + + def apply_cb(self, func, args=None, kwds=None, callback=None): + """ + :meth:`apply` the given *func(\\*args, \\*\\*kwds)*, and, if a *callback* is given, run it with the + results of *func* (unless an exception was raised.) + + The *callback* may be called synchronously or asynchronously. If called + asynchronously, it will not be tracked by this group. (:class:`Group` and :class:`Pool` + call it asynchronously in a new greenlet; :class:`~gevent.threadpool.ThreadPool` calls + it synchronously in the current greenlet.) + """ + result = self.apply(func, args, kwds) + if callback is not None: + self._apply_async_cb_spawn(callback, result) + return result + + def apply_async(self, func, args=None, kwds=None, callback=None): + """ + A variant of the :meth:`apply` method which returns a :class:`~.Greenlet` object. + + When the returned greenlet gets to run, it *will* call :meth:`apply`, + passing in *func*, *args* and *kwds*. + + If *callback* is specified, then it should be a callable which + accepts a single argument. When the result becomes ready + callback is applied to it (unless the call failed). + + This method will never block, even if this group is full (that is, + even if :meth:`spawn` would block, this method will not). + + .. caution:: The returned greenlet may or may not be tracked + as part of this group, so :meth:`joining <join>` this group is + not a reliable way to wait for the results to be available or + for the returned greenlet to run; instead, join the returned + greenlet. + + .. tip:: Because :class:`~.ThreadPool` objects do not track greenlets, the returned + greenlet will never be a part of it. To reduce overhead and improve performance, + :class:`Group` and :class:`Pool` may choose to track the returned + greenlet. These are implementation details that may change. + """ + if args is None: + args = () + if kwds is None: + kwds = {} + if self._apply_async_use_greenlet(): + # cannot call self.spawn() directly because it will block + # XXX: This is always the case for ThreadPool, but for Group/Pool + # of greenlets, this is only the case when they are full...hence + # the weasely language about "may or may not be tracked". Should we make + # Group/Pool always return true as well so it's never tracked by any + # implementation? That would simplify that logic, but could increase + # the total number of greenlets in the system and add a layer of + # overhead for the simple cases when the pool isn't full. + return Greenlet.spawn(self.apply_cb, func, args, kwds, callback) + + greenlet = self.spawn(func, *args, **kwds) + if callback is not None: + greenlet.link(pass_value(callback)) + return greenlet + + def apply(self, func, args=None, kwds=None): + """ + Rough quivalent of the :func:`apply()` builtin function blocking until + the result is ready and returning it. + + The ``func`` will *usually*, but not *always*, be run in a way + that allows the current greenlet to switch out (for example, + in a new greenlet or thread, depending on implementation). But + if the current greenlet or thread is already one that was + spawned by this pool, the pool may choose to immediately run + the `func` synchronously. + + Any exception ``func`` raises will be propagated to the caller of ``apply`` (that is, + this method will raise the exception that ``func`` raised). + """ + if args is None: + args = () + if kwds is None: + kwds = {} + if self._apply_immediately(): + return func(*args, **kwds) + return self.spawn(func, *args, **kwds).get() + + def map(self, func, iterable): + """Return a list made by applying the *func* to each element of + the iterable. + + .. seealso:: :meth:`imap` + """ + return list(self.imap(func, iterable)) + + def map_cb(self, func, iterable, callback=None): + result = self.map(func, iterable) + if callback is not None: + callback(result) + return result + + def map_async(self, func, iterable, callback=None): + """ + A variant of the map() method which returns a Greenlet object that is executing + the map function. + + If callback is specified then it should be a callable which accepts a + single argument. + """ + return Greenlet.spawn(self.map_cb, func, iterable, callback) + + def __imap(self, cls, func, *iterables, **kwargs): + # Python 2 doesn't support the syntax that lets us mix varargs and + # a named kwarg, so we have to unpack manually + maxsize = kwargs.pop('maxsize', None) + if kwargs: + raise TypeError("Unsupported keyword arguments") + return cls.spawn(func, izip(*iterables), spawn=self.spawn, + _zipped=True, maxsize=maxsize) + + def imap(self, func, *iterables, **kwargs): + """ + imap(func, *iterables, maxsize=None) -> iterable + + An equivalent of :func:`itertools.imap`, operating in parallel. + The *func* is applied to each element yielded from each + iterable in *iterables* in turn, collecting the result. + + If this object has a bound on the number of active greenlets it can + contain (such as :class:`Pool`), then at most that number of tasks will operate + in parallel. + + :keyword int maxsize: If given and not-None, specifies the maximum number of + finished results that will be allowed to accumulate awaiting the reader; + more than that number of results will cause map function greenlets to begin + to block. This is most useful if there is a great disparity in the speed of + the mapping code and the consumer and the results consume a great deal of resources. + + .. note:: This is separate from any bound on the number of active parallel + tasks, though they may have some interaction (for example, limiting the + number of parallel tasks to the smallest bound). + + .. note:: Using a bound is slightly more computationally expensive than not using a bound. + + .. tip:: The :meth:`imap_unordered` method makes much better + use of this parameter. Some additional, unspecified, + number of objects may be required to be kept in memory + to maintain order by this function. + + :return: An iterable object. + + .. versionchanged:: 1.1b3 + Added the *maxsize* keyword parameter. + .. versionchanged:: 1.1a1 + Accept multiple *iterables* to iterate in parallel. + """ + return self.__imap(IMap, func, *iterables, **kwargs) + + def imap_unordered(self, func, *iterables, **kwargs): + """ + imap_unordered(func, *iterables, maxsize=None) -> iterable + + The same as :meth:`imap` except that the ordering of the results + from the returned iterator should be considered in arbitrary + order. + + This is lighter weight than :meth:`imap` and should be preferred if order + doesn't matter. + + .. seealso:: :meth:`imap` for more details. + """ + return self.__imap(IMapUnordered, func, *iterables, **kwargs) + + +class Group(GroupMappingMixin): + """ + Maintain a group of greenlets that are still running, without + limiting their number. + + Links to each item and removes it upon notification. + + Groups can be iterated to discover what greenlets they are tracking, + they can be tested to see if they contain a greenlet, and they know the + number (len) of greenlets they are tracking. If they are not tracking any + greenlets, they are False in a boolean context. + """ + + #: The type of Greenlet object we will :meth:`spawn`. This can be changed + #: on an instance or in a subclass. + greenlet_class = Greenlet + + def __init__(self, *args): + assert len(args) <= 1, args + self.greenlets = set(*args) + if args: + for greenlet in args[0]: + greenlet.rawlink(self._discard) + # each item we kill we place in dying, to avoid killing the same greenlet twice + self.dying = set() + self._empty_event = Event() + self._empty_event.set() + + def __repr__(self): + return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), self.greenlets) + + def __len__(self): + """ + Answer how many greenlets we are tracking. Note that if we are empty, + we are False in a boolean context. + """ + return len(self.greenlets) + + def __contains__(self, item): + """ + Answer if we are tracking the given greenlet. + """ + return item in self.greenlets + + def __iter__(self): + """ + Iterate across all the greenlets we are tracking, in no particular order. + """ + return iter(self.greenlets) + + def add(self, greenlet): + """ + Begin tracking the greenlet. + + If this group is :meth:`full`, then this method may block + until it is possible to track the greenlet. + """ + try: + rawlink = greenlet.rawlink + except AttributeError: + pass # non-Greenlet greenlet, like MAIN + else: + rawlink(self._discard) + self.greenlets.add(greenlet) + self._empty_event.clear() + + def _discard(self, greenlet): + self.greenlets.discard(greenlet) + self.dying.discard(greenlet) + if not self.greenlets: + self._empty_event.set() + + def discard(self, greenlet): + """ + Stop tracking the greenlet. + """ + self._discard(greenlet) + try: + unlink = greenlet.unlink + except AttributeError: + pass # non-Greenlet greenlet, like MAIN + else: + unlink(self._discard) + + def start(self, greenlet): + """ + Start the un-started *greenlet* and add it to the collection of greenlets + this group is monitoring. + """ + self.add(greenlet) + greenlet.start() + + def spawn(self, *args, **kwargs): + """ + Begin a new greenlet with the given arguments (which are passed + to the greenlet constructor) and add it to the collection of greenlets + this group is monitoring. + + :return: The newly started greenlet. + """ + greenlet = self.greenlet_class(*args, **kwargs) + self.start(greenlet) + return greenlet + +# def close(self): +# """Prevents any more tasks from being submitted to the pool""" +# self.add = RaiseException("This %s has been closed" % self.__class__.__name__) + + def join(self, timeout=None, raise_error=False): + """ + Wait for this group to become empty *at least once*. + + If there are no greenlets in the group, returns immediately. + + .. note:: By the time the waiting code (the caller of this + method) regains control, a greenlet may have been added to + this group, and so this object may no longer be empty. (That + is, ``group.join(); assert len(group) == 0`` is not + guaranteed to hold.) This method only guarantees that the group + reached a ``len`` of 0 at some point. + + :keyword bool raise_error: If True (*not* the default), if any + greenlet that finished while the join was in progress raised + an exception, that exception will be raised to the caller of + this method. If multiple greenlets raised exceptions, which + one gets re-raised is not determined. Only greenlets currently + in the group when this method is called are guaranteed to + be checked for exceptions. + + :return bool: A value indicating whether this group became empty. + If the timeout is specified and the group did not become empty + during that timeout, then this will be a false value. Otherwise + it will be a true value. + + .. versionchanged:: 1.2a1 + Add the return value. + """ + greenlets = list(self.greenlets) if raise_error else () + result = self._empty_event.wait(timeout=timeout) + + for greenlet in greenlets: + if greenlet.exception is not None: + if hasattr(greenlet, '_raise_exception'): + greenlet._raise_exception() + raise greenlet.exception + + return result + + def kill(self, exception=GreenletExit, block=True, timeout=None): + """ + Kill all greenlets being tracked by this group. + """ + timer = Timeout._start_new_or_dummy(timeout) + try: + while self.greenlets: + for greenlet in list(self.greenlets): + if greenlet in self.dying: + continue + try: + kill = greenlet.kill + except AttributeError: + _kill(greenlet, exception) + else: + kill(exception, block=False) + self.dying.add(greenlet) + if not block: + break + joinall(self.greenlets) + except Timeout as ex: + if ex is not timer: + raise + finally: + timer.cancel() + + def killone(self, greenlet, exception=GreenletExit, block=True, timeout=None): + """ + If the given *greenlet* is running and being tracked by this group, + kill it. + """ + if greenlet not in self.dying and greenlet in self.greenlets: + greenlet.kill(exception, block=False) + self.dying.add(greenlet) + if block: + greenlet.join(timeout) + + def full(self): + """ + Return a value indicating whether this group can track more greenlets. + + In this implementation, because there are no limits on the number of + tracked greenlets, this will always return a ``False`` value. + """ + return False + + def wait_available(self, timeout=None): + """ + Block until it is possible to :meth:`spawn` a new greenlet. + + In this implementation, because there are no limits on the number + of tracked greenlets, this will always return immediately. + """ + pass + + # MappingMixin methods + + def _apply_immediately(self): + # If apply() is called from one of our own + # worker greenlets, don't spawn a new one---if we're full, that + # could deadlock. + return getcurrent() in self + + def _apply_async_cb_spawn(self, callback, result): + Greenlet.spawn(callback, result) + + def _apply_async_use_greenlet(self): + # cannot call self.spawn() because it will block, so + # use a fresh, untracked greenlet that when run will + # (indirectly) call self.spawn() for us. + return self.full() + + +class Failure(object): + __slots__ = ['exc', '_raise_exception'] + + def __init__(self, exc, raise_exception=None): + self.exc = exc + self._raise_exception = raise_exception + + def raise_exc(self): + if self._raise_exception: + self._raise_exception() + else: + raise self.exc + + +class Pool(Group): + + def __init__(self, size=None, greenlet_class=None): + """ + Create a new pool. + + A pool is like a group, but the maximum number of members + is governed by the *size* parameter. + + :keyword int size: If given, this non-negative integer is the + maximum count of active greenlets that will be allowed in + this pool. A few values have special significance: + + * ``None`` (the default) places no limit on the number of + greenlets. This is useful when you need to track, but not limit, + greenlets, as with :class:`gevent.pywsgi.WSGIServer`. A :class:`Group` + may be a more efficient way to achieve the same effect. + * ``0`` creates a pool that can never have any active greenlets. Attempting + to spawn in this pool will block forever. This is only useful + if an application uses :meth:`wait_available` with a timeout and checks + :meth:`free_count` before attempting to spawn. + """ + if size is not None and size < 0: + raise ValueError('size must not be negative: %r' % (size, )) + Group.__init__(self) + self.size = size + if greenlet_class is not None: + self.greenlet_class = greenlet_class + if size is None: + factory = DummySemaphore + else: + factory = Semaphore + self._semaphore = factory(size) + + def wait_available(self, timeout=None): + """ + Wait until it's possible to spawn a greenlet in this pool. + + :param float timeout: If given, only wait the specified number + of seconds. + + .. warning:: If the pool was initialized with a size of 0, this + method will block forever unless a timeout is given. + + :return: A number indicating how many new greenlets can be put into + the pool without blocking. + + .. versionchanged:: 1.1a3 + Added the ``timeout`` parameter. + """ + return self._semaphore.wait(timeout=timeout) + + def full(self): + """ + Return a boolean indicating whether this pool has any room for + members. (True if it does, False if it doesn't.) + """ + return self.free_count() <= 0 + + def free_count(self): + """ + Return a number indicating *approximately* how many more members + can be added to this pool. + """ + if self.size is None: + return 1 + return max(0, self.size - len(self)) + + def add(self, greenlet): + """ + Begin tracking the given greenlet, blocking until space is available. + + .. seealso:: :meth:`Group.add` + """ + self._semaphore.acquire() + try: + Group.add(self, greenlet) + except: + self._semaphore.release() + raise + + def _discard(self, greenlet): + Group._discard(self, greenlet) + self._semaphore.release() + + +class pass_value(object): + __slots__ = ['callback'] + + def __init__(self, callback): + self.callback = callback + + def __call__(self, source): + if source.successful(): + self.callback(source.value) + + def __hash__(self): + return hash(self.callback) + + def __eq__(self, other): + return self.callback == getattr(other, 'callback', other) + + def __str__(self): + return str(self.callback) + + def __repr__(self): + return repr(self.callback) + + def __getattr__(self, item): + assert item != 'callback' + return getattr(self.callback, item) diff --git a/python/gevent/python.pxd b/python/gevent/python.pxd new file mode 100644 index 0000000..b4635b1 --- /dev/null +++ b/python/gevent/python.pxd @@ -0,0 +1,17 @@ +cdef extern from "Python.h": + struct PyObject: + pass + ctypedef PyObject* PyObjectPtr "PyObject*" + void Py_INCREF(PyObjectPtr) + void Py_DECREF(PyObjectPtr) + void Py_XDECREF(PyObjectPtr) + int Py_ReprEnter(PyObjectPtr) + void Py_ReprLeave(PyObjectPtr) + int PyCallable_Check(PyObjectPtr) + +cdef extern from "frameobject.h": + ctypedef struct PyThreadState: + PyObjectPtr exc_type + PyObjectPtr exc_value + PyObjectPtr exc_traceback + PyThreadState* PyThreadState_GET() diff --git a/python/gevent/pywsgi.py b/python/gevent/pywsgi.py new file mode 100644 index 0000000..2726f6d --- /dev/null +++ b/python/gevent/pywsgi.py @@ -0,0 +1,1509 @@ +# Copyright (c) 2005-2009, eventlet contributors +# Copyright (c) 2009-2015, gevent contributors +""" +A pure-Python, gevent-friendly WSGI server. + +The server is provided in :class:`WSGIServer`, but most of the actual +WSGI work is handled by :class:`WSGIHandler` --- a new instance is +created for each request. The server can be customized to use +different subclasses of :class:`WSGIHandler`. + +""" +# FIXME: Can we refactor to make smallor? +# pylint:disable=too-many-lines + +import errno +from io import BytesIO +import string +import sys +import time +import traceback +from datetime import datetime + +try: + from urllib import unquote +except ImportError: + from urllib.parse import unquote # python 2 pylint:disable=import-error,no-name-in-module + +from gevent import socket +import gevent +from gevent.server import StreamServer +from gevent.hub import GreenletExit +from gevent._compat import PY3, reraise + +from functools import partial +if PY3: + unquote_latin1 = partial(unquote, encoding='latin-1') +else: + unquote_latin1 = unquote + +_no_undoc_members = True # Don't put undocumented things into sphinx + +__all__ = [ + 'WSGIServer', + 'WSGIHandler', + 'LoggingLogAdapter', + 'Environ', + 'SecureEnviron', + 'WSGISecureEnviron', +] + + +MAX_REQUEST_LINE = 8192 +# Weekday and month names for HTTP date/time formatting; always English! +_WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] +_MONTHNAME = [None, # Dummy so we can use 1-based month numbers + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + +# The contents of the "HEX" grammar rule for HTTP, upper and lowercase A-F plus digits, +# in byte form for comparing to the network. +_HEX = string.hexdigits.encode('ascii') + +# Errors +_ERRORS = dict() +_INTERNAL_ERROR_STATUS = '500 Internal Server Error' +_INTERNAL_ERROR_BODY = b'Internal Server Error' +_INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'), + ('Connection', 'close'), + ('Content-Length', str(len(_INTERNAL_ERROR_BODY)))] +_ERRORS[500] = (_INTERNAL_ERROR_STATUS, _INTERNAL_ERROR_HEADERS, _INTERNAL_ERROR_BODY) + +_BAD_REQUEST_STATUS = '400 Bad Request' +_BAD_REQUEST_BODY = '' +_BAD_REQUEST_HEADERS = [('Content-Type', 'text/plain'), + ('Connection', 'close'), + ('Content-Length', str(len(_BAD_REQUEST_BODY)))] +_ERRORS[400] = (_BAD_REQUEST_STATUS, _BAD_REQUEST_HEADERS, _BAD_REQUEST_BODY) + +_REQUEST_TOO_LONG_RESPONSE = b"HTTP/1.1 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n" +_BAD_REQUEST_RESPONSE = b"HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n" +_CONTINUE_RESPONSE = b"HTTP/1.1 100 Continue\r\n\r\n" + + +def format_date_time(timestamp): + # Return a byte-string of the date and time in HTTP format + # .. versionchanged:: 1.1b5 + # Return a byte string, not a native string + year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp) + value = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (_WEEKDAYNAME[wd], day, _MONTHNAME[month], year, hh, mm, ss) + if PY3: + value = value.encode("latin-1") + return value + + +class _InvalidClientInput(IOError): + # Internal exception raised by Input indicating that the client + # sent invalid data at the lowest level of the stream. The result + # *should* be a HTTP 400 error. + pass + + +class _InvalidClientRequest(ValueError): + # Internal exception raised by WSGIHandler.read_request + # indicating that the client sent an HTTP request that cannot + # be parsed (e.g., invalid grammar). The result *should* be an + # HTTP 400 error + pass + + +class Input(object): + + __slots__ = ('rfile', 'content_length', 'socket', 'position', + 'chunked_input', 'chunk_length', '_chunked_input_error') + + def __init__(self, rfile, content_length, socket=None, chunked_input=False): + # pylint:disable=redefined-outer-name + self.rfile = rfile + self.content_length = content_length + self.socket = socket + self.position = 0 + self.chunked_input = chunked_input + self.chunk_length = -1 + self._chunked_input_error = False + + def _discard(self): + if self._chunked_input_error: + # We are in an unknown state, so we can't necessarily discard + # the body (e.g., if the client keeps the socket open, we could hang + # here forever). + # In this case, we've raised an exception and the user of this object + # is going to close the socket, so we don't have to discard + return + + if self.socket is None and (self.position < (self.content_length or 0) or self.chunked_input): + # ## Read and discard body + while 1: + d = self.read(16384) + if not d: + break + + def _send_100_continue(self): + if self.socket is not None: + self.socket.sendall(_CONTINUE_RESPONSE) + self.socket = None + + def _do_read(self, length=None, use_readline=False): + if use_readline: + reader = self.rfile.readline + else: + reader = self.rfile.read + content_length = self.content_length + if content_length is None: + # Either Content-Length or "Transfer-Encoding: chunked" must be present in a request with a body + # if it was chunked, then this function would have not been called + return b'' + + self._send_100_continue() + left = content_length - self.position + if length is None: + length = left + elif length > left: + length = left + if not length: + return b'' + + # On Python 2, self.rfile is usually socket.makefile(), which + # uses cStringIO.StringIO. If *length* is greater than the C + # sizeof(int) (typically 32 bits signed), parsing the argument to + # readline raises OverflowError. StringIO.read(), OTOH, uses + # PySize_t, typically a long (64 bits). In a bare readline() + # case, because the header lines we're trying to read with + # readline are typically expected to be small, we can correct + # that failure by simply doing a smaller call to readline and + # appending; failures in read we let propagate. + try: + read = reader(length) + except OverflowError: + if not use_readline: + # Expecting to read more than 64 bits of data. Ouch! + raise + # We could loop on calls to smaller readline(), appending them + # until we actually get a newline. For uses in this module, + # we expect the actual length to be small, but WSGI applications + # are allowed to pass in an arbitrary length. (This loop isn't optimal, + # but even client applications *probably* have short lines.) + read = b'' + while len(read) < length and not read.endswith(b'\n'): + read += reader(MAX_REQUEST_LINE) + + self.position += len(read) + if len(read) < length: + if (use_readline and not read.endswith(b"\n")) or not use_readline: + raise IOError("unexpected end of file while reading request at position %s" % (self.position,)) + + return read + + def __read_chunk_length(self, rfile): + # Read and return the next integer chunk length. If no + # chunk length can be read, raises _InvalidClientInput. + + # Here's the production for a chunk: + # (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html) + # chunk = chunk-size [ chunk-extension ] CRLF + # chunk-data CRLF + # chunk-size = 1*HEX + # chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) + # chunk-ext-name = token + # chunk-ext-val = token | quoted-string + + # To cope with malicious or broken clients that fail to send valid + # chunk lines, the strategy is to read character by character until we either reach + # a ; or newline. If at any time we read a non-HEX digit, we bail. If we hit a + # ;, indicating an chunk-extension, we'll read up to the next + # MAX_REQUEST_LINE characters + # looking for the CRLF, and if we don't find it, we bail. If we read more than 16 hex characters, + # (the number needed to represent a 64-bit chunk size), we bail (this protects us from + # a client that sends an infinite stream of `F`, for example). + + buf = BytesIO() + while 1: + char = rfile.read(1) + if not char: + self._chunked_input_error = True + raise _InvalidClientInput("EOF before chunk end reached") + if char == b'\r': + break + if char == b';': + break + + if char not in _HEX: + self._chunked_input_error = True + raise _InvalidClientInput("Non-hex data", char) + buf.write(char) + if buf.tell() > 16: + self._chunked_input_error = True + raise _InvalidClientInput("Chunk-size too large.") + + if char == b';': + i = 0 + while i < MAX_REQUEST_LINE: + char = rfile.read(1) + if char == b'\r': + break + i += 1 + else: + # we read more than MAX_REQUEST_LINE without + # hitting CR + self._chunked_input_error = True + raise _InvalidClientInput("Too large chunk extension") + + if char == b'\r': + # We either got here from the main loop or from the + # end of an extension + char = rfile.read(1) + if char != b'\n': + self._chunked_input_error = True + raise _InvalidClientInput("Line didn't end in CRLF") + return int(buf.getvalue(), 16) + + def _chunked_read(self, length=None, use_readline=False): + # pylint:disable=too-many-branches + rfile = self.rfile + self._send_100_continue() + + if length == 0: + return b"" + + if length is not None and length < 0: + length = None + + if use_readline: + reader = self.rfile.readline + else: + reader = self.rfile.read + + response = [] + while self.chunk_length != 0: + maxreadlen = self.chunk_length - self.position + if length is not None and length < maxreadlen: + maxreadlen = length + + if maxreadlen > 0: + data = reader(maxreadlen) + if not data: + self.chunk_length = 0 + self._chunked_input_error = True + raise IOError("unexpected end of file while parsing chunked data") + + datalen = len(data) + response.append(data) + + self.position += datalen + if self.chunk_length == self.position: + rfile.readline() + + if length is not None: + length -= datalen + if length == 0: + break + if use_readline and data[-1] == b"\n"[0]: + break + else: + # We're at the beginning of a chunk, so we need to + # determine the next size to read + self.chunk_length = self.__read_chunk_length(rfile) + self.position = 0 + if self.chunk_length == 0: + # Last chunk. Terminates with a CRLF. + rfile.readline() + return b''.join(response) + + def read(self, length=None): + if self.chunked_input: + return self._chunked_read(length) + return self._do_read(length) + + def readline(self, size=None): + if self.chunked_input: + return self._chunked_read(size, True) + return self._do_read(size, use_readline=True) + + def readlines(self, hint=None): + # pylint:disable=unused-argument + return list(self) + + def __iter__(self): + return self + + def next(self): + line = self.readline() + if not line: + raise StopIteration + return line + __next__ = next + + +try: + import mimetools + headers_factory = mimetools.Message +except ImportError: + # adapt Python 3 HTTP headers to old API + from http import client # pylint:disable=import-error + + class OldMessage(client.HTTPMessage): + def __init__(self, **kwargs): + super(client.HTTPMessage, self).__init__(**kwargs) # pylint:disable=bad-super-call + self.status = '' + + def getheader(self, name, default=None): + return self.get(name, default) + + @property + def headers(self): + for key, value in self._headers: + yield '%s: %s\r\n' % (key, value) + + @property + def typeheader(self): + return self.get('content-type') + + def headers_factory(fp, *args): # pylint:disable=unused-argument + try: + ret = client.parse_headers(fp, _class=OldMessage) + except client.LineTooLong: + ret = OldMessage() + ret.status = 'Line too long' + return ret + + +class WSGIHandler(object): + """ + Handles HTTP requests from a socket, creates the WSGI environment, and + interacts with the WSGI application. + + This is the default value of :attr:`WSGIServer.handler_class`. + This class may be subclassed carefully, and that class set on a + :class:`WSGIServer` instance through a keyword argument at + construction time. + + Instances are constructed with the same arguments as passed to the + server's :meth:`WSGIServer.handle` method followed by the server + itself. The application and environment are obtained from the server. + + """ + # pylint:disable=too-many-instance-attributes + + protocol_version = 'HTTP/1.1' + if PY3: + # if we do like Py2, then headers_factory unconditionally + # becomes a bound method, meaning the fp argument becomes WSGIHandler + def MessageClass(self, *args): + return headers_factory(*args) + else: + MessageClass = headers_factory + + # Attributes reset at various times for each request; not public + # documented. Class attributes to keep the constructor fast + # (but not make lint tools complain) + + status = None # byte string: b'200 OK' + _orig_status = None # native string: '200 OK' + response_headers = None # list of tuples (b'name', b'value') + code = None # Integer parsed from status + provided_date = None + provided_content_length = None + close_connection = False + time_start = 0 # time.time() when begin handling request + time_finish = 0 # time.time() when done handling request + headers_sent = False # Have we already sent headers? + response_use_chunked = False # Write with transfer-encoding chunked + environ = None # Dict from self.get_environ + application = None # application callable from self.server.application + requestline = None # native str 'GET / HTTP/1.1' + response_length = 0 # How much data we sent + result = None # The return value of the WSGI application + wsgi_input = None # Instance of Input() + content_length = 0 # From application-provided headers Incoming + # request headers, instance of MessageClass (gunicorn uses hasattr + # on this so the default value needs to be compatible with the + # API) + headers = headers_factory(BytesIO()) + request_version = None # str: 'HTTP 1.1' + command = None # str: 'GET' + path = None # str: '/' + + def __init__(self, sock, address, server, rfile=None): + # Deprecation: The rfile kwarg was introduced in 1.0a1 as part + # of a refactoring. It was never documented or used. It is + # considered DEPRECATED and may be removed in the future. Its + # use is not supported. + + self.socket = sock + self.client_address = address + self.server = server + if rfile is None: + self.rfile = sock.makefile('rb', -1) + else: + self.rfile = rfile + + def handle(self): + """ + The main request handling method, called by the server. + + This method runs a request handling loop, calling + :meth:`handle_one_request` until all requests on the + connection have been handled (that is, it implements + keep-alive). + """ + try: + while self.socket is not None: + self.time_start = time.time() + self.time_finish = 0 + + result = self.handle_one_request() + if result is None: + break + if result is True: + continue + + self.status, response_body = result + self.socket.sendall(response_body) + if self.time_finish == 0: + self.time_finish = time.time() + self.log_request() + break + finally: + if self.socket is not None: + _sock = getattr(self.socket, '_sock', None) # Python 3 + try: + # read out request data to prevent error: [Errno 104] Connection reset by peer + if _sock: + try: + # socket.recv would hang + _sock.recv(16384) + finally: + _sock.close() + self.socket.close() + except socket.error: + pass + self.__dict__.pop('socket', None) + self.__dict__.pop('rfile', None) + + def _check_http_version(self): + version_str = self.request_version + if not version_str.startswith("HTTP/"): + return False + version = tuple(int(x) for x in version_str[5:].split(".")) # "HTTP/" + if version[1] < 0 or version < (0, 9) or version >= (2, 0): + return False + return True + + def read_request(self, raw_requestline): + """ + Parse the incoming request. + + Parses various headers into ``self.headers`` using + :attr:`MessageClass`. Other attributes that are set upon a successful + return of this method include ``self.content_length`` and ``self.close_connection``. + + :param str raw_requestline: A native :class:`str` representing + the request line. A processed version of this will be stored + into ``self.requestline``. + + :raises ValueError: If the request is invalid. This error will + not be logged as a traceback (because it's a client issue, not a server problem). + :return: A boolean value indicating whether the request was successfully parsed. + This method should either return a true value or have raised a ValueError + with details about the parsing error. + + .. versionchanged:: 1.1b6 + Raise the previously documented :exc:`ValueError` in more cases instead of returning a + false value; this allows subclasses more opportunity to customize behaviour. + """ + # pylint:disable=too-many-branches + self.requestline = raw_requestline.rstrip() + words = self.requestline.split() + if len(words) == 3: + self.command, self.path, self.request_version = words + if not self._check_http_version(): + raise _InvalidClientRequest('Invalid http version: %r', raw_requestline) + elif len(words) == 2: + self.command, self.path = words + if self.command != "GET": + raise _InvalidClientRequest('Expected GET method: %r', raw_requestline) + self.request_version = "HTTP/0.9" + # QQQ I'm pretty sure we can drop support for HTTP/0.9 + else: + raise _InvalidClientRequest('Invalid HTTP method: %r', raw_requestline) + + self.headers = self.MessageClass(self.rfile, 0) + + if self.headers.status: + raise _InvalidClientRequest('Invalid headers status: %r', self.headers.status) + + if self.headers.get("transfer-encoding", "").lower() == "chunked": + try: + del self.headers["content-length"] + except KeyError: + pass + + content_length = self.headers.get("content-length") + if content_length is not None: + content_length = int(content_length) + if content_length < 0: + raise _InvalidClientRequest('Invalid Content-Length: %r', content_length) + + if content_length and self.command in ('HEAD', ): + raise _InvalidClientRequest('Unexpected Content-Length') + + self.content_length = content_length + + if self.request_version == "HTTP/1.1": + conntype = self.headers.get("Connection", "").lower() + self.close_connection = (conntype == 'close') + else: + self.close_connection = True + + return True + + def log_error(self, msg, *args): + try: + message = msg % args + except Exception: # pylint:disable=broad-except + traceback.print_exc() + message = '%r %r' % (msg, args) + try: + message = '%s: %s' % (self.socket, message) + except Exception: # pylint:disable=broad-except + pass + + try: + self.server.error_log.write(message + '\n') + except Exception: # pylint:disable=broad-except + traceback.print_exc() + + def read_requestline(self): + """ + Read and return the HTTP request line. + + Under both Python 2 and 3, this should return the native + ``str`` type; under Python 3, this probably means the bytes read + from the network need to be decoded (using the ISO-8859-1 charset, aka + latin-1). + """ + line = self.rfile.readline(MAX_REQUEST_LINE) + if PY3: + line = line.decode('latin-1') + return line + + def handle_one_request(self): + """ + Handles one HTTP request using ``self.socket`` and ``self.rfile``. + + Each invocation of this method will do several things, including (but not limited to): + + - Read the request line using :meth:`read_requestline`; + - Read the rest of the request, including headers, with :meth:`read_request`; + - Construct a new WSGI environment in ``self.environ`` using :meth:`get_environ`; + - Store the application in ``self.application``, retrieving it from the server; + - Handle the remainder of the request, including invoking the application, + with :meth:`handle_one_response` + + There are several possible return values to indicate the state + of the client connection: + + - ``None`` + The client connection is already closed or should + be closed because the WSGI application or client set the + ``Connection: close`` header. The request handling + loop should terminate and perform cleanup steps. + - (status, body) + An HTTP status and body tuple. The request was in error, + as detailed by the status and body. The request handling + loop should terminate, close the connection, and perform + cleanup steps. Note that the ``body`` is the complete contents + to send to the client, including all headers and the initial + status line. + - ``True`` + The literal ``True`` value. The request was successfully handled + and the response sent to the client by :meth:`handle_one_response`. + The connection remains open to process more requests and the connection + handling loop should call this method again. This is the typical return + value. + + .. seealso:: :meth:`handle` + + .. versionchanged:: 1.1b6 + Funnel exceptions having to do with invalid HTTP requests through + :meth:`_handle_client_error` to allow subclasses to customize. Note that + this is experimental and may change in the future. + """ + # pylint:disable=too-many-return-statements + if self.rfile.closed: + return + + try: + self.requestline = self.read_requestline() + # Account for old subclasses that haven't done this + if PY3 and isinstance(self.requestline, bytes): + self.requestline = self.requestline.decode('latin-1') + except socket.error: + # "Connection reset by peer" or other socket errors aren't interesting here + return + + if not self.requestline: + return + + self.response_length = 0 + + if len(self.requestline) >= MAX_REQUEST_LINE: + return ('414', _REQUEST_TOO_LONG_RESPONSE) + + try: + # for compatibility with older versions of pywsgi, we pass self.requestline as an argument there + # NOTE: read_request is supposed to raise ValueError on invalid input; allow old + # subclasses that return a False value instead. + # NOTE: This can mutate the value of self.headers, so self.get_environ() must not be + # called until AFTER this call is done. + if not self.read_request(self.requestline): + return ('400', _BAD_REQUEST_RESPONSE) + except Exception as ex: # pylint:disable=broad-except + # Notice we don't use self.handle_error because it reports + # a 500 error to the client, and this is almost certainly + # a client error. + # Provide a hook for subclasses. + return self._handle_client_error(ex) + + self.environ = self.get_environ() + self.application = self.server.application + + self.handle_one_response() + + if self.close_connection: + return + + if self.rfile.closed: + return + + return True # read more requests + + def finalize_headers(self): + if self.provided_date is None: + self.response_headers.append((b'Date', format_date_time(time.time()))) + + if self.code not in (304, 204): + # the reply will include message-body; make sure we have either Content-Length or chunked + if self.provided_content_length is None: + if hasattr(self.result, '__len__'): + total_len = sum(len(chunk) for chunk in self.result) + total_len_str = str(total_len) + if PY3: + total_len_str = total_len_str.encode("latin-1") + self.response_headers.append((b'Content-Length', total_len_str)) + else: + if self.request_version != 'HTTP/1.0': + self.response_use_chunked = True + self.response_headers.append((b'Transfer-Encoding', b'chunked')) + + def _sendall(self, data): + try: + self.socket.sendall(data) + except socket.error as ex: + self.status = 'socket error: %s' % ex + if self.code > 0: + self.code = -self.code + raise + self.response_length += len(data) + + def _write(self, data): + if not data: + # The application/middleware are allowed to yield + # empty bytestrings. + return + + if self.response_use_chunked: + ## Write the chunked encoding + header = ("%x\r\n" % len(data)).encode('ascii') + # socket.sendall will slice these small strings, as [0:], + # but that's special cased to return the original string. + # They're small enough we probably expect them to go down to the network + # buffers in one go anyway. + self._sendall(header) + self._sendall(data) + self._sendall(b'\r\n') # trailer + else: + self._sendall(data) + + def write(self, data): + # The write() callable we return from start_response. + # https://www.python.org/dev/peps/pep-3333/#the-write-callable + # Supposed to do pretty much the same thing as yielding values + # from the application's return. + if self.code in (304, 204) and data: + raise AssertionError('The %s response must have no body' % self.code) + + if self.headers_sent: + self._write(data) + else: + if not self.status: + raise AssertionError("The application did not call start_response()") + self._write_with_headers(data) + + def _write_with_headers(self, data): + towrite = bytearray() + self.headers_sent = True + self.finalize_headers() + + # self.response_headers and self.status are already in latin-1, as encoded by self.start_response + towrite.extend(b'HTTP/1.1 ') + towrite.extend(self.status) + towrite.extend(b'\r\n') + for header, value in self.response_headers: + towrite.extend(header) + towrite.extend(b': ') + towrite.extend(value) + towrite.extend(b"\r\n") + + towrite.extend(b'\r\n') + self._sendall(towrite) + # No need to copy the data into towrite; we may make an extra syscall + # but the copy time could be substantial too, and it reduces the chances + # of sendall being able to send everything in one go + self._write(data) + + def start_response(self, status, headers, exc_info=None): + """ + .. versionchanged:: 1.2a1 + Avoid HTTP header injection by raising a :exc:`ValueError` + if *status* or any *header* name or value contains a carriage + return or newline. + .. versionchanged:: 1.1b5 + Pro-actively handle checking the encoding of the status line + and headers during this method. On Python 2, avoid some + extra encodings. + """ + # pylint:disable=too-many-branches,too-many-statements + if exc_info: + try: + if self.headers_sent: + # Re-raise original exception if headers sent + reraise(*exc_info) + finally: + # Avoid dangling circular ref + exc_info = None + + # Pep 3333, "The start_response callable": + # https://www.python.org/dev/peps/pep-3333/#the-start-response-callable + # "Servers should check for errors in the headers at the time + # start_response is called, so that an error can be raised + # while the application is still running." Here, we check the encoding. + # This aids debugging: headers especially are generated programatically + # and an encoding error in a loop or list comprehension yields an opaque + # UnicodeError without any clue which header was wrong. + # Note that this results in copying the header list at this point, not modifying it, + # although we are allowed to do so if needed. This slightly increases memory usage. + # We also check for HTTP Response Splitting vulnerabilities + response_headers = [] + header = None + value = None + try: + for header, value in headers: + if not isinstance(header, str): + raise UnicodeError("The header must be a native string", header, value) + if not isinstance(value, str): + raise UnicodeError("The value must be a native string", header, value) + if '\r' in header or '\n' in header: + raise ValueError('carriage return or newline in header name', header) + if '\r' in value or '\n' in value: + raise ValueError('carriage return or newline in header value', value) + # Either we're on Python 2, in which case bytes is correct, or + # we're on Python 3 and the user screwed up (because it should be a native + # string). In either case, make sure that this is latin-1 compatible. Under + # Python 2, bytes.encode() will take a round-trip through the system encoding, + # which may be ascii, which is not really what we want. However, the latin-1 encoding + # can encode everything except control characters and the block from 0x7F to 0x9F, so + # explicitly round-tripping bytes through the encoding is unlikely to be of much + # benefit, so we go for speed (the WSGI spec specifically calls out allowing the range + # from 0x00 to 0xFF, although the HTTP spec forbids the control characters). + # Note: Some Python 2 implementations, like Jython, may allow non-octet (above 255) values + # in their str implementation; this is mentioned in the WSGI spec, but we don't + # run on any platform like that so we can assume that a str value is pure bytes. + response_headers.append((header if not PY3 else header.encode("latin-1"), + value if not PY3 else value.encode("latin-1"))) + except UnicodeEncodeError: + # If we get here, we're guaranteed to have a header and value + raise UnicodeError("Non-latin1 header", repr(header), repr(value)) + + # Same as above + if not isinstance(status, str): + raise UnicodeError("The status string must be a native string") + if '\r' in status or '\n' in status: + raise ValueError("carriage return or newline in status", status) + # don't assign to anything until the validation is complete, including parsing the + # code + code = int(status.split(' ', 1)[0]) + + self.status = status if not PY3 else status.encode("latin-1") + self._orig_status = status # Preserve the native string for logging + self.response_headers = response_headers + self.code = code + + provided_connection = None + self.provided_date = None + self.provided_content_length = None + + for header, value in headers: + header = header.lower() + if header == 'connection': + provided_connection = value + elif header == 'date': + self.provided_date = value + elif header == 'content-length': + self.provided_content_length = value + + if self.request_version == 'HTTP/1.0' and provided_connection is None: + response_headers.append((b'Connection', b'close')) + self.close_connection = True + elif provided_connection == 'close': + self.close_connection = True + + if self.code in (304, 204): + if self.provided_content_length is not None and self.provided_content_length != '0': + msg = 'Invalid Content-Length for %s response: %r (must be absent or zero)' % (self.code, self.provided_content_length) + if PY3: + msg = msg.encode('latin-1') + raise AssertionError(msg) + + return self.write + + def log_request(self): + self.server.log.write(self.format_request() + '\n') + + def format_request(self): + now = datetime.now().replace(microsecond=0) + length = self.response_length or '-' + if self.time_finish: + delta = '%.6f' % (self.time_finish - self.time_start) + else: + delta = '-' + client_address = self.client_address[0] if isinstance(self.client_address, tuple) else self.client_address + return '%s - - [%s] "%s" %s %s %s' % ( + client_address or '-', + now, + self.requestline or '', + # Use the native string version of the status, saved so we don't have to + # decode. But fallback to the encoded 'status' in case of subclasses + # (Is that really necessary? At least there's no overhead.) + (self._orig_status or self.status or '000').split()[0], + length, + delta) + + def process_result(self): + for data in self.result: + if data: + self.write(data) + if self.status and not self.headers_sent: + # In other words, the application returned an empty + # result iterable (and did not use the write callable) + # Trigger the flush of the headers. + self.write(b'') + if self.response_use_chunked: + self.socket.sendall(b'0\r\n\r\n') + self.response_length += 5 + + def run_application(self): + assert self.result is None + try: + self.result = self.application(self.environ, self.start_response) + self.process_result() + finally: + close = getattr(self.result, 'close', None) + try: + if close is not None: + close() + finally: + # Discard the result. If it's a generator this can + # free a lot of hidden resources (if we failed to iterate + # all the way through it---the frames are automatically + # cleaned up when StopIteration is raised); but other cases + # could still free up resources sooner than otherwise. + close = None + self.result = None + + def handle_one_response(self): + self.time_start = time.time() + self.status = None + self.headers_sent = False + + self.result = None + self.response_use_chunked = False + self.response_length = 0 + + try: + try: + self.run_application() + finally: + try: + self.wsgi_input._discard() + except (socket.error, IOError): + # Don't let exceptions during discarding + # input override any exception that may have been + # raised by the application, such as our own _InvalidClientInput. + # In the general case, these aren't even worth logging (see the comment + # just below) + pass + except _InvalidClientInput: + self._send_error_response_if_possible(400) + except socket.error as ex: + if ex.args[0] in (errno.EPIPE, errno.ECONNRESET): + # Broken pipe, connection reset by peer. + # Swallow these silently to avoid spewing + # useless info on normal operating conditions, + # bloating logfiles. See https://github.com/gevent/gevent/pull/377 + # and https://github.com/gevent/gevent/issues/136. + if not PY3: + sys.exc_clear() + self.close_connection = True + else: + self.handle_error(*sys.exc_info()) + except: # pylint:disable=bare-except + self.handle_error(*sys.exc_info()) + finally: + self.time_finish = time.time() + self.log_request() + + def _send_error_response_if_possible(self, error_code): + if self.response_length: + self.close_connection = True + else: + status, headers, body = _ERRORS[error_code] + try: + self.start_response(status, headers[:]) + self.write(body) + except socket.error: + if not PY3: + sys.exc_clear() + self.close_connection = True + + def _log_error(self, t, v, tb): + # TODO: Shouldn't we dump this to wsgi.errors? If we did that now, it would + # wind up getting logged twice + if not issubclass(t, GreenletExit): + context = self.environ + if not isinstance(context, self.server.secure_environ_class): + context = self.server.secure_environ_class(context) + self.server.loop.handle_error(context, t, v, tb) + + def handle_error(self, t, v, tb): + # Called for internal, unexpected errors, NOT invalid client input + self._log_error(t, v, tb) + del tb + self._send_error_response_if_possible(500) + + def _handle_client_error(self, ex): + # Called for invalid client input + # Returns the appropriate error response. + if not isinstance(ex, ValueError): + # XXX: Why not self._log_error to send it through the loop's + # handle_error method? + traceback.print_exc() + if isinstance(ex, _InvalidClientRequest): + # These come with good error messages, and we want to let + # log_error deal with the formatting, especially to handle encoding + self.log_error(*ex.args) + else: + self.log_error('Invalid request: %s', str(ex) or ex.__class__.__name__) + return ('400', _BAD_REQUEST_RESPONSE) + + def _headers(self): + key = None + value = None + IGNORED_KEYS = (None, 'CONTENT_TYPE', 'CONTENT_LENGTH') + for header in self.headers.headers: + if key is not None and header[:1] in " \t": + value += header + continue + + if key not in IGNORED_KEYS: + yield 'HTTP_' + key, value.strip() + + key, value = header.split(':', 1) + if '_' in key: + # strip incoming bad veaders + key = None + else: + key = key.replace('-', '_').upper() + + if key not in IGNORED_KEYS: + yield 'HTTP_' + key, value.strip() + + def get_environ(self): + """ + Construct and return a new WSGI environment dictionary for a specific request. + + This should begin with asking the server for the base environment + using :meth:`WSGIServer.get_environ`, and then proceed to add the + request specific values. + + By the time this method is invoked the request line and request shall have + been parsed and ``self.headers`` shall be populated. + """ + env = self.server.get_environ() + env['REQUEST_METHOD'] = self.command + env['SCRIPT_NAME'] = '' + + if '?' in self.path: + path, query = self.path.split('?', 1) + else: + path, query = self.path, '' + # Note that self.path contains the original str object; if it contains + # encoded escapes, it will NOT match PATH_INFO. + env['PATH_INFO'] = unquote_latin1(path) + env['QUERY_STRING'] = query + + if self.headers.typeheader is not None: + env['CONTENT_TYPE'] = self.headers.typeheader + + length = self.headers.getheader('content-length') + if length: + env['CONTENT_LENGTH'] = length + env['SERVER_PROTOCOL'] = self.request_version + + client_address = self.client_address + if isinstance(client_address, tuple): + env['REMOTE_ADDR'] = str(client_address[0]) + env['REMOTE_PORT'] = str(client_address[1]) + + for key, value in self._headers(): + if key in env: + if 'COOKIE' in key: + env[key] += '; ' + value + else: + env[key] += ',' + value + else: + env[key] = value + + if env.get('HTTP_EXPECT') == '100-continue': + sock = self.socket + else: + sock = None + + chunked = env.get('HTTP_TRANSFER_ENCODING', '').lower() == 'chunked' + self.wsgi_input = Input(self.rfile, self.content_length, socket=sock, chunked_input=chunked) + env['wsgi.input'] = self.wsgi_input + return env + + +class _NoopLog(object): + # Does nothing; implements just enough file-like methods + # to pass the WSGI validator + + def write(self, *args, **kwargs): + # pylint:disable=unused-argument + return + + def flush(self): + pass + + def writelines(self, *args, **kwargs): + pass + + +class LoggingLogAdapter(object): + """ + An adapter for :class:`logging.Logger` instances + to let them be used with :class:`WSGIServer`. + + .. warning:: Unless the entire process is monkey-patched at a very + early part of the lifecycle (before logging is configured), + loggers are likely to not be gevent-cooperative. For example, + the socket and syslog handlers use the socket module in a way + that can block, and most handlers acquire threading locks. + + .. warning:: It *may* be possible for the logging functions to be + called in the :class:`gevent.Hub` greenlet. Code running in the + hub greenlet cannot use any gevent blocking functions without triggering + a ``LoopExit``. + + .. versionadded:: 1.1a3 + + .. versionchanged:: 1.1b6 + Attributes not present on this object are proxied to the underlying + logger instance. This permits using custom :class:`~logging.Logger` + subclasses (or indeed, even duck-typed objects). + + .. versionchanged:: 1.1 + Strip trailing newline characters on the message passed to :meth:`write` + because log handlers will usually add one themselves. + """ + + # gevent avoids importing and using logging because importing it and + # creating loggers creates native locks unless monkey-patched. + + __slots__ = ('_logger', '_level') + + def __init__(self, logger, level=20): + """ + Write information to the *logger* at the given *level* (default to INFO). + """ + self._logger = logger + self._level = level + + def write(self, msg): + if msg and msg.endswith('\n'): + msg = msg[:-1] + self._logger.log(self._level, msg) + + def flush(self): + "No-op; required to be a file-like object" + pass + + def writelines(self, lines): + for line in lines: + self.write(line) + + def __getattr__(self, name): + return getattr(self._logger, name) + + def __setattr__(self, name, value): + if name not in LoggingLogAdapter.__slots__: + setattr(self._logger, name, value) + else: + object.__setattr__(self, name, value) + + def __delattr__(self, name): + delattr(self._logger, name) + +#### +## Environ classes. +# These subclass dict. They could subclass collections.UserDict on +# 3.3+ and proxy to the underlying real dict to avoid a copy if we +# have to print them (on 2.7 it's slightly more complicated to be an +# instance of collections.MutableMapping; UserDict.UserDict isn't.) +# Then we could have either the WSGIHandler.get_environ or the +# WSGIServer.get_environ return one of these proxies, and +# WSGIHandler.run_application would know to access the `environ.data` +# attribute to be able to pass the *real* dict to the application +# (because PEP3333 requires no subclasses, only actual dict objects; +# wsgiref.validator and webob.Request both enforce this). This has the +# advantage of not being fragile if anybody else tries to print/log +# self.environ (and not requiring a copy). However, if there are any +# subclasses of Handler or Server, this could break if they don't know +# to return this type. +#### + +class Environ(dict): + """ + A base class that can be used for WSGI environment objects. + + Provisional API. + + .. versionadded:: 1.2a1 + """ + + __slots__ = () # add no ivars or weakref ability + + def copy(self): + return self.__class__(self) + + if not hasattr(dict, 'iteritems'): + # Python 3 + def iteritems(self): + return self.items() + + def __reduce_ex__(self, proto): + return (dict, (), None, None, iter(self.iteritems())) + +class SecureEnviron(Environ): + """ + An environment that does not print its keys and values + by default. + + Provisional API. + + This is intended to keep potentially sensitive information like + HTTP authorization and cookies from being inadvertently printed + or logged. + + For debugging, each instance can have its *secure_repr* attribute + set to ``False``, which will cause it to print like a normal dict. + + When *secure_repr* is ``True`` (the default), then the value of + the *whitelist_keys* attribute is consulted; if this value is + true-ish, it should be a container (something that responds to + ``in``) of key names (typically a list or set). Keys and values in + this dictionary that are in *whitelist_keys* will then be printed, + while all other values will be masked. These values may be + customized on the class by setting the *default_secure_repr* and + *default_whitelist_keys*, respectively:: + + >>> environ = SecureEnviron(key='value') + >>> environ # doctest: +ELLIPSIS + <pywsgi.SecureEnviron dict (keys: 1) at ... + + If we whitelist the key, it gets printed:: + + >>> environ.whitelist_keys = {'key'} + >>> environ + {'key': 'value'} + + A non-whitelisted key (*only*, to avoid doctest issues) is masked:: + + >>> environ['secure'] = 'secret'; del environ['key'] + >>> environ + {'secure': '<MASKED>'} + + We can turn it off entirely for the instance:: + + >>> environ.secure_repr = False + >>> environ + {'secure': 'secret'} + + We can also customize it at the class level (here we use a new + class to be explicit and to avoid polluting the true default + values; we would set this class to be the ``environ_class`` of the + server):: + + >>> class MyEnviron(SecureEnviron): + ... default_whitelist_keys = ('key',) + ... + >>> environ = MyEnviron({'key': 'value'}) + >>> environ + {'key': 'value'} + + .. versionadded:: 1.2a1 + """ + + default_secure_repr = True + default_whitelist_keys = () + default_print_masked_keys = True + + # Allow instances to override the class values, + # but inherit from the class if not present. Keeps instances + # small since we can't combine __slots__ with class attributes + # of the same name. + __slots__ = ('secure_repr', 'whitelist_keys', 'print_masked_keys') + + def __getattr__(self, name): + if name in SecureEnviron.__slots__: + return getattr(type(self), 'default_' + name) + raise AttributeError(name) + + def __repr__(self): + if self.secure_repr: + whitelist = self.whitelist_keys + print_masked = self.print_masked_keys + if whitelist: + safe = {k: self[k] if k in whitelist else "<MASKED>" + for k in self + if k in whitelist or print_masked} + safe_repr = repr(safe) + if not print_masked and len(safe) != len(self): + safe_repr = safe_repr[:-1] + ", (hidden keys: %d)}" % (len(self) - len(safe)) + return safe_repr + return "<pywsgi.SecureEnviron dict (keys: %d) at %s>" % (len(self), id(self)) + return Environ.__repr__(self) + __str__ = __repr__ + + +class WSGISecureEnviron(SecureEnviron): + """ + Specializes the default list of whitelisted keys to a few + common WSGI variables. + + Example:: + + >>> environ = WSGISecureEnviron(REMOTE_ADDR='::1', HTTP_AUTHORIZATION='secret') + >>> environ + {'REMOTE_ADDR': '::1', (hidden keys: 1)} + >>> import pprint + >>> pprint.pprint(environ) + {'REMOTE_ADDR': '::1', (hidden keys: 1)} + >>> print(pprint.pformat(environ)) + {'REMOTE_ADDR': '::1', (hidden keys: 1)} + """ + default_whitelist_keys = ('REMOTE_ADDR', 'REMOTE_PORT', 'HTTP_HOST') + default_print_masked_keys = False + + +class WSGIServer(StreamServer): + """ + A WSGI server based on :class:`StreamServer` that supports HTTPS. + + + :keyword log: If given, an object with a ``write`` method to which + request (access) logs will be written. If not given, defaults + to :obj:`sys.stderr`. You may pass ``None`` to disable request + logging. You may use a wrapper, around e.g., :mod:`logging`, + to support objects that don't implement a ``write`` method. + (If you pass a :class:`~logging.Logger` instance, or in + general something that provides a ``log`` method but not a + ``write`` method, such a wrapper will automatically be created + and it will be logged to at the :data:`~logging.INFO` level.) + + :keyword error_log: If given, a file-like object with ``write``, + ``writelines`` and ``flush`` methods to which error logs will + be written. If not given, defaults to :obj:`sys.stderr`. You + may pass ``None`` to disable error logging (not recommended). + You may use a wrapper, around e.g., :mod:`logging`, to support + objects that don't implement the proper methods. This + parameter will become the value for ``wsgi.errors`` in the + WSGI environment (if not already set). (As with *log*, + wrappers for :class:`~logging.Logger` instances and the like + will be created automatically and logged to at the :data:`~logging.ERROR` + level.) + + .. seealso:: + + :class:`LoggingLogAdapter` + See important warnings before attempting to use :mod:`logging`. + + .. versionchanged:: 1.1a3 + Added the ``error_log`` parameter, and set ``wsgi.errors`` in the WSGI + environment to this value. + .. versionchanged:: 1.1a3 + Add support for passing :class:`logging.Logger` objects to the ``log`` and + ``error_log`` arguments. + """ + + #: A callable taking three arguments: (socket, address, server) and returning + #: an object with a ``handle()`` method. The callable is called once for + #: each incoming socket request, as is its handle method. The handle method should not + #: return until all use of the socket is complete. + #: + #: This class uses the :class:`WSGIHandler` object as the default value. You may + #: subclass this class and set a different default value, or you may pass + #: a value to use in the ``handler_class`` keyword constructor argument. + handler_class = WSGIHandler + + #: The object to which request logs will be written. + #: It must never be None. Initialized from the ``log`` constructor + #: parameter. + log = None + + #: The object to which error logs will be written. + #: It must never be None. Initialized from the ``error_log`` constructor + #: parameter. + error_log = None + + #: The class of environ objects passed to the handlers. + #: Must be a dict subclass. For compliance with :pep:`3333` + #: and libraries like WebOb, this is simply :class:`dict` + #: but this can be customized in a subclass or per-instance + #: (probably to :class:`WSGISecureEnviron`). + #: + #: .. versionadded:: 1.2a1 + environ_class = dict + + # Undocumented internal detail: the class that WSGIHandler._log_error + # will cast to before passing to the loop. + secure_environ_class = WSGISecureEnviron + + base_env = {'GATEWAY_INTERFACE': 'CGI/1.1', + 'SERVER_SOFTWARE': 'gevent/%d.%d Python/%d.%d' % (gevent.version_info[:2] + sys.version_info[:2]), + 'SCRIPT_NAME': '', + 'wsgi.version': (1, 0), + 'wsgi.multithread': False, # XXX: Aren't we really, though? + 'wsgi.multiprocess': False, + 'wsgi.run_once': False} + + def __init__(self, listener, application=None, backlog=None, spawn='default', + log='default', error_log='default', + handler_class=None, + environ=None, **ssl_args): + StreamServer.__init__(self, listener, backlog=backlog, spawn=spawn, **ssl_args) + if application is not None: + self.application = application + if handler_class is not None: + self.handler_class = handler_class + + # Note that we can't initialize these as class variables: + # sys.stderr might get monkey patched at runtime. + def _make_log(l, level=20): + if l == 'default': + return sys.stderr + if l is None: + return _NoopLog() + if not hasattr(l, 'write') and hasattr(l, 'log'): + return LoggingLogAdapter(l, level) + return l + self.log = _make_log(log) + self.error_log = _make_log(error_log, 40) # logging.ERROR + + self.set_environ(environ) + self.set_max_accept() + + def set_environ(self, environ=None): + if environ is not None: + self.environ = environ + environ_update = getattr(self, 'environ', None) + + self.environ = self.environ_class(self.base_env) + if self.ssl_enabled: + self.environ['wsgi.url_scheme'] = 'https' + else: + self.environ['wsgi.url_scheme'] = 'http' + if environ_update is not None: + self.environ.update(environ_update) + if self.environ.get('wsgi.errors') is None: + self.environ['wsgi.errors'] = self.error_log + + def set_max_accept(self): + if self.environ.get('wsgi.multiprocess'): + self.max_accept = 1 + + def get_environ(self): + return self.environ_class(self.environ) + + def init_socket(self): + StreamServer.init_socket(self) + self.update_environ() + + def update_environ(self): + """ + Called before the first request is handled to fill in WSGI environment values. + + This includes getting the correct server name and port. + """ + address = self.address + if isinstance(address, tuple): + if 'SERVER_NAME' not in self.environ: + try: + name = socket.getfqdn(address[0]) + except socket.error: + name = str(address[0]) + if PY3 and not isinstance(name, str): + name = name.decode('ascii') + self.environ['SERVER_NAME'] = name + self.environ.setdefault('SERVER_PORT', str(address[1])) + else: + self.environ.setdefault('SERVER_NAME', '') + self.environ.setdefault('SERVER_PORT', '') + + def handle(self, sock, address): + """ + Create an instance of :attr:`handler_class` to handle the request. + + This method blocks until the handler returns. + """ + # pylint:disable=method-hidden + handler = self.handler_class(sock, address, self) + handler.handle() + +def _main(): + # Provisional main handler, for quick tests, not production + # usage. + from gevent import monkey; monkey.patch_all() + + import argparse + import importlib + + parser = argparse.ArgumentParser() + parser.add_argument("app", help="dotted name of WSGI app callable [module:callable]") + parser.add_argument("-b", "--bind", + help="The socket to bind", + default=":8080") + + args = parser.parse_args() + + module_name, app_name = args.app.split(':') + module = importlib.import_module(module_name) + app = getattr(module, app_name) + bind = args.bind + + server = WSGIServer(bind, app) + server.serve_forever() + +if __name__ == '__main__': + _main() diff --git a/python/gevent/queue.py b/python/gevent/queue.py new file mode 100644 index 0000000..5f1bb47 --- /dev/null +++ b/python/gevent/queue.py @@ -0,0 +1,605 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +"""Synchronized queues. + +The :mod:`gevent.queue` module implements multi-producer, multi-consumer queues +that work across greenlets, with the API similar to the classes found in the +standard :mod:`Queue` and :class:`multiprocessing <multiprocessing.Queue>` modules. + +The classes in this module implement iterator protocol. Iterating over queue +means repeatedly calling :meth:`get <Queue.get>` until :meth:`get <Queue.get>` returns ``StopIteration``. + + >>> queue = gevent.queue.Queue() + >>> queue.put(1) + >>> queue.put(2) + >>> queue.put(StopIteration) + >>> for item in queue: + ... print(item) + 1 + 2 + +.. versionchanged:: 1.0 + ``Queue(0)`` now means queue of infinite size, not a channel. A :exc:`DeprecationWarning` + will be issued with this argument. +""" + +from __future__ import absolute_import +import sys +import heapq +import collections + +if sys.version_info[0] == 2: + import Queue as __queue__ +else: + import queue as __queue__ # python 2: pylint:disable=import-error +Full = __queue__.Full +Empty = __queue__.Empty + +from gevent.timeout import Timeout +from gevent.hub import get_hub, Waiter, getcurrent +from gevent.hub import InvalidSwitchError + + +__all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'JoinableQueue', 'Channel'] + + +def _safe_remove(deq, item): + # For when the item may have been removed by + # Queue._unlock + try: + deq.remove(item) + except ValueError: + pass + + +class Queue(object): + """ + Create a queue object with a given maximum size. + + If *maxsize* is less than or equal to zero or ``None``, the queue + size is infinite. + + .. versionchanged:: 1.1b3 + Queues now support :func:`len`; it behaves the same as :meth:`qsize`. + .. versionchanged:: 1.1b3 + Multiple greenlets that block on a call to :meth:`put` for a full queue + will now be woken up to put their items into the queue in the order in which + they arrived. Likewise, multiple greenlets that block on a call to :meth:`get` for + an empty queue will now receive items in the order in which they blocked. An + implementation quirk under CPython *usually* ensured this was roughly the case + previously anyway, but that wasn't the case for PyPy. + """ + + def __init__(self, maxsize=None, items=None): + if maxsize is not None and maxsize <= 0: + self.maxsize = None + if maxsize == 0: + import warnings + warnings.warn('Queue(0) now equivalent to Queue(None); if you want a channel, use Channel', + DeprecationWarning, stacklevel=2) + else: + self.maxsize = maxsize + # Explicitly maintain order for getters and putters that block + # so that callers can consistently rely on getting things out + # in the apparent order they went in. This was once required by + # imap_unordered. Previously these were set() objects, and the + # items put in the set have default hash() and eq() methods; + # under CPython, since new objects tend to have increasing + # hash values, this tended to roughly maintain order anyway, + # but that's not true under PyPy. An alternative to a deque + # (to avoid the linear scan of remove()) might be an + # OrderedDict, but it's 2.7 only; we don't expect to have so + # many waiters that removing an arbitrary element is a + # bottleneck, though. + self.getters = collections.deque() + self.putters = collections.deque() + self.hub = get_hub() + self._event_unlock = None + if items: + self._init(maxsize, items) + else: + self._init(maxsize) + + # QQQ make maxsize into a property with setter that schedules unlock if necessary + + def copy(self): + return type(self)(self.maxsize, self.queue) + + def _init(self, maxsize, items=None): + # FIXME: Why is maxsize unused or even passed? + # pylint:disable=unused-argument + if items: + self.queue = collections.deque(items) + else: + self.queue = collections.deque() + + def _get(self): + return self.queue.popleft() + + def _peek(self): + return self.queue[0] + + def _put(self, item): + self.queue.append(item) + + def __repr__(self): + return '<%s at %s%s>' % (type(self).__name__, hex(id(self)), self._format()) + + def __str__(self): + return '<%s%s>' % (type(self).__name__, self._format()) + + def _format(self): + result = [] + if self.maxsize is not None: + result.append('maxsize=%r' % (self.maxsize, )) + if getattr(self, 'queue', None): + result.append('queue=%r' % (self.queue, )) + if self.getters: + result.append('getters[%s]' % len(self.getters)) + if self.putters: + result.append('putters[%s]' % len(self.putters)) + if result: + return ' ' + ' '.join(result) + return '' + + def qsize(self): + """Return the size of the queue.""" + return len(self.queue) + + def __len__(self): + """ + Return the size of the queue. This is the same as :meth:`qsize`. + + .. versionadded: 1.1b3 + + Previously, getting len() of a queue would raise a TypeError. + """ + + return self.qsize() + + def __bool__(self): + """ + A queue object is always True. + + .. versionadded: 1.1b3 + + Now that queues support len(), they need to implement ``__bool__`` + to return True for backwards compatibility. + """ + return True + __nonzero__ = __bool__ + + def empty(self): + """Return ``True`` if the queue is empty, ``False`` otherwise.""" + return not self.qsize() + + def full(self): + """Return ``True`` if the queue is full, ``False`` otherwise. + + ``Queue(None)`` is never full. + """ + return self.maxsize is not None and self.qsize() >= self.maxsize + + def put(self, item, block=True, timeout=None): + """Put an item into the queue. + + If optional arg *block* is true and *timeout* is ``None`` (the default), + block if necessary until a free slot is available. If *timeout* is + a positive number, it blocks at most *timeout* seconds and raises + the :class:`Full` exception if no free slot was available within that time. + Otherwise (*block* is false), put an item on the queue if a free slot + is immediately available, else raise the :class:`Full` exception (*timeout* + is ignored in that case). + """ + if self.maxsize is None or self.qsize() < self.maxsize: + # there's a free slot, put an item right away + self._put(item) + if self.getters: + self._schedule_unlock() + elif self.hub is getcurrent(): + # We're in the mainloop, so we cannot wait; we can switch to other greenlets though. + # Check if possible to get a free slot in the queue. + while self.getters and self.qsize() and self.qsize() >= self.maxsize: + getter = self.getters.popleft() + getter.switch(getter) + if self.qsize() < self.maxsize: + self._put(item) + return + raise Full + elif block: + waiter = ItemWaiter(item, self) + self.putters.append(waiter) + timeout = Timeout._start_new_or_dummy(timeout, Full) + try: + if self.getters: + self._schedule_unlock() + result = waiter.get() + if result is not waiter: + raise InvalidSwitchError("Invalid switch into Queue.put: %r" % (result, )) + finally: + timeout.cancel() + _safe_remove(self.putters, waiter) + else: + raise Full + + def put_nowait(self, item): + """Put an item into the queue without blocking. + + Only enqueue the item if a free slot is immediately available. + Otherwise raise the :class:`Full` exception. + """ + self.put(item, False) + + def __get_or_peek(self, method, block, timeout): + # Internal helper method. The `method` should be either + # self._get when called from self.get() or self._peek when + # called from self.peek(). Call this after the initial check + # to see if there are items in the queue. + + if self.hub is getcurrent(): + # special case to make get_nowait() or peek_nowait() runnable in the mainloop greenlet + # there are no items in the queue; try to fix the situation by unlocking putters + while self.putters: + # Note: get() used popleft(), peek used pop(); popleft + # is almost certainly correct. + self.putters.popleft().put_and_switch() + if self.qsize(): + return method() + raise Empty() + + if not block: + # We can't block, we're not the hub, and we have nothing + # to return. No choice... + raise Empty() + + waiter = Waiter() + timeout = Timeout._start_new_or_dummy(timeout, Empty) + try: + self.getters.append(waiter) + if self.putters: + self._schedule_unlock() + result = waiter.get() + if result is not waiter: + raise InvalidSwitchError('Invalid switch into Queue.get: %r' % (result, )) + return method() + finally: + timeout.cancel() + _safe_remove(self.getters, waiter) + + def get(self, block=True, timeout=None): + """Remove and return an item from the queue. + + If optional args *block* is true and *timeout* is ``None`` (the default), + block if necessary until an item is available. If *timeout* is a positive number, + it blocks at most *timeout* seconds and raises the :class:`Empty` exception + if no item was available within that time. Otherwise (*block* is false), return + an item if one is immediately available, else raise the :class:`Empty` exception + (*timeout* is ignored in that case). + """ + if self.qsize(): + if self.putters: + self._schedule_unlock() + return self._get() + + return self.__get_or_peek(self._get, block, timeout) + + def get_nowait(self): + """Remove and return an item from the queue without blocking. + + Only get an item if one is immediately available. Otherwise + raise the :class:`Empty` exception. + """ + return self.get(False) + + def peek(self, block=True, timeout=None): + """Return an item from the queue without removing it. + + If optional args *block* is true and *timeout* is ``None`` (the default), + block if necessary until an item is available. If *timeout* is a positive number, + it blocks at most *timeout* seconds and raises the :class:`Empty` exception + if no item was available within that time. Otherwise (*block* is false), return + an item if one is immediately available, else raise the :class:`Empty` exception + (*timeout* is ignored in that case). + """ + if self.qsize(): + # XXX: Why doesn't this schedule an unlock like get() does? + return self._peek() + + return self.__get_or_peek(self._peek, block, timeout) + + def peek_nowait(self): + """Return an item from the queue without blocking. + + Only return an item if one is immediately available. Otherwise + raise the :class:`Empty` exception. + """ + return self.peek(False) + + def _unlock(self): + while True: + repeat = False + if self.putters and (self.maxsize is None or self.qsize() < self.maxsize): + repeat = True + try: + putter = self.putters.popleft() + self._put(putter.item) + except: # pylint:disable=bare-except + putter.throw(*sys.exc_info()) + else: + putter.switch(putter) + if self.getters and self.qsize(): + repeat = True + getter = self.getters.popleft() + getter.switch(getter) + if not repeat: + return + + def _schedule_unlock(self): + if not self._event_unlock: + self._event_unlock = self.hub.loop.run_callback(self._unlock) + + def __iter__(self): + return self + + def next(self): + result = self.get() + if result is StopIteration: + raise result + return result + + __next__ = next + + + +class ItemWaiter(Waiter): + __slots__ = ['item', 'queue'] + + def __init__(self, item, queue): + Waiter.__init__(self) + self.item = item + self.queue = queue + + def put_and_switch(self): + self.queue._put(self.item) + self.queue = None + self.item = None + return self.switch(self) + + +class PriorityQueue(Queue): + '''A subclass of :class:`Queue` that retrieves entries in priority order (lowest first). + + Entries are typically tuples of the form: ``(priority number, data)``. + + .. versionchanged:: 1.2a1 + Any *items* given to the constructor will now be passed through + :func:`heapq.heapify` to ensure the invariants of this class hold. + Previously it was just assumed that they were already a heap. + ''' + + def _init(self, maxsize, items=None): + if items: + self.queue = list(items) + heapq.heapify(self.queue) + else: + self.queue = [] + + def _put(self, item, heappush=heapq.heappush): + # pylint:disable=arguments-differ + heappush(self.queue, item) + + def _get(self, heappop=heapq.heappop): + # pylint:disable=arguments-differ + return heappop(self.queue) + + +class LifoQueue(Queue): + '''A subclass of :class:`Queue` that retrieves most recently added entries first.''' + + def _init(self, maxsize, items=None): + if items: + self.queue = list(items) + else: + self.queue = [] + + def _put(self, item): + self.queue.append(item) + + def _get(self): + return self.queue.pop() + + def _peek(self): + return self.queue[-1] + + +class JoinableQueue(Queue): + """ + A subclass of :class:`Queue` that additionally has + :meth:`task_done` and :meth:`join` methods. + """ + + def __init__(self, maxsize=None, items=None, unfinished_tasks=None): + """ + + .. versionchanged:: 1.1a1 + If *unfinished_tasks* is not given, then all the given *items* + (if any) will be considered unfinished. + + """ + from gevent.event import Event + Queue.__init__(self, maxsize, items) + self._cond = Event() + self._cond.set() + + if unfinished_tasks: + self.unfinished_tasks = unfinished_tasks + elif items: + self.unfinished_tasks = len(items) + else: + self.unfinished_tasks = 0 + + if self.unfinished_tasks: + self._cond.clear() + + def copy(self): + return type(self)(self.maxsize, self.queue, self.unfinished_tasks) + + def _format(self): + result = Queue._format(self) + if self.unfinished_tasks: + result += ' tasks=%s _cond=%s' % (self.unfinished_tasks, self._cond) + return result + + def _put(self, item): + Queue._put(self, item) + self.unfinished_tasks += 1 + self._cond.clear() + + def task_done(self): + '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads. + For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue + that the processing on the task is complete. + + If a :meth:`join` is currently blocking, it will resume when all items have been processed + (meaning that a :meth:`task_done` call was received for every item that had been + :meth:`put <Queue.put>` into the queue). + + Raises a :exc:`ValueError` if called more times than there were items placed in the queue. + ''' + if self.unfinished_tasks <= 0: + raise ValueError('task_done() called too many times') + self.unfinished_tasks -= 1 + if self.unfinished_tasks == 0: + self._cond.set() + + def join(self, timeout=None): + ''' + Block until all items in the queue have been gotten and processed. + + The count of unfinished tasks goes up whenever an item is added to the queue. + The count goes down whenever a consumer thread calls :meth:`task_done` to indicate + that the item was retrieved and all work on it is complete. When the count of + unfinished tasks drops to zero, :meth:`join` unblocks. + + :param float timeout: If not ``None``, then wait no more than this time in seconds + for all tasks to finish. + :return: ``True`` if all tasks have finished; if ``timeout`` was given and expired before + all tasks finished, ``False``. + + .. versionchanged:: 1.1a1 + Add the *timeout* parameter. + ''' + return self._cond.wait(timeout=timeout) + + +class Channel(object): + + def __init__(self): + self.getters = collections.deque() + self.putters = collections.deque() + self.hub = get_hub() + self._event_unlock = None + + def __repr__(self): + return '<%s at %s %s>' % (type(self).__name__, hex(id(self)), self._format()) + + def __str__(self): + return '<%s %s>' % (type(self).__name__, self._format()) + + def _format(self): + result = '' + if self.getters: + result += ' getters[%s]' % len(self.getters) + if self.putters: + result += ' putters[%s]' % len(self.putters) + return result + + @property + def balance(self): + return len(self.putters) - len(self.getters) + + def qsize(self): + return 0 + + def empty(self): + return True + + def full(self): + return True + + def put(self, item, block=True, timeout=None): + if self.hub is getcurrent(): + if self.getters: + getter = self.getters.popleft() + getter.switch(item) + return + raise Full + + if not block: + timeout = 0 + + waiter = Waiter() + item = (item, waiter) + self.putters.append(item) + timeout = Timeout._start_new_or_dummy(timeout, Full) + try: + if self.getters: + self._schedule_unlock() + result = waiter.get() + if result is not waiter: + raise InvalidSwitchError("Invalid switch into Channel.put: %r" % (result, )) + except: + _safe_remove(self.putters, item) + raise + finally: + timeout.cancel() + + def put_nowait(self, item): + self.put(item, False) + + def get(self, block=True, timeout=None): + if self.hub is getcurrent(): + if self.putters: + item, putter = self.putters.popleft() + self.hub.loop.run_callback(putter.switch, putter) + return item + + if not block: + timeout = 0 + + waiter = Waiter() + timeout = Timeout._start_new_or_dummy(timeout, Empty) + try: + self.getters.append(waiter) + if self.putters: + self._schedule_unlock() + return waiter.get() + except: + self.getters.remove(waiter) + raise + finally: + timeout.cancel() + + def get_nowait(self): + return self.get(False) + + def _unlock(self): + while self.putters and self.getters: + getter = self.getters.popleft() + item, putter = self.putters.popleft() + getter.switch(item) + putter.switch(putter) + + def _schedule_unlock(self): + if not self._event_unlock: + self._event_unlock = self.hub.loop.run_callback(self._unlock) + + def __iter__(self): + return self + + def next(self): + result = self.get() + if result is StopIteration: + raise result + return result + + __next__ = next # py3 diff --git a/python/gevent/resolver_ares.py b/python/gevent/resolver_ares.py new file mode 100644 index 0000000..196e4c4 --- /dev/null +++ b/python/gevent/resolver_ares.py @@ -0,0 +1,388 @@ +# Copyright (c) 2011-2015 Denis Bilenko. See LICENSE for details. +""" +c-ares based hostname resolver. +""" +from __future__ import absolute_import +import os +import sys +from _socket import getservbyname, getaddrinfo, gaierror, error +from gevent.hub import Waiter, get_hub +from gevent._compat import string_types, text_type, integer_types, reraise, PY3 +from gevent.socket import AF_UNSPEC, AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AI_NUMERICHOST, EAI_SERVICE, AI_PASSIVE +from gevent.ares import channel, InvalidIP # pylint:disable=import-error,no-name-in-module + + +__all__ = ['Resolver'] + + +class Resolver(object): + """ + Implementation of the resolver API using the `c-ares`_ library. + + This implementation uses the c-ares library to handle name + resolution. c-ares is natively asynchronous at the socket level + and so integrates well into gevent's event loop. + + In comparison to :class:`gevent.resolver_thread.Resolver` (which + delegates to the native system resolver), the implementation is + much more complex. In addition, there have been reports of it not + properly honoring certain system configurations (for example, the + order in which IPv4 and IPv6 results are returned may not match + the threaded resolver). However, because it does not use threads, + it may scale better for applications that make many lookups. + + There are some known differences from the system resolver: + + - ``gethostbyname_ex`` and ``gethostbyaddr`` may return different + for the ``aliaslist`` tuple member. (Sometimes the same, + sometimes in a different order, sometimes a different alias + altogether.) + - ``gethostbyname_ex`` may return the ``ipaddrlist`` in a different order. + - ``getaddrinfo`` does not return ``SOCK_RAW`` results. + - ``getaddrinfo`` may return results in a different order. + - Handling of ``.local`` (mDNS) names may be different, even if they are listed in + the hosts file. + - c-ares will not resolve ``broadcasthost``, even if listed in the hosts file. + - This implementation may raise ``gaierror(4)`` where the system implementation would raise + ``herror(1)``. + - The results for ``localhost`` may be different. In particular, some system + resolvers will return more results from ``getaddrinfo`` than c-ares does, + such as SOCK_DGRAM results, and c-ares may report more ips on a multi-homed + host. + + .. caution:: This module is considered extremely experimental on PyPy, and + due to its implementation in cython, it may be slower. It may also lead to + interpreter crashes. + + .. _c-ares: http://c-ares.haxx.se + """ + + ares_class = channel + + def __init__(self, hub=None, use_environ=True, **kwargs): + if hub is None: + hub = get_hub() + self.hub = hub + if use_environ: + for key in os.environ: + if key.startswith('GEVENTARES_'): + name = key[11:].lower() + if name: + value = os.environ[key] + kwargs.setdefault(name, value) + self.ares = self.ares_class(hub.loop, **kwargs) + self.pid = os.getpid() + self.params = kwargs + self.fork_watcher = hub.loop.fork(ref=False) + self.fork_watcher.start(self._on_fork) + + def __repr__(self): + return '<gevent.resolver_ares.Resolver at 0x%x ares=%r>' % (id(self), self.ares) + + def _on_fork(self): + # NOTE: See comment in gevent.hub.reinit. + pid = os.getpid() + if pid != self.pid: + self.hub.loop.run_callback(self.ares.destroy) + self.ares = self.ares_class(self.hub.loop, **self.params) + self.pid = pid + + def close(self): + if self.ares is not None: + self.hub.loop.run_callback(self.ares.destroy) + self.ares = None + self.fork_watcher.stop() + + def gethostbyname(self, hostname, family=AF_INET): + hostname = _resolve_special(hostname, family) + return self.gethostbyname_ex(hostname, family)[-1][0] + + def gethostbyname_ex(self, hostname, family=AF_INET): + if PY3: + if isinstance(hostname, str): + hostname = hostname.encode('idna') + elif not isinstance(hostname, (bytes, bytearray)): + raise TypeError('Expected es(idna), not %s' % type(hostname).__name__) + else: + if isinstance(hostname, text_type): + hostname = hostname.encode('ascii') + elif not isinstance(hostname, str): + raise TypeError('Expected string, not %s' % type(hostname).__name__) + + while True: + ares = self.ares + try: + waiter = Waiter(self.hub) + ares.gethostbyname(waiter, hostname, family) + result = waiter.get() + if not result[-1]: + raise gaierror(-5, 'No address associated with hostname') + return result + except gaierror: + if ares is self.ares: + if hostname == b'255.255.255.255': + # The stdlib handles this case in 2.7 and 3.x, but ares does not. + # It is tested by test_socket.py in 3.4. + # HACK: So hardcode the expected return. + return ('255.255.255.255', [], ['255.255.255.255']) + raise + # "self.ares is not ares" means channel was destroyed (because we were forked) + + def _lookup_port(self, port, socktype): + # pylint:disable=too-many-branches + socktypes = [] + if isinstance(port, string_types): + try: + port = int(port) + except ValueError: + try: + if socktype == 0: + origport = port + try: + port = getservbyname(port, 'tcp') + socktypes.append(SOCK_STREAM) + except error: + port = getservbyname(port, 'udp') + socktypes.append(SOCK_DGRAM) + else: + try: + if port == getservbyname(origport, 'udp'): + socktypes.append(SOCK_DGRAM) + except error: + pass + elif socktype == SOCK_STREAM: + port = getservbyname(port, 'tcp') + elif socktype == SOCK_DGRAM: + port = getservbyname(port, 'udp') + else: + raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype') + except error as ex: + if 'not found' in str(ex): + raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype') + else: + raise gaierror(str(ex)) + except UnicodeEncodeError: + raise error('Int or String expected') + elif port is None: + port = 0 + elif isinstance(port, integer_types): + pass + else: + raise error('Int or String expected', port, type(port)) + port = int(port % 65536) + if not socktypes and socktype: + socktypes.append(socktype) + return port, socktypes + + def _getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0): + # pylint:disable=too-many-locals,too-many-branches + if isinstance(host, text_type): + host = host.encode('idna') + elif not isinstance(host, str) or (flags & AI_NUMERICHOST): + # this handles cases which do not require network access + # 1) host is None + # 2) host is of an invalid type + # 3) AI_NUMERICHOST flag is set + return getaddrinfo(host, port, family, socktype, proto, flags) + # we also call _socket.getaddrinfo below if family is not one of AF_* + + port, socktypes = self._lookup_port(port, socktype) + + socktype_proto = [(SOCK_STREAM, 6), (SOCK_DGRAM, 17), (SOCK_RAW, 0)] + if socktypes: + socktype_proto = [(x, y) for (x, y) in socktype_proto if x in socktypes] + if proto: + socktype_proto = [(x, y) for (x, y) in socktype_proto if proto == y] + + ares = self.ares + + if family == AF_UNSPEC: + ares_values = Values(self.hub, 2) + ares.gethostbyname(ares_values, host, AF_INET) + ares.gethostbyname(ares_values, host, AF_INET6) + elif family == AF_INET: + ares_values = Values(self.hub, 1) + ares.gethostbyname(ares_values, host, AF_INET) + elif family == AF_INET6: + ares_values = Values(self.hub, 1) + ares.gethostbyname(ares_values, host, AF_INET6) + else: + raise gaierror(5, 'ai_family not supported: %r' % (family, )) + + values = ares_values.get() + if len(values) == 2 and values[0] == values[1]: + values.pop() + + result = [] + result4 = [] + result6 = [] + + for addrs in values: + if addrs.family == AF_INET: + for addr in addrs[-1]: + sockaddr = (addr, port) + for socktype4, proto4 in socktype_proto: + result4.append((AF_INET, socktype4, proto4, '', sockaddr)) + elif addrs.family == AF_INET6: + for addr in addrs[-1]: + if addr == '::1': + dest = result + else: + dest = result6 + sockaddr = (addr, port, 0, 0) + for socktype6, proto6 in socktype_proto: + dest.append((AF_INET6, socktype6, proto6, '', sockaddr)) + + # As of 2016, some platforms return IPV6 first and some do IPV4 first, + # and some might even allow configuration of which is which. For backwards + # compatibility with earlier releases (but not necessarily resolver_thread!) + # we return 4 first. See https://github.com/gevent/gevent/issues/815 for more. + result += result4 + result6 + + if not result: + raise gaierror(-5, 'No address associated with hostname') + + return result + + def getaddrinfo(self, host, port, family=0, socktype=0, proto=0, flags=0): + while True: + ares = self.ares + try: + return self._getaddrinfo(host, port, family, socktype, proto, flags) + except gaierror: + if ares is self.ares: + raise + + def _gethostbyaddr(self, ip_address): + if PY3: + if isinstance(ip_address, str): + ip_address = ip_address.encode('idna') + elif not isinstance(ip_address, (bytes, bytearray)): + raise TypeError('Expected es(idna), not %s' % type(ip_address).__name__) + else: + if isinstance(ip_address, text_type): + ip_address = ip_address.encode('ascii') + elif not isinstance(ip_address, str): + raise TypeError('Expected string, not %s' % type(ip_address).__name__) + + waiter = Waiter(self.hub) + try: + self.ares.gethostbyaddr(waiter, ip_address) + return waiter.get() + except InvalidIP: + result = self._getaddrinfo(ip_address, None, family=AF_UNSPEC, socktype=SOCK_DGRAM) + if not result: + raise + _ip_address = result[0][-1][0] + if isinstance(_ip_address, text_type): + _ip_address = _ip_address.encode('ascii') + if _ip_address == ip_address: + raise + waiter.clear() + self.ares.gethostbyaddr(waiter, _ip_address) + return waiter.get() + + def gethostbyaddr(self, ip_address): + ip_address = _resolve_special(ip_address, AF_UNSPEC) + while True: + ares = self.ares + try: + return self._gethostbyaddr(ip_address) + except gaierror: + if ares is self.ares: + raise + + def _getnameinfo(self, sockaddr, flags): + if not isinstance(flags, int): + raise TypeError('an integer is required') + if not isinstance(sockaddr, tuple): + raise TypeError('getnameinfo() argument 1 must be a tuple') + + address = sockaddr[0] + if not PY3 and isinstance(address, text_type): + address = address.encode('ascii') + + if not isinstance(address, string_types): + raise TypeError('sockaddr[0] must be a string, not %s' % type(address).__name__) + + port = sockaddr[1] + if not isinstance(port, int): + raise TypeError('port must be an integer, not %s' % type(port)) + + waiter = Waiter(self.hub) + result = self._getaddrinfo(address, str(sockaddr[1]), family=AF_UNSPEC, socktype=SOCK_DGRAM) + if not result: + reraise(*sys.exc_info()) + elif len(result) != 1: + raise error('sockaddr resolved to multiple addresses') + family, _socktype, _proto, _name, address = result[0] + + if family == AF_INET: + if len(sockaddr) != 2: + raise error("IPv4 sockaddr must be 2 tuple") + elif family == AF_INET6: + address = address[:2] + sockaddr[2:] + + self.ares.getnameinfo(waiter, address, flags) + node, service = waiter.get() + + if service is None: + if PY3: + # ares docs: "If the query did not complete + # successfully, or one of the values was not + # requested, node or service will be NULL ". Python 2 + # allows that for the service, but Python 3 raises + # an error. This is tested by test_socket in py 3.4 + err = gaierror('nodename nor servname provided, or not known') + err.errno = 8 + raise err + service = '0' + return node, service + + def getnameinfo(self, sockaddr, flags): + while True: + ares = self.ares + try: + return self._getnameinfo(sockaddr, flags) + except gaierror: + if ares is self.ares: + raise + + +class Values(object): + # helper to collect multiple values; ignore errors unless nothing has succeeded + # QQQ could probably be moved somewhere - hub.py? + + __slots__ = ['count', 'values', 'error', 'waiter'] + + def __init__(self, hub, count): + self.count = count + self.values = [] + self.error = None + self.waiter = Waiter(hub) + + def __call__(self, source): + self.count -= 1 + if source.exception is None: + self.values.append(source.value) + else: + self.error = source.exception + if self.count <= 0: + self.waiter.switch() + + def get(self): + self.waiter.get() + if self.values: + return self.values + else: + assert error is not None + raise self.error # pylint:disable=raising-bad-type + + +def _resolve_special(hostname, family): + if hostname == '': + result = getaddrinfo(None, 0, family, SOCK_DGRAM, 0, AI_PASSIVE) + if len(result) != 1: + raise error('wildcard resolved to multiple address') + return result[0][4][0] + return hostname diff --git a/python/gevent/resolver_thread.py b/python/gevent/resolver_thread.py new file mode 100644 index 0000000..ce69eaf --- /dev/null +++ b/python/gevent/resolver_thread.py @@ -0,0 +1,71 @@ +# Copyright (c) 2012-2015 Denis Bilenko. See LICENSE for details. +""" +Native thread-based hostname resolver. +""" +import _socket +from gevent._compat import text_type +from gevent.hub import get_hub + + +__all__ = ['Resolver'] + + +# trigger import of encodings.idna to avoid https://github.com/gevent/gevent/issues/349 +text_type('foo').encode('idna') + + +class Resolver(object): + """ + Implementation of the resolver API using native threads and native resolution + functions. + + Using the native resolution mechanisms ensures the highest + compatibility with what a non-gevent program would return + including good support for platform specific configuration + mechanisms. The use of native (non-greenlet) threads ensures that + a caller doesn't block other greenlets. + + This implementation also has the benefit of being very simple in comparison to + :class:`gevent.resolver_ares.Resolver`. + + .. tip:: + + Most users find this resolver to be quite reliable in a + properly monkey-patched environment. However, there have been + some reports of long delays, slow performance or even hangs, + particularly in long-lived programs that make many, many DNS + requests. If you suspect that may be happening to you, try the + ares resolver (and submit a bug report). + """ + def __init__(self, hub=None): + if hub is None: + hub = get_hub() + self.pool = hub.threadpool + if _socket.gaierror not in hub.NOT_ERROR: + # Do not cause lookup failures to get printed by the default + # error handler. This can be very noisy. + hub.NOT_ERROR += (_socket.gaierror, _socket.herror) + + def __repr__(self): + return '<gevent.resolver_thread.Resolver at 0x%x pool=%r>' % (id(self), self.pool) + + def close(self): + pass + + # from briefly reading socketmodule.c, it seems that all of the functions + # below are thread-safe in Python, even if they are not thread-safe in C. + + def gethostbyname(self, *args): + return self.pool.apply(_socket.gethostbyname, args) + + def gethostbyname_ex(self, *args): + return self.pool.apply(_socket.gethostbyname_ex, args) + + def getaddrinfo(self, *args, **kwargs): + return self.pool.apply(_socket.getaddrinfo, args, kwargs) + + def gethostbyaddr(self, *args, **kwargs): + return self.pool.apply(_socket.gethostbyaddr, args, kwargs) + + def getnameinfo(self, *args, **kwargs): + return self.pool.apply(_socket.getnameinfo, args, kwargs) diff --git a/python/gevent/select.py b/python/gevent/select.py new file mode 100644 index 0000000..e5680b5 --- /dev/null +++ b/python/gevent/select.py @@ -0,0 +1,244 @@ +# Copyright (c) 2009-2011 Denis Bilenko. See LICENSE for details. +""" +Waiting for I/O completion. +""" +from __future__ import absolute_import + +import sys + +from gevent.event import Event +from gevent.hub import get_hub +from gevent.hub import sleep as _g_sleep +from gevent._compat import integer_types +from gevent._compat import iteritems +from gevent._compat import itervalues +from gevent._util import copy_globals +from gevent._util import _NONE + +from errno import EINTR +if sys.platform.startswith('win32'): + def _original_select(_r, _w, _x, _t): + # windows cant handle three empty lists, but we've always + # accepted that, so don't try the compliance check on windows + return ((), (), ()) +else: + from select import select as _original_select + +try: + from select import poll as original_poll + from select import POLLIN, POLLOUT, POLLNVAL + __implements__ = ['select', 'poll'] +except ImportError: + original_poll = None + __implements__ = ['select'] + +__all__ = ['error'] + __implements__ + +import select as __select__ + +error = __select__.error + +__imports__ = copy_globals(__select__, globals(), + names_to_ignore=__all__, + dunder_names_to_keep=()) + +_EV_READ = 1 +_EV_WRITE = 2 + +def get_fileno(obj): + try: + fileno_f = obj.fileno + except AttributeError: + if not isinstance(obj, integer_types): + raise TypeError('argument must be an int, or have a fileno() method: %r' % (obj,)) + return obj + else: + return fileno_f() + + +class SelectResult(object): + __slots__ = ('read', 'write', 'event') + + def __init__(self): + self.read = [] + self.write = [] + self.event = Event() + + def add_read(self, socket): + self.read.append(socket) + self.event.set() + + add_read.event = _EV_READ + + def add_write(self, socket): + self.write.append(socket) + self.event.set() + + add_write.event = _EV_WRITE + + def __add_watchers(self, watchers, fdlist, callback, io, pri): + for fd in fdlist: + watcher = io(get_fileno(fd), callback.event) + watcher.priority = pri + watchers.append(watcher) + watcher.start(callback, fd) + + def _make_watchers(self, watchers, rlist, wlist): + loop = get_hub().loop + io = loop.io + MAXPRI = loop.MAXPRI + + try: + self.__add_watchers(watchers, rlist, self.add_read, io, MAXPRI) + self.__add_watchers(watchers, wlist, self.add_write, io, MAXPRI) + except IOError as ex: + raise error(*ex.args) + + def _closeall(self, watchers): + for watcher in watchers: + watcher.stop() + del watchers[:] + + def select(self, rlist, wlist, timeout): + watchers = [] + try: + self._make_watchers(watchers, rlist, wlist) + self.event.wait(timeout=timeout) + return self.read, self.write, [] + finally: + self._closeall(watchers) + + +def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument + """An implementation of :meth:`select.select` that blocks only the current greenlet. + + .. caution:: *xlist* is ignored. + + .. versionchanged:: 1.2a1 + Raise a :exc:`ValueError` if timeout is negative. This matches Python 3's + behaviour (Python 2 would raise a ``select.error``). Previously gevent had + undefined behaviour. + .. versionchanged:: 1.2a1 + Raise an exception if any of the file descriptors are invalid. + """ + if timeout is not None and timeout < 0: + # Raise an error like the real implementation; which error + # depends on the version. Python 3, where select.error is OSError, + # raises a ValueError (which makes sense). Older pythons raise + # the error from the select syscall...but we don't actually get there. + # We choose to just raise the ValueError as it makes more sense and is + # forward compatible + raise ValueError("timeout must be non-negative") + + # First, do a poll with the original select system call. This + # is the most efficient way to check to see if any of the file descriptors + # have previously been closed and raise the correct corresponding exception. + # (Because libev tends to just return them as ready...) + # We accept the *xlist* here even though we can't below because this is all about + # error handling. + sel_results = ((), (), ()) + try: + sel_results = _original_select(rlist, wlist, xlist, 0) + except error as e: + enumber = getattr(e, 'errno', None) or e.args[0] + if enumber != EINTR: + # Ignore interrupted syscalls + raise + + if sel_results[0] or sel_results[1] or sel_results[2]: + # If we actually had stuff ready, go ahead and return it. No need + # to go through the trouble of doing our own stuff. + # However, because this is typically a place where scheduling switches + # can occur, we need to make sure that's still the case; otherwise a single + # consumer could monopolize the thread. (shows up in test_ftplib.) + _g_sleep() + return sel_results + + result = SelectResult() + return result.select(rlist, wlist, timeout) + + +if original_poll is not None: + class PollResult(object): + __slots__ = ('events', 'event') + + def __init__(self): + self.events = set() + self.event = Event() + + def add_event(self, events, fd): + if events < 0: + result_flags = POLLNVAL + else: + result_flags = 0 + if events & _EV_READ: + result_flags = POLLIN + if events & _EV_WRITE: + result_flags |= POLLOUT + + self.events.add((fd, result_flags)) + self.event.set() + + class poll(object): + """ + An implementation of :class:`select.poll` that blocks only the current greenlet. + + .. caution:: ``POLLPRI`` data is not supported. + + .. versionadded:: 1.1b1 + """ + def __init__(self): + self.fds = {} # {int -> watcher} + self.loop = get_hub().loop + + def register(self, fd, eventmask=_NONE): + if eventmask is _NONE: + flags = _EV_READ | _EV_WRITE + else: + flags = 0 + if eventmask & POLLIN: + flags = _EV_READ + if eventmask & POLLOUT: + flags |= _EV_WRITE + # If they ask for POLLPRI, we can't support + # that. Should we raise an error? + + fileno = get_fileno(fd) + watcher = self.loop.io(fileno, flags) + watcher.priority = self.loop.MAXPRI + self.fds[fileno] = watcher + + def modify(self, fd, eventmask): + self.register(fd, eventmask) + + def poll(self, timeout=None): + """ + poll the registered fds. + + .. versionchanged:: 1.2a1 + File descriptors that are closed are reported with POLLNVAL. + """ + result = PollResult() + try: + for fd, watcher in iteritems(self.fds): + watcher.start(result.add_event, fd, pass_events=True) + if timeout is not None and timeout > -1: + timeout /= 1000.0 + result.event.wait(timeout=timeout) + return list(result.events) + finally: + for awatcher in itervalues(self.fds): + awatcher.stop() + + def unregister(self, fd): + """ + Unregister the *fd*. + + .. versionchanged:: 1.2a1 + Raise a `KeyError` if *fd* was not registered, like the standard + library. Previously gevent did nothing. + """ + fileno = get_fileno(fd) + del self.fds[fileno] + +del original_poll diff --git a/python/gevent/server.py b/python/gevent/server.py new file mode 100644 index 0000000..f2afab7 --- /dev/null +++ b/python/gevent/server.py @@ -0,0 +1,255 @@ +# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details. +"""TCP/SSL server""" +import sys +import _socket +from gevent.baseserver import BaseServer +from gevent.socket import EWOULDBLOCK, socket +from gevent._compat import PYPY, PY3 + +__all__ = ['StreamServer', 'DatagramServer'] + + +if sys.platform == 'win32': + # SO_REUSEADDR on Windows does not mean the same thing as on *nix (issue #217) + DEFAULT_REUSE_ADDR = None +else: + DEFAULT_REUSE_ADDR = 1 + + +class StreamServer(BaseServer): + """ + A generic TCP server. + + Accepts connections on a listening socket and spawns user-provided + *handle* function for each connection with 2 arguments: the client + socket and the client address. + + Note that although the errors in a successfully spawned handler + will not affect the server or other connections, the errors raised + by :func:`accept` and *spawn* cause the server to stop accepting + for a short amount of time. The exact period depends on the values + of :attr:`min_delay` and :attr:`max_delay` attributes. + + The delay starts with :attr:`min_delay` and doubles with each + successive error until it reaches :attr:`max_delay`. A successful + :func:`accept` resets the delay to :attr:`min_delay` again. + + See :class:`~gevent.baseserver.BaseServer` for information on defining the *handle* + function and important restrictions on it. + + **SSL Support** + + The server can optionally work in SSL mode when given the correct + keyword arguments. (That is, the presence of any keyword arguments + will trigger SSL mode.) On Python 2.7.9 and later (any Python + version that supports the :class:`ssl.SSLContext`), this can be + done with a configured ``SSLContext``. On any Python version, it + can be done by passing the appropriate arguments for + :func:`ssl.wrap_socket`. + + The incoming socket will be wrapped into an SSL socket before + being passed to the *handle* function. + + If the *ssl_context* keyword argument is present, it should + contain an :class:`ssl.SSLContext`. The remaining keyword + arguments are passed to the :meth:`ssl.SSLContext.wrap_socket` + method of that object. Depending on the Python version, supported arguments + may include: + + - server_hostname + - suppress_ragged_eofs + - do_handshake_on_connect + + .. caution:: When using an SSLContext, it should either be + imported from :mod:`gevent.ssl`, or the process needs to be monkey-patched. + If the process is not monkey-patched and you pass the standard library + SSLContext, the resulting client sockets will not cooperate with gevent. + + Otherwise, keyword arguments are assumed to apply to :func:`ssl.wrap_socket`. + These keyword arguments bay include: + + - keyfile + - certfile + - cert_reqs + - ssl_version + - ca_certs + - suppress_ragged_eofs + - do_handshake_on_connect + - ciphers + + .. versionchanged:: 1.2a2 + Add support for the *ssl_context* keyword argument. + + """ + # the default backlog to use if none was provided in __init__ + backlog = 256 + + reuse_addr = DEFAULT_REUSE_ADDR + + def __init__(self, listener, handle=None, backlog=None, spawn='default', **ssl_args): + BaseServer.__init__(self, listener, handle=handle, spawn=spawn) + try: + if ssl_args: + ssl_args.setdefault('server_side', True) + if 'ssl_context' in ssl_args: + ssl_context = ssl_args.pop('ssl_context') + self.wrap_socket = ssl_context.wrap_socket + self.ssl_args = ssl_args + else: + from gevent.ssl import wrap_socket + self.wrap_socket = wrap_socket + self.ssl_args = ssl_args + else: + self.ssl_args = None + if backlog is not None: + if hasattr(self, 'socket'): + raise TypeError('backlog must be None when a socket instance is passed') + self.backlog = backlog + except: + self.close() + raise + + @property + def ssl_enabled(self): + return self.ssl_args is not None + + def set_listener(self, listener): + BaseServer.set_listener(self, listener) + try: + self.socket = self.socket._sock + except AttributeError: + pass + + def init_socket(self): + if not hasattr(self, 'socket'): + # FIXME: clean up the socket lifetime + # pylint:disable=attribute-defined-outside-init + self.socket = self.get_listener(self.address, self.backlog, self.family) + self.address = self.socket.getsockname() + if self.ssl_args: + self._handle = self.wrap_socket_and_handle + else: + self._handle = self.handle + + @classmethod + def get_listener(cls, address, backlog=None, family=None): + if backlog is None: + backlog = cls.backlog + return _tcp_listener(address, backlog=backlog, reuse_addr=cls.reuse_addr, family=family) + + if PY3: + + def do_read(self): + sock = self.socket + try: + fd, address = sock._accept() + except BlockingIOError: # python 2: pylint: disable=undefined-variable + if not sock.timeout: + return + raise + sock = socket(sock.family, sock.type, sock.proto, fileno=fd) + # XXX Python issue #7995? + return sock, address + + else: + + def do_read(self): + try: + client_socket, address = self.socket.accept() + except _socket.error as err: + if err.args[0] == EWOULDBLOCK: + return + raise + sockobj = socket(_sock=client_socket) + if PYPY: + client_socket._drop() + return sockobj, address + + def do_close(self, sock, *args): + # pylint:disable=arguments-differ + sock.close() + + def wrap_socket_and_handle(self, client_socket, address): + # used in case of ssl sockets + ssl_socket = self.wrap_socket(client_socket, **self.ssl_args) + return self.handle(ssl_socket, address) + + +class DatagramServer(BaseServer): + """A UDP server""" + + reuse_addr = DEFAULT_REUSE_ADDR + + def __init__(self, *args, **kwargs): + # The raw (non-gevent) socket, if possible + self._socket = None + BaseServer.__init__(self, *args, **kwargs) + from gevent.lock import Semaphore + self._writelock = Semaphore() + + def init_socket(self): + if not hasattr(self, 'socket'): + # FIXME: clean up the socket lifetime + # pylint:disable=attribute-defined-outside-init + self.socket = self.get_listener(self.address, self.family) + self.address = self.socket.getsockname() + self._socket = self.socket + try: + self._socket = self._socket._sock + except AttributeError: + pass + + @classmethod + def get_listener(cls, address, family=None): + return _udp_socket(address, reuse_addr=cls.reuse_addr, family=family) + + def do_read(self): + try: + data, address = self._socket.recvfrom(8192) + except _socket.error as err: + if err.args[0] == EWOULDBLOCK: + return + raise + return data, address + + def sendto(self, *args): + self._writelock.acquire() + try: + self.socket.sendto(*args) + finally: + self._writelock.release() + + +def _tcp_listener(address, backlog=50, reuse_addr=None, family=_socket.AF_INET): + """A shortcut to create a TCP socket, bind it and put it into listening state.""" + sock = socket(family=family) + if reuse_addr is not None: + sock.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, reuse_addr) + try: + sock.bind(address) + except _socket.error as ex: + strerror = getattr(ex, 'strerror', None) + if strerror is not None: + ex.strerror = strerror + ': ' + repr(address) + raise + sock.listen(backlog) + sock.setblocking(0) + return sock + + +def _udp_socket(address, backlog=50, reuse_addr=None, family=_socket.AF_INET): + # backlog argument for compat with tcp_listener + # pylint:disable=unused-argument + + # we want gevent.socket.socket here + sock = socket(family=family, type=_socket.SOCK_DGRAM) + if reuse_addr is not None: + sock.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, reuse_addr) + try: + sock.bind(address) + except _socket.error as ex: + strerror = getattr(ex, 'strerror', None) + if strerror is not None: + ex.strerror = strerror + ': ' + repr(address) + raise + return sock diff --git a/python/gevent/signal.py b/python/gevent/signal.py new file mode 100644 index 0000000..fc46018 --- /dev/null +++ b/python/gevent/signal.py @@ -0,0 +1,137 @@ +""" +Cooperative implementation of special cases of :func:`signal.signal`. + +This module is designed to work with libev's child watchers, as used +by default in :func:`gevent.os.fork` Note that each ``SIGCHLD`` handler +will be run in a new greenlet when the signal is delivered (just like +:class:`gevent.hub.signal`) + +The implementations in this module are only monkey patched if +:func:`gevent.os.waitpid` is being used (the default) and if +:const:`signal.SIGCHLD` is available; see :func:`gevent.os.fork` for +information on configuring this not to be the case for advanced uses. + +.. versionadded:: 1.1b4 +""" + +from __future__ import absolute_import + +from gevent._util import _NONE as _INITIAL +from gevent._util import copy_globals + +import signal as _signal + +__implements__ = [] +__extensions__ = [] + + +_child_handler = _INITIAL + +_signal_signal = _signal.signal +_signal_getsignal = _signal.getsignal + + +def getsignal(signalnum): + """ + Exactly the same as :func:`signal.signal` except where + :const:`signal.SIGCHLD` is concerned. + + For :const:`signal.SIGCHLD`, this cooperates with :func:`signal` + to provide consistent answers. + """ + if signalnum != _signal.SIGCHLD: + return _signal_getsignal(signalnum) + + global _child_handler + if _child_handler is _INITIAL: + _child_handler = _signal_getsignal(_signal.SIGCHLD) + + return _child_handler + + +def signal(signalnum, handler): + """ + Exactly the same as :func:`signal.signal` except where + :const:`signal.SIGCHLD` is concerned. + + .. note:: + + A :const:`signal.SIGCHLD` handler installed with this function + will only be triggered for children that are forked using + :func:`gevent.os.fork` (:func:`gevent.os.fork_and_watch`); + children forked before monkey patching, or otherwise by the raw + :func:`os.fork`, will not trigger the handler installed by this + function. (It's unlikely that a SIGCHLD handler installed with + the builtin :func:`signal.signal` would be triggered either; + libev typically overwrites such a handler at the C level. At + the very least, it's full of race conditions.) + + .. note:: + + Use of ``SIG_IGN`` and ``SIG_DFL`` may also have race conditions + with libev child watchers and the :mod:`gevent.subprocess` module. + + .. versionchanged:: 1.2a1 + If ``SIG_IGN`` or ``SIG_DFL`` are used to ignore ``SIGCHLD``, a + future use of ``gevent.subprocess`` and libev child watchers + will once again work. However, on Python 2, use of ``os.popen`` + will fail. + + .. versionchanged:: 1.1rc2 + Allow using ``SIG_IGN`` and ``SIG_DFL`` to reset and ignore ``SIGCHLD``. + However, this allows the possibility of a race condition if ``gevent.subprocess`` + had already been used. + """ + if signalnum != _signal.SIGCHLD: + return _signal_signal(signalnum, handler) + + # TODO: raise value error if not called from the main + # greenlet, just like threads + + if handler != _signal.SIG_IGN and handler != _signal.SIG_DFL and not callable(handler): + # exact same error message raised by the stdlib + raise TypeError("signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object") + + old_handler = getsignal(signalnum) + global _child_handler + _child_handler = handler + if handler == _signal.SIG_IGN or handler == _signal.SIG_DFL: + # Allow resetting/ignoring this signal at the process level. + # Note that this conflicts with gevent.subprocess and other users + # of child watchers, until the next time gevent.subprocess/loop.install_sigchld() + # is called. + from gevent import get_hub # Are we always safe to import here? + _signal_signal(signalnum, handler) + get_hub().loop.reset_sigchld() + return old_handler + + +def _on_child_hook(): + # This is called in the hub greenlet. To let the function + # do more useful work, like use blocking functions, + # we run it in a new greenlet; see gevent.hub.signal + if callable(_child_handler): + # None is a valid value for the frame argument + from gevent import Greenlet + greenlet = Greenlet(_child_handler, _signal.SIGCHLD, None) + greenlet.switch() + + +import gevent.os + +if 'waitpid' in gevent.os.__implements__ and hasattr(_signal, 'SIGCHLD'): + # Tightly coupled here to gevent.os and its waitpid implementation; only use these + # if necessary. + gevent.os._on_child_hook = _on_child_hook + __implements__.append("signal") + __implements__.append("getsignal") +else: + # XXX: This breaks test__all__ on windows + __extensions__.append("signal") + __extensions__.append("getsignal") + +__imports__ = copy_globals(_signal, globals(), + names_to_ignore=__implements__ + __extensions__, + dunder_names_to_keep=()) + +__all__ = __implements__ + __extensions__ diff --git a/python/gevent/socket.py b/python/gevent/socket.py new file mode 100644 index 0000000..50f7a59 --- /dev/null +++ b/python/gevent/socket.py @@ -0,0 +1,106 @@ +# Copyright (c) 2009-2014 Denis Bilenko and gevent contributors. See LICENSE for details. + +"""Cooperative low-level networking interface. + +This module provides socket operations and some related functions. +The API of the functions and classes matches the API of the corresponding +items in the standard :mod:`socket` module exactly, but the synchronous functions +in this module only block the current greenlet and let the others run. + +For convenience, exceptions (like :class:`error <socket.error>` and :class:`timeout <socket.timeout>`) +as well as the constants from the :mod:`socket` module are imported into this module. +""" +# Our import magic sadly makes this warning useless +# pylint: disable=undefined-variable + +import sys +from gevent._compat import PY3 +from gevent._util import copy_globals + + +if PY3: + from gevent import _socket3 as _source # python 2: pylint:disable=no-name-in-module +else: + from gevent import _socket2 as _source + +# define some things we're expecting to overwrite; each module +# needs to define these +__implements__ = __dns__ = __all__ = __extensions__ = __imports__ = () + + +class error(Exception): + errno = None + + +def getfqdn(*args): + # pylint:disable=unused-argument + raise NotImplementedError() + +copy_globals(_source, globals(), + dunder_names_to_keep=('__implements__', '__dns__', '__all__', + '__extensions__', '__imports__', '__socket__'), + cleanup_globs=False) + +# The _socket2 and _socket3 don't import things defined in +# __extensions__, to help avoid confusing reference cycles in the +# documentation and to prevent importing from the wrong place, but we +# *do* need to expose them here. (NOTE: This may lead to some sphinx +# warnings like: +# WARNING: missing attribute mentioned in :members: or __all__: +# module gevent._socket2, attribute cancel_wait +# These can be ignored.) +from gevent import _socketcommon +copy_globals(_socketcommon, globals(), + only_names=_socketcommon.__extensions__) + +try: + _GLOBAL_DEFAULT_TIMEOUT = __socket__._GLOBAL_DEFAULT_TIMEOUT +except AttributeError: + _GLOBAL_DEFAULT_TIMEOUT = object() + + +def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None): + """Connect to *address* and return the socket object. + + Convenience function. Connect to *address* (a 2-tuple ``(host, + port)``) and return the socket object. Passing the optional + *timeout* parameter will set the timeout on the socket instance + before attempting to connect. If no *timeout* is supplied, the + global default timeout setting returned by :func:`getdefaulttimeout` + is used. If *source_address* is set it must be a tuple of (host, port) + for the socket to bind as a source address before making the connection. + A host of '' or port 0 tells the OS to use the default. + """ + + host, port = address + err = None + for res in getaddrinfo(host, port, 0 if has_ipv6 else AF_INET, SOCK_STREAM): + af, socktype, proto, _, sa = res + sock = None + try: + sock = socket(af, socktype, proto) + if timeout is not _GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + if source_address: + sock.bind(source_address) + sock.connect(sa) + return sock + except error as ex: + # without exc_clear(), if connect() fails once, the socket is referenced by the frame in exc_info + # and the next bind() fails (see test__socket.TestCreateConnection) + # that does not happen with regular sockets though, because _socket.socket.connect() is a built-in. + # this is similar to "getnameinfo loses a reference" failure in test_socket.py + if not PY3: + sys.exc_clear() # pylint:disable=no-member,useless-suppression + if sock is not None: + sock.close() + err = ex + if err is not None: + raise err # pylint:disable=raising-bad-type + else: + raise error("getaddrinfo returns an empty list") + +# This is promised to be in the __all__ of the _source, but, for circularity reasons, +# we implement it in this module. Mostly for documentation purposes, put it +# in the _source too. +_source.create_connection = create_connection diff --git a/python/gevent/ssl.py b/python/gevent/ssl.py new file mode 100644 index 0000000..42f2b1b --- /dev/null +++ b/python/gevent/ssl.py @@ -0,0 +1,26 @@ +""" +Secure Sockets Layer (SSL/TLS) module. +""" +from gevent._compat import PY2 +from gevent._util import copy_globals + +# things we expect to override, here for static analysis +def wrap_socket(_sock, **_kwargs): + # pylint:disable=unused-argument + raise NotImplementedError() + +if PY2: + if hasattr(__import__('ssl'), 'SSLContext'): + # It's not sufficient to check for >= 2.7.9; some distributions + # have backported most of PEP 466. Try to accommodate them. See Issue #702. + # We're just about to import ssl anyway so it's fine to import it here, just + # don't pollute the namespace + from gevent import _sslgte279 as _source + else: + from gevent import _ssl2 as _source # pragma: no cover +else: + # Py3 + from gevent import _ssl3 as _source # pragma: no cover + + +copy_globals(_source, globals()) diff --git a/python/gevent/subprocess.py b/python/gevent/subprocess.py new file mode 100644 index 0000000..2ea165e --- /dev/null +++ b/python/gevent/subprocess.py @@ -0,0 +1,1480 @@ +""" +Cooperative ``subprocess`` module. + +.. caution:: On POSIX platforms, this module is not usable from native + threads other than the main thread; attempting to do so will raise + a :exc:`TypeError`. This module depends on libev's fork watchers. + On POSIX systems, fork watchers are implemented using signals, and + the thread to which process-directed signals are delivered `is not + defined`_. Because each native thread has its own gevent/libev + loop, this means that a fork watcher registered with one loop + (thread) may never see the signal about a child it spawned if the + signal is sent to a different thread. + +.. note:: The interface of this module is intended to match that of + the standard library :mod:`subprocess` module (with many backwards + compatible extensions from Python 3 backported to Python 2). There + are some small differences between the Python 2 and Python 3 + versions of that module (the Python 2 ``TimeoutExpired`` exception, + notably, extends ``Timeout`` and there is no ``SubprocessError``) and between the + POSIX and Windows versions. The HTML documentation here can only + describe one version; for definitive documentation, see the + standard library or the source code. + +.. _is not defined: http://www.linuxprogrammingblog.com/all-about-linux-signals?page=11 +""" +from __future__ import absolute_import, print_function +# Can we split this up to make it cleaner? See https://github.com/gevent/gevent/issues/748 +# pylint: disable=too-many-lines +# Import magic +# pylint: disable=undefined-all-variable,undefined-variable +# Most of this we inherit from the standard lib +# pylint: disable=bare-except,too-many-locals,too-many-statements,attribute-defined-outside-init +# pylint: disable=too-many-branches,too-many-instance-attributes +# Most of this is cross-platform +# pylint: disable=no-member,expression-not-assigned,unused-argument,unused-variable +import errno +import gc +import os +import signal +import sys +import traceback +from gevent.event import AsyncResult +from gevent.hub import get_hub, linkproxy, sleep, getcurrent +from gevent._compat import integer_types, string_types, xrange +from gevent._compat import PY3 +from gevent._compat import reraise +from gevent._util import _NONE +from gevent._util import copy_globals +from gevent.fileobject import FileObject +from gevent.greenlet import Greenlet, joinall +spawn = Greenlet.spawn +import subprocess as __subprocess__ + + +# Standard functions and classes that this module re-implements in a gevent-aware way. +__implements__ = [ + 'Popen', + 'call', + 'check_call', + 'check_output', +] +if PY3 and not sys.platform.startswith('win32'): + __implements__.append("_posixsubprocess") + _posixsubprocess = None + +# Some symbols we define that we expect to export; +# useful for static analysis +PIPE = "PIPE should be imported" + +# Standard functions and classes that this module re-imports. +__imports__ = [ + 'PIPE', + 'STDOUT', + 'CalledProcessError', + # Windows: + 'CREATE_NEW_CONSOLE', + 'CREATE_NEW_PROCESS_GROUP', + 'STD_INPUT_HANDLE', + 'STD_OUTPUT_HANDLE', + 'STD_ERROR_HANDLE', + 'SW_HIDE', + 'STARTF_USESTDHANDLES', + 'STARTF_USESHOWWINDOW', +] + + +__extra__ = [ + 'MAXFD', + '_eintr_retry_call', + 'STARTUPINFO', + 'pywintypes', + 'list2cmdline', + '_subprocess', + '_winapi', + # Python 2.5 does not have _subprocess, so we don't use it + # XXX We don't run on Py 2.5 anymore; can/could/should we use _subprocess? + # It's only used on mswindows + 'WAIT_OBJECT_0', + 'WaitForSingleObject', + 'GetExitCodeProcess', + 'GetStdHandle', + 'CreatePipe', + 'DuplicateHandle', + 'GetCurrentProcess', + 'DUPLICATE_SAME_ACCESS', + 'GetModuleFileName', + 'GetVersion', + 'CreateProcess', + 'INFINITE', + 'TerminateProcess', + + # These were added for 3.5, but we make them available everywhere. + 'run', + 'CompletedProcess', +] + +if sys.version_info[:2] >= (3, 3): + __imports__ += [ + 'DEVNULL', + 'getstatusoutput', + 'getoutput', + 'SubprocessError', + 'TimeoutExpired', + ] +else: + __extra__.append("TimeoutExpired") + + +if sys.version_info[:2] >= (3, 5): + __extra__.remove('run') + __extra__.remove('CompletedProcess') + __implements__.append('run') + __implements__.append('CompletedProcess') + + # Removed in Python 3.5; this is the exact code that was removed: + # https://hg.python.org/cpython/rev/f98b0a5e5ef5 + __extra__.remove('MAXFD') + try: + MAXFD = os.sysconf("SC_OPEN_MAX") + except: + MAXFD = 256 + +if sys.version_info[:2] >= (3, 6): + # This was added to __all__ for windows in 3.6 + __extra__.remove('STARTUPINFO') + __imports__.append('STARTUPINFO') + +actually_imported = copy_globals(__subprocess__, globals(), + only_names=__imports__, + ignore_missing_names=True) +# anything we couldn't import from here we may need to find +# elsewhere +__extra__.extend(set(__imports__).difference(set(actually_imported))) +__imports__ = actually_imported +del actually_imported + + +# In Python 3 on Windows, a lot of the functions previously +# in _subprocess moved to _winapi +_subprocess = getattr(__subprocess__, '_subprocess', _NONE) +_winapi = getattr(__subprocess__, '_winapi', _NONE) + +_attr_resolution_order = [__subprocess__, _subprocess, _winapi] + +for name in list(__extra__): + if name in globals(): + continue + value = _NONE + for place in _attr_resolution_order: + value = getattr(place, name, _NONE) + if value is not _NONE: + break + + if value is _NONE: + __extra__.remove(name) + else: + globals()[name] = value + +del _attr_resolution_order +__all__ = __implements__ + __imports__ +# Some other things we want to document +for _x in ('run', 'CompletedProcess', 'TimeoutExpired'): + if _x not in __all__: + __all__.append(_x) + + +mswindows = sys.platform == 'win32' +if mswindows: + import msvcrt # pylint: disable=import-error + if PY3: + class Handle(int): + closed = False + + def Close(self): + if not self.closed: + self.closed = True + _winapi.CloseHandle(self) + + def Detach(self): + if not self.closed: + self.closed = True + return int(self) + raise ValueError("already closed") + + def __repr__(self): + return "Handle(%d)" % int(self) + + __del__ = Close + __str__ = __repr__ +else: + import fcntl + import pickle + from gevent import monkey + fork = monkey.get_original('os', 'fork') + from gevent.os import fork_and_watch + +def call(*popenargs, **kwargs): + """ + call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) -> returncode + + Run command with arguments. Wait for command to complete or + timeout, then return the returncode attribute. + + The arguments are the same as for the Popen constructor. Example:: + + retcode = call(["ls", "-l"]) + + .. versionchanged:: 1.2a1 + The ``timeout`` keyword argument is now accepted on all supported + versions of Python (not just Python 3) and if it expires will raise a + :exc:`TimeoutExpired` exception (under Python 2 this is a subclass of :exc:`~.Timeout`). + """ + timeout = kwargs.pop('timeout', None) + with Popen(*popenargs, **kwargs) as p: + try: + return p.wait(timeout=timeout, _raise_exc=True) + except: + p.kill() + p.wait() + raise + +def check_call(*popenargs, **kwargs): + """ + check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) -> 0 + + Run command with arguments. Wait for command to complete. If + the exit code was zero then return, otherwise raise + :exc:`CalledProcessError`. The ``CalledProcessError`` object will have the + return code in the returncode attribute. + + The arguments are the same as for the Popen constructor. Example:: + + retcode = check_call(["ls", "-l"]) + """ + retcode = call(*popenargs, **kwargs) + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise CalledProcessError(retcode, cmd) + return 0 + +def check_output(*popenargs, **kwargs): + r""" + check_output(args, *, input=None, stdin=None, stderr=None, shell=False, universal_newlines=False, timeout=None) -> output + + Run command with arguments and return its output. + + If the exit code was non-zero it raises a :exc:`CalledProcessError`. The + ``CalledProcessError`` object will have the return code in the returncode + attribute and output in the output attribute. + + + The arguments are the same as for the Popen constructor. Example:: + + >>> check_output(["ls", "-1", "/dev/null"]) + '/dev/null\n' + + The ``stdout`` argument is not allowed as it is used internally. + + To capture standard error in the result, use ``stderr=STDOUT``:: + + >>> check_output(["/bin/sh", "-c", + ... "ls -l non_existent_file ; exit 0"], + ... stderr=STDOUT) + 'ls: non_existent_file: No such file or directory\n' + + There is an additional optional argument, "input", allowing you to + pass a string to the subprocess's stdin. If you use this argument + you may not also use the Popen constructor's "stdin" argument, as + it too will be used internally. Example:: + + >>> check_output(["sed", "-e", "s/foo/bar/"], + ... input=b"when in the course of fooman events\n") + 'when in the course of barman events\n' + + If ``universal_newlines=True`` is passed, the return value will be a + string rather than bytes. + + .. versionchanged:: 1.2a1 + The ``timeout`` keyword argument is now accepted on all supported + versions of Python (not just Python 3) and if it expires will raise a + :exc:`TimeoutExpired` exception (under Python 2 this is a subclass of :exc:`~.Timeout`). + .. versionchanged:: 1.2a1 + The ``input`` keyword argument is now accepted on all supported + versions of Python, not just Python 3 + """ + timeout = kwargs.pop('timeout', None) + if 'stdout' in kwargs: + raise ValueError('stdout argument not allowed, it will be overridden.') + if 'input' in kwargs: + if 'stdin' in kwargs: + raise ValueError('stdin and input arguments may not both be used.') + inputdata = kwargs['input'] + del kwargs['input'] + kwargs['stdin'] = PIPE + else: + inputdata = None + with Popen(*popenargs, stdout=PIPE, **kwargs) as process: + try: + output, unused_err = process.communicate(inputdata, timeout=timeout) + except TimeoutExpired: + process.kill() + output, unused_err = process.communicate() + raise TimeoutExpired(process.args, timeout, output=output) + except: + process.kill() + process.wait() + raise + retcode = process.poll() + if retcode: + raise CalledProcessError(retcode, process.args, output=output) + return output + +_PLATFORM_DEFAULT_CLOSE_FDS = object() + +if 'TimeoutExpired' not in globals(): + # Python 2 + + # Make TimeoutExpired inherit from _Timeout so it can be caught + # the way we used to throw things (except Timeout), but make sure it doesn't + # init a timer. Note that we can't have a fake 'SubprocessError' that inherits + # from exception, because we need TimeoutExpired to just be a BaseException for + # bwc. + from gevent.timeout import Timeout as _Timeout + + class TimeoutExpired(_Timeout): + """ + This exception is raised when the timeout expires while waiting for + a child process in `communicate`. + + Under Python 2, this is a gevent extension with the same name as the + Python 3 class for source-code forward compatibility. However, it extends + :class:`gevent.timeout.Timeout` for backwards compatibility (because + we used to just raise a plain ``Timeout``); note that ``Timeout`` is a + ``BaseException``, *not* an ``Exception``. + + .. versionadded:: 1.2a1 + """ + def __init__(self, cmd, timeout, output=None): + _Timeout.__init__(self, timeout, _use_timer=False) + self.cmd = cmd + self.timeout = timeout + self.output = output + + def __str__(self): + return ("Command '%s' timed out after %s seconds" % + (self.cmd, self.timeout)) + + +class Popen(object): + """ + The underlying process creation and management in this module is + handled by the Popen class. It offers a lot of flexibility so that + developers are able to handle the less common cases not covered by + the convenience functions. + + .. seealso:: :class:`subprocess.Popen` + This class should have the same interface as the standard library class. + + .. versionchanged:: 1.2a1 + Instances can now be used as context managers under Python 2.7. Previously + this was restricted to Python 3. + + .. versionchanged:: 1.2a1 + Instances now save the ``args`` attribute under Python 2.7. Previously this was + restricted to Python 3. + """ + + def __init__(self, args, bufsize=None, executable=None, + stdin=None, stdout=None, stderr=None, + preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS, shell=False, + cwd=None, env=None, universal_newlines=False, + startupinfo=None, creationflags=0, threadpool=None, + **kwargs): + """Create new Popen instance. + + :param kwargs: *Only* allowed under Python 3; under Python 2, any + unrecognized keyword arguments will result in a :exc:`TypeError`. + Under Python 3, keyword arguments can include ``pass_fds``, ``start_new_session``, + ``restore_signals``, ``encoding`` and ``errors`` + + .. versionchanged:: 1.2b1 + Add the ``encoding`` and ``errors`` parameters for Python 3. + """ + + if not PY3 and kwargs: + raise TypeError("Got unexpected keyword arguments", kwargs) + pass_fds = kwargs.pop('pass_fds', ()) + start_new_session = kwargs.pop('start_new_session', False) + restore_signals = kwargs.pop('restore_signals', True) + # Added in 3.6. These are kept as ivars + encoding = self.encoding = kwargs.pop('encoding', None) + errors = self.errors = kwargs.pop('errors', None) + + hub = get_hub() + + if bufsize is None: + # bufsize has different defaults on Py3 and Py2 + if PY3: + bufsize = -1 + else: + bufsize = 0 + if not isinstance(bufsize, integer_types): + raise TypeError("bufsize must be an integer") + + if mswindows: + if preexec_fn is not None: + raise ValueError("preexec_fn is not supported on Windows " + "platforms") + any_stdio_set = (stdin is not None or stdout is not None or + stderr is not None) + if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: + if any_stdio_set: + close_fds = False + else: + close_fds = True + elif close_fds and any_stdio_set: + raise ValueError("close_fds is not supported on Windows " + "platforms if you redirect stdin/stdout/stderr") + if threadpool is None: + threadpool = hub.threadpool + self.threadpool = threadpool + self._waiting = False + else: + # POSIX + if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: + # close_fds has different defaults on Py3/Py2 + if PY3: # pylint: disable=simplifiable-if-statement + close_fds = True + else: + close_fds = False + + if pass_fds and not close_fds: + import warnings + warnings.warn("pass_fds overriding close_fds.", RuntimeWarning) + close_fds = True + if startupinfo is not None: + raise ValueError("startupinfo is only supported on Windows " + "platforms") + if creationflags != 0: + raise ValueError("creationflags is only supported on Windows " + "platforms") + assert threadpool is None + self._loop = hub.loop + + self.args = args # Previously this was Py3 only. + self.stdin = None + self.stdout = None + self.stderr = None + self.pid = None + self.returncode = None + self.universal_newlines = universal_newlines + self.result = AsyncResult() + + # Input and output objects. The general principle is like + # this: + # + # Parent Child + # ------ ----- + # p2cwrite ---stdin---> p2cread + # c2pread <--stdout--- c2pwrite + # errread <--stderr--- errwrite + # + # On POSIX, the child objects are file descriptors. On + # Windows, these are Windows file handles. The parent objects + # are file descriptors on both platforms. The parent objects + # are None when not using PIPEs. The child objects are None + # when not redirecting. + + (p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite) = self._get_handles(stdin, stdout, stderr) + + # We wrap OS handles *before* launching the child, otherwise a + # quickly terminating child could make our fds unwrappable + # (see #8458). + if mswindows: + if p2cwrite is not None: + p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) + if c2pread is not None: + c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) + if errread is not None: + errread = msvcrt.open_osfhandle(errread.Detach(), 0) + + text_mode = PY3 and (self.encoding or self.errors or universal_newlines) + + if p2cwrite is not None: + if PY3 and text_mode: + # Under Python 3, if we left on the 'b' we'd get different results + # depending on whether we used FileObjectPosix or FileObjectThread + self.stdin = FileObject(p2cwrite, 'wb', bufsize) + self.stdin.translate_newlines(None, + write_through=True, + line_buffering=(bufsize == 1), + encoding=self.encoding, errors=self.errors) + else: + self.stdin = FileObject(p2cwrite, 'wb', bufsize) + if c2pread is not None: + if universal_newlines or text_mode: + if PY3: + # FileObjectThread doesn't support the 'U' qualifier + # with a bufsize of 0 + self.stdout = FileObject(c2pread, 'rb', bufsize) + # NOTE: Universal Newlines are broken on Windows/Py3, at least + # in some cases. This is true in the stdlib subprocess module + # as well; the following line would fix the test cases in + # test__subprocess.py that depend on python_universal_newlines, + # but would be inconsistent with the stdlib: + #msvcrt.setmode(self.stdout.fileno(), os.O_TEXT) + self.stdout.translate_newlines('r', encoding=self.encoding, errors=self.errors) + else: + self.stdout = FileObject(c2pread, 'rU', bufsize) + else: + self.stdout = FileObject(c2pread, 'rb', bufsize) + if errread is not None: + if universal_newlines or text_mode: + if PY3: + self.stderr = FileObject(errread, 'rb', bufsize) + self.stderr.translate_newlines(None, encoding=encoding, errors=errors) + else: + self.stderr = FileObject(errread, 'rU', bufsize) + else: + self.stderr = FileObject(errread, 'rb', bufsize) + + self._closed_child_pipe_fds = False + try: + self._execute_child(args, executable, preexec_fn, close_fds, + pass_fds, cwd, env, universal_newlines, + startupinfo, creationflags, shell, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite, + restore_signals, start_new_session) + except: + # Cleanup if the child failed starting. + # (gevent: New in python3, but reported as gevent bug in #347. + # Note that under Py2, any error raised below will replace the + # original error so we have to use reraise) + if not PY3: + exc_info = sys.exc_info() + for f in filter(None, (self.stdin, self.stdout, self.stderr)): + try: + f.close() + except (OSError, IOError): + pass # Ignore EBADF or other errors. + + if not self._closed_child_pipe_fds: + to_close = [] + if stdin == PIPE: + to_close.append(p2cread) + if stdout == PIPE: + to_close.append(c2pwrite) + if stderr == PIPE: + to_close.append(errwrite) + if hasattr(self, '_devnull'): + to_close.append(self._devnull) + for fd in to_close: + try: + os.close(fd) + except (OSError, IOError): + pass + if not PY3: + try: + reraise(*exc_info) + finally: + del exc_info + raise + + def __repr__(self): + return '<%s at 0x%x pid=%r returncode=%r>' % (self.__class__.__name__, id(self), self.pid, self.returncode) + + def _on_child(self, watcher): + watcher.stop() + status = watcher.rstatus + if os.WIFSIGNALED(status): + self.returncode = -os.WTERMSIG(status) + else: + self.returncode = os.WEXITSTATUS(status) + self.result.set(self.returncode) + + def _get_devnull(self): + if not hasattr(self, '_devnull'): + self._devnull = os.open(os.devnull, os.O_RDWR) + return self._devnull + + _stdout_buffer = None + _stderr_buffer = None + + def communicate(self, input=None, timeout=None): + """Interact with process: Send data to stdin. Read data from + stdout and stderr, until end-of-file is reached. Wait for + process to terminate. The optional input argument should be a + string to be sent to the child process, or None, if no data + should be sent to the child. + + communicate() returns a tuple (stdout, stderr). + + :keyword timeout: Under Python 2, this is a gevent extension; if + given and it expires, we will raise :exc:`TimeoutExpired`, which + extends :exc:`gevent.timeout.Timeout` (note that this only extends :exc:`BaseException`, + *not* :exc:`Exception`) + Under Python 3, this raises the standard :exc:`TimeoutExpired` exception. + + .. versionchanged:: 1.1a2 + Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout` + exception. Previously, we silently returned. + .. versionchanged:: 1.1b5 + Honor a *timeout* even if there's no way to communicate with the child + (stdin, stdout, and stderr are not pipes). + """ + greenlets = [] + if self.stdin: + greenlets.append(spawn(write_and_close, self.stdin, input)) + + # If the timeout parameter is used, and the caller calls back after + # getting a TimeoutExpired exception, we can wind up with multiple + # greenlets trying to run and read from and close stdout/stderr. + # That's bad because it can lead to 'RuntimeError: reentrant call in io.BufferedReader'. + # We can't just kill the previous greenlets when a timeout happens, + # though, because we risk losing the output collected by that greenlet + # (and Python 3, where timeout is an official parameter, explicitly says + # that no output should be lost in the event of a timeout.) Instead, we're + # watching for the exception and ignoring it. It's not elegant, + # but it works + if self.stdout: + def _read_out(): + try: + data = self.stdout.read() + except RuntimeError: + return + if self._stdout_buffer is not None: + self._stdout_buffer += data + else: + self._stdout_buffer = data + stdout = spawn(_read_out) + greenlets.append(stdout) + else: + stdout = None + + if self.stderr: + def _read_err(): + try: + data = self.stderr.read() + except RuntimeError: + return + if self._stderr_buffer is not None: + self._stderr_buffer += data + else: + self._stderr_buffer = data + stderr = spawn(_read_err) + greenlets.append(stderr) + else: + stderr = None + + # If we were given stdin=stdout=stderr=None, we have no way to + # communicate with the child, and thus no greenlets to wait + # on. This is a nonsense case, but it comes up in the test + # case for Python 3.5 (test_subprocess.py + # RunFuncTestCase.test_timeout). Instead, we go directly to + # self.wait + if not greenlets and timeout is not None: + self.wait(timeout=timeout, _raise_exc=True) + + done = joinall(greenlets, timeout=timeout) + if timeout is not None and len(done) != len(greenlets): + raise TimeoutExpired(self.args, timeout) + + if self.stdout: + try: + self.stdout.close() + except RuntimeError: + pass + if self.stderr: + try: + self.stderr.close() + except RuntimeError: + pass + self.wait() + stdout_value = self._stdout_buffer + self._stdout_buffer = None + stderr_value = self._stderr_buffer + self._stderr_buffer = None + # XXX: Under python 3 in universal newlines mode we should be + # returning str, not bytes + return (None if stdout is None else stdout_value or b'', + None if stderr is None else stderr_value or b'') + + def poll(self): + """Check if child process has terminated. Set and return :attr:`returncode` attribute.""" + return self._internal_poll() + + def __enter__(self): + return self + + def __exit__(self, t, v, tb): + if self.stdout: + self.stdout.close() + if self.stderr: + self.stderr.close() + try: # Flushing a BufferedWriter may raise an error + if self.stdin: + self.stdin.close() + finally: + # Wait for the process to terminate, to avoid zombies. + # JAM: gevent: If the process never terminates, this + # blocks forever. + self.wait() + + def _gevent_result_wait(self, timeout=None, raise_exc=PY3): + result = self.result.wait(timeout=timeout) + if raise_exc and timeout is not None and not self.result.ready(): + raise TimeoutExpired(self.args, timeout) + return result + + + if mswindows: + # + # Windows methods + # + def _get_handles(self, stdin, stdout, stderr): + """Construct and return tuple with IO objects: + p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite + """ + if stdin is None and stdout is None and stderr is None: + return (None, None, None, None, None, None) + + p2cread, p2cwrite = None, None + c2pread, c2pwrite = None, None + errread, errwrite = None, None + + try: + DEVNULL + except NameError: + _devnull = object() + else: + _devnull = DEVNULL + + if stdin is None: + p2cread = GetStdHandle(STD_INPUT_HANDLE) + if p2cread is None: + p2cread, _ = CreatePipe(None, 0) + if PY3: + p2cread = Handle(p2cread) + _winapi.CloseHandle(_) + elif stdin == PIPE: + p2cread, p2cwrite = CreatePipe(None, 0) + if PY3: + p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite) + elif stdin == _devnull: + p2cread = msvcrt.get_osfhandle(self._get_devnull()) + elif isinstance(stdin, int): + p2cread = msvcrt.get_osfhandle(stdin) + else: + # Assuming file-like object + p2cread = msvcrt.get_osfhandle(stdin.fileno()) + p2cread = self._make_inheritable(p2cread) + + if stdout is None: + c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE) + if c2pwrite is None: + _, c2pwrite = CreatePipe(None, 0) + if PY3: + c2pwrite = Handle(c2pwrite) + _winapi.CloseHandle(_) + elif stdout == PIPE: + c2pread, c2pwrite = CreatePipe(None, 0) + if PY3: + c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite) + elif stdout == _devnull: + c2pwrite = msvcrt.get_osfhandle(self._get_devnull()) + elif isinstance(stdout, int): + c2pwrite = msvcrt.get_osfhandle(stdout) + else: + # Assuming file-like object + c2pwrite = msvcrt.get_osfhandle(stdout.fileno()) + c2pwrite = self._make_inheritable(c2pwrite) + + if stderr is None: + errwrite = GetStdHandle(STD_ERROR_HANDLE) + if errwrite is None: + _, errwrite = CreatePipe(None, 0) + if PY3: + errwrite = Handle(errwrite) + _winapi.CloseHandle(_) + elif stderr == PIPE: + errread, errwrite = CreatePipe(None, 0) + if PY3: + errread, errwrite = Handle(errread), Handle(errwrite) + elif stderr == STDOUT: + errwrite = c2pwrite + elif stderr == _devnull: + errwrite = msvcrt.get_osfhandle(self._get_devnull()) + elif isinstance(stderr, int): + errwrite = msvcrt.get_osfhandle(stderr) + else: + # Assuming file-like object + errwrite = msvcrt.get_osfhandle(stderr.fileno()) + errwrite = self._make_inheritable(errwrite) + + return (p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite) + + def _make_inheritable(self, handle): + """Return a duplicate of handle, which is inheritable""" + return DuplicateHandle(GetCurrentProcess(), + handle, GetCurrentProcess(), 0, 1, + DUPLICATE_SAME_ACCESS) + + def _find_w9xpopen(self): + """Find and return absolute path to w9xpopen.exe""" + w9xpopen = os.path.join(os.path.dirname(GetModuleFileName(0)), + "w9xpopen.exe") + if not os.path.exists(w9xpopen): + # Eeek - file-not-found - possibly an embedding + # situation - see if we can locate it in sys.exec_prefix + w9xpopen = os.path.join(os.path.dirname(sys.exec_prefix), + "w9xpopen.exe") + if not os.path.exists(w9xpopen): + raise RuntimeError("Cannot locate w9xpopen.exe, which is " + "needed for Popen to work with your " + "shell or platform.") + return w9xpopen + + def _execute_child(self, args, executable, preexec_fn, close_fds, + pass_fds, cwd, env, universal_newlines, + startupinfo, creationflags, shell, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite, + unused_restore_signals, unused_start_new_session): + """Execute program (MS Windows version)""" + + assert not pass_fds, "pass_fds not supported on Windows." + + if not isinstance(args, string_types): + args = list2cmdline(args) + + # Process startup details + if startupinfo is None: + startupinfo = STARTUPINFO() + if None not in (p2cread, c2pwrite, errwrite): + startupinfo.dwFlags |= STARTF_USESTDHANDLES + startupinfo.hStdInput = p2cread + startupinfo.hStdOutput = c2pwrite + startupinfo.hStdError = errwrite + + if shell: + startupinfo.dwFlags |= STARTF_USESHOWWINDOW + startupinfo.wShowWindow = SW_HIDE + comspec = os.environ.get("COMSPEC", "cmd.exe") + args = '{} /c "{}"'.format(comspec, args) + if GetVersion() >= 0x80000000 or os.path.basename(comspec).lower() == "command.com": + # Win9x, or using command.com on NT. We need to + # use the w9xpopen intermediate program. For more + # information, see KB Q150956 + # (http://web.archive.org/web/20011105084002/http://support.microsoft.com/support/kb/articles/Q150/9/56.asp) + w9xpopen = self._find_w9xpopen() + args = '"%s" %s' % (w9xpopen, args) + # Not passing CREATE_NEW_CONSOLE has been known to + # cause random failures on win9x. Specifically a + # dialog: "Your program accessed mem currently in + # use at xxx" and a hopeful warning about the + # stability of your system. Cost is Ctrl+C wont + # kill children. + creationflags |= CREATE_NEW_CONSOLE + + # Start the process + try: + hp, ht, pid, tid = CreateProcess(executable, args, + # no special security + None, None, + int(not close_fds), + creationflags, + env, + cwd, + startupinfo) + except IOError as e: # From 2.6 on, pywintypes.error was defined as IOError + # Translate pywintypes.error to WindowsError, which is + # a subclass of OSError. FIXME: We should really + # translate errno using _sys_errlist (or similar), but + # how can this be done from Python? + if PY3: + raise # don't remap here + raise WindowsError(*e.args) + finally: + # Child is launched. Close the parent's copy of those pipe + # handles that only the child should have open. You need + # to make sure that no handles to the write end of the + # output pipe are maintained in this process or else the + # pipe will not close when the child process exits and the + # ReadFile will hang. + def _close(x): + if x is not None and x != -1: + if hasattr(x, 'Close'): + x.Close() + else: + _winapi.CloseHandle(x) + + _close(p2cread) + _close(c2pwrite) + _close(errwrite) + if hasattr(self, '_devnull'): + os.close(self._devnull) + + # Retain the process handle, but close the thread handle + self._child_created = True + self._handle = Handle(hp) if not hasattr(hp, 'Close') else hp + self.pid = pid + _winapi.CloseHandle(ht) if not hasattr(ht, 'Close') else ht.Close() + + def _internal_poll(self): + """Check if child process has terminated. Returns returncode + attribute. + """ + if self.returncode is None: + if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: + self.returncode = GetExitCodeProcess(self._handle) + self.result.set(self.returncode) + return self.returncode + + def rawlink(self, callback): + if not self.result.ready() and not self._waiting: + self._waiting = True + Greenlet.spawn(self._wait) + self.result.rawlink(linkproxy(callback, self)) + # XXX unlink + + def _blocking_wait(self): + WaitForSingleObject(self._handle, INFINITE) + self.returncode = GetExitCodeProcess(self._handle) + return self.returncode + + def _wait(self): + self.threadpool.spawn(self._blocking_wait).rawlink(self.result) + + def wait(self, timeout=None, _raise_exc=PY3): + """Wait for child process to terminate. Returns returncode + attribute.""" + if self.returncode is None: + if not self._waiting: + self._waiting = True + self._wait() + return self._gevent_result_wait(timeout, _raise_exc) + + def send_signal(self, sig): + """Send a signal to the process + """ + if sig == signal.SIGTERM: + self.terminate() + elif sig == signal.CTRL_C_EVENT: + os.kill(self.pid, signal.CTRL_C_EVENT) + elif sig == signal.CTRL_BREAK_EVENT: + os.kill(self.pid, signal.CTRL_BREAK_EVENT) + else: + raise ValueError("Unsupported signal: {}".format(sig)) + + def terminate(self): + """Terminates the process + """ + TerminateProcess(self._handle, 1) + + kill = terminate + + else: + # + # POSIX methods + # + + def rawlink(self, callback): + # Not public documented, part of the link protocol + self.result.rawlink(linkproxy(callback, self)) + # XXX unlink + + def _get_handles(self, stdin, stdout, stderr): + """Construct and return tuple with IO objects: + p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite + """ + p2cread, p2cwrite = None, None + c2pread, c2pwrite = None, None + errread, errwrite = None, None + + try: + DEVNULL + except NameError: + _devnull = object() + else: + _devnull = DEVNULL + + if stdin is None: + pass + elif stdin == PIPE: + p2cread, p2cwrite = self.pipe_cloexec() + elif stdin == _devnull: + p2cread = self._get_devnull() + elif isinstance(stdin, int): + p2cread = stdin + else: + # Assuming file-like object + p2cread = stdin.fileno() + + if stdout is None: + pass + elif stdout == PIPE: + c2pread, c2pwrite = self.pipe_cloexec() + elif stdout == _devnull: + c2pwrite = self._get_devnull() + elif isinstance(stdout, int): + c2pwrite = stdout + else: + # Assuming file-like object + c2pwrite = stdout.fileno() + + if stderr is None: + pass + elif stderr == PIPE: + errread, errwrite = self.pipe_cloexec() + elif stderr == STDOUT: + errwrite = c2pwrite + elif stderr == _devnull: + errwrite = self._get_devnull() + elif isinstance(stderr, int): + errwrite = stderr + else: + # Assuming file-like object + errwrite = stderr.fileno() + + return (p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite) + + def _set_cloexec_flag(self, fd, cloexec=True): + try: + cloexec_flag = fcntl.FD_CLOEXEC + except AttributeError: + cloexec_flag = 1 + + old = fcntl.fcntl(fd, fcntl.F_GETFD) + if cloexec: + fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag) + else: + fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag) + + def _remove_nonblock_flag(self, fd): + flags = fcntl.fcntl(fd, fcntl.F_GETFL) & (~os.O_NONBLOCK) + fcntl.fcntl(fd, fcntl.F_SETFL, flags) + + def pipe_cloexec(self): + """Create a pipe with FDs set CLOEXEC.""" + # Pipes' FDs are set CLOEXEC by default because we don't want them + # to be inherited by other subprocesses: the CLOEXEC flag is removed + # from the child's FDs by _dup2(), between fork() and exec(). + # This is not atomic: we would need the pipe2() syscall for that. + r, w = os.pipe() + self._set_cloexec_flag(r) + self._set_cloexec_flag(w) + return r, w + + def _close_fds(self, keep): + # `keep` is a set of fds, so we + # use os.closerange from 3 to min(keep) + # and then from max(keep + 1) to MAXFD and + # loop through filling in the gaps. + # Under new python versions, we need to explicitly set + # passed fds to be inheritable or they will go away on exec + if hasattr(os, 'set_inheritable'): + set_inheritable = os.set_inheritable + else: + set_inheritable = lambda i, v: True + if hasattr(os, 'closerange'): + keep = sorted(keep) + min_keep = min(keep) + max_keep = max(keep) + os.closerange(3, min_keep) + os.closerange(max_keep + 1, MAXFD) + for i in xrange(min_keep, max_keep): + if i in keep: + set_inheritable(i, True) + continue + + try: + os.close(i) + except: + pass + else: + for i in xrange(3, MAXFD): + if i in keep: + set_inheritable(i, True) + continue + try: + os.close(i) + except: + pass + + def _execute_child(self, args, executable, preexec_fn, close_fds, + pass_fds, cwd, env, universal_newlines, + startupinfo, creationflags, shell, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite, + restore_signals, start_new_session): + """Execute program (POSIX version)""" + + if PY3 and isinstance(args, (str, bytes)): + args = [args] + elif not PY3 and isinstance(args, string_types): + args = [args] + else: + args = list(args) + + if shell: + args = ["/bin/sh", "-c"] + args + if executable: + args[0] = executable + + if executable is None: + executable = args[0] + + self._loop.install_sigchld() + + # For transferring possible exec failure from child to parent + # The first char specifies the exception type: 0 means + # OSError, 1 means some other error. + errpipe_read, errpipe_write = self.pipe_cloexec() + # errpipe_write must not be in the standard io 0, 1, or 2 fd range. + low_fds_to_close = [] + while errpipe_write < 3: + low_fds_to_close.append(errpipe_write) + errpipe_write = os.dup(errpipe_write) + for low_fd in low_fds_to_close: + os.close(low_fd) + try: + try: + gc_was_enabled = gc.isenabled() + # Disable gc to avoid bug where gc -> file_dealloc -> + # write to stderr -> hang. http://bugs.python.org/issue1336 + gc.disable() + try: + self.pid = fork_and_watch(self._on_child, self._loop, True, fork) + except: + if gc_was_enabled: + gc.enable() + raise + if self.pid == 0: + # Child + try: + # Close parent's pipe ends + if p2cwrite is not None: + os.close(p2cwrite) + if c2pread is not None: + os.close(c2pread) + if errread is not None: + os.close(errread) + os.close(errpipe_read) + + # When duping fds, if there arises a situation + # where one of the fds is either 0, 1 or 2, it + # is possible that it is overwritten (#12607). + if c2pwrite == 0: + c2pwrite = os.dup(c2pwrite) + if errwrite == 0 or errwrite == 1: + errwrite = os.dup(errwrite) + + # Dup fds for child + def _dup2(a, b): + # dup2() removes the CLOEXEC flag but + # we must do it ourselves if dup2() + # would be a no-op (issue #10806). + if a == b: + self._set_cloexec_flag(a, False) + elif a is not None: + os.dup2(a, b) + self._remove_nonblock_flag(b) + _dup2(p2cread, 0) + _dup2(c2pwrite, 1) + _dup2(errwrite, 2) + + # Close pipe fds. Make sure we don't close the + # same fd more than once, or standard fds. + closed = set([None]) + for fd in [p2cread, c2pwrite, errwrite]: + if fd not in closed and fd > 2: + os.close(fd) + closed.add(fd) + + if cwd is not None: + os.chdir(cwd) + + if preexec_fn: + preexec_fn() + + # Close all other fds, if asked for. This must be done + # after preexec_fn runs. + if close_fds: + fds_to_keep = set(pass_fds) + fds_to_keep.add(errpipe_write) + self._close_fds(fds_to_keep) + elif hasattr(os, 'get_inheritable'): + # close_fds was false, and we're on + # Python 3.4 or newer, so "all file + # descriptors except standard streams + # are closed, and inheritable handles + # are only inherited if the close_fds + # parameter is False." + for i in xrange(3, MAXFD): + try: + if i == errpipe_write or os.get_inheritable(i): + continue + os.close(i) + except: + pass + + if restore_signals: + # restore the documented signals back to sig_dfl; + # not all will be defined on every platform + for sig in 'SIGPIPE', 'SIGXFZ', 'SIGXFSZ': + sig = getattr(signal, sig, None) + if sig is not None: + signal.signal(sig, signal.SIG_DFL) + + if start_new_session: + os.setsid() + + if env is None: + os.execvp(executable, args) + else: + if PY3: + # Python 3.6 started testing for + # bytes values in the env; it also + # started encoding strs using + # fsencode and using a lower-level + # API that takes a list of keys + # and values. We don't have access + # to that API, so we go the reverse direction. + env = {os.fsdecode(k) if isinstance(k, bytes) else k: + os.fsdecode(v) if isinstance(v, bytes) else v + for k, v in env.items()} + os.execvpe(executable, args, env) + + except: + exc_type, exc_value, tb = sys.exc_info() + # Save the traceback and attach it to the exception object + exc_lines = traceback.format_exception(exc_type, + exc_value, + tb) + exc_value.child_traceback = ''.join(exc_lines) + os.write(errpipe_write, pickle.dumps(exc_value)) + + finally: + # Make sure that the process exits no matter what. + # The return code does not matter much as it won't be + # reported to the application + os._exit(1) + + # Parent + self._child_created = True + if gc_was_enabled: + gc.enable() + finally: + # be sure the FD is closed no matter what + os.close(errpipe_write) + + # self._devnull is not always defined. + devnull_fd = getattr(self, '_devnull', None) + if p2cread is not None and p2cwrite is not None and p2cread != devnull_fd: + os.close(p2cread) + if c2pwrite is not None and c2pread is not None and c2pwrite != devnull_fd: + os.close(c2pwrite) + if errwrite is not None and errread is not None and errwrite != devnull_fd: + os.close(errwrite) + if devnull_fd is not None: + os.close(devnull_fd) + # Prevent a double close of these fds from __init__ on error. + self._closed_child_pipe_fds = True + + # Wait for exec to fail or succeed; possibly raising exception + errpipe_read = FileObject(errpipe_read, 'rb') + data = errpipe_read.read() + finally: + if hasattr(errpipe_read, 'close'): + errpipe_read.close() + else: + os.close(errpipe_read) + + if data != b"": + self.wait() + child_exception = pickle.loads(data) + for fd in (p2cwrite, c2pread, errread): + if fd is not None: + os.close(fd) + raise child_exception + + def _handle_exitstatus(self, sts): + if os.WIFSIGNALED(sts): + self.returncode = -os.WTERMSIG(sts) + elif os.WIFEXITED(sts): + self.returncode = os.WEXITSTATUS(sts) + else: + # Should never happen + raise RuntimeError("Unknown child exit status!") + + def _internal_poll(self): + """Check if child process has terminated. Returns returncode + attribute. + """ + if self.returncode is None: + if get_hub() is not getcurrent(): + sig_pending = getattr(self._loop, 'sig_pending', True) + if sig_pending: + sleep(0.00001) + return self.returncode + + def wait(self, timeout=None, _raise_exc=PY3): + """ + Wait for child process to terminate. Returns :attr:`returncode` + attribute. + + :keyword timeout: The floating point number of seconds to + wait. Under Python 2, this is a gevent extension, and + we simply return if it expires. Under Python 3, if + this time elapses without finishing the process, + :exc:`TimeoutExpired` is raised. + """ + return self._gevent_result_wait(timeout, _raise_exc) + + def send_signal(self, sig): + """Send a signal to the process + """ + # Skip signalling a process that we know has already died. + if self.returncode is None: + os.kill(self.pid, sig) + + def terminate(self): + """Terminate the process with SIGTERM + """ + self.send_signal(signal.SIGTERM) + + def kill(self): + """Kill the process with SIGKILL + """ + self.send_signal(signal.SIGKILL) + + +def write_and_close(fobj, data): + try: + if data: + fobj.write(data) + if hasattr(fobj, 'flush'): + # 3.6 started expecting flush to be called. + fobj.flush() + except (OSError, IOError) as ex: + if ex.errno != errno.EPIPE and ex.errno != errno.EINVAL: + raise + finally: + try: + fobj.close() + except EnvironmentError: + pass + +def _with_stdout_stderr(exc, stderr): + # Prior to Python 3.5, most exceptions didn't have stdout + # and stderr attributes and can't take the stderr attribute in their + # constructor + exc.stdout = exc.output + exc.stderr = stderr + return exc + +class CompletedProcess(object): + """ + A process that has finished running. + + This is returned by run(). + + Attributes: + - args: The list or str args passed to run(). + - returncode: The exit code of the process, negative for signals. + - stdout: The standard output (None if not captured). + - stderr: The standard error (None if not captured). + + .. versionadded:: 1.2a1 + This first appeared in Python 3.5 and is available to all + Python versions in gevent. + """ + def __init__(self, args, returncode, stdout=None, stderr=None): + self.args = args + self.returncode = returncode + self.stdout = stdout + self.stderr = stderr + + def __repr__(self): + args = ['args={!r}'.format(self.args), + 'returncode={!r}'.format(self.returncode)] + if self.stdout is not None: + args.append('stdout={!r}'.format(self.stdout)) + if self.stderr is not None: + args.append('stderr={!r}'.format(self.stderr)) + return "{}({})".format(type(self).__name__, ', '.join(args)) + + def check_returncode(self): + """Raise CalledProcessError if the exit code is non-zero.""" + if self.returncode: + raise _with_stdout_stderr(CalledProcessError(self.returncode, self.args, self.stdout), self.stderr) + + +def run(*popenargs, **kwargs): + """ + run(args, *, stdin=None, input=None, stdout=None, stderr=None, shell=False, timeout=None, check=False) -> CompletedProcess + + Run command with arguments and return a CompletedProcess instance. + + The returned instance will have attributes args, returncode, stdout and + stderr. By default, stdout and stderr are not captured, and those attributes + will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them. + If check is True and the exit code was non-zero, it raises a + CalledProcessError. The CalledProcessError object will have the return code + in the returncode attribute, and output & stderr attributes if those streams + were captured. + + If timeout is given, and the process takes too long, a TimeoutExpired + exception will be raised. + + There is an optional argument "input", allowing you to + pass a string to the subprocess's stdin. If you use this argument + you may not also use the Popen constructor's "stdin" argument, as + it will be used internally. + The other arguments are the same as for the Popen constructor. + If universal_newlines=True is passed, the "input" argument must be a + string and stdout/stderr in the returned object will be strings rather than + bytes. + + .. versionadded:: 1.2a1 + This function first appeared in Python 3.5. It is available on all Python + versions gevent supports. + """ + input = kwargs.pop('input', None) + timeout = kwargs.pop('timeout', None) + check = kwargs.pop('check', False) + + if input is not None: + if 'stdin' in kwargs: + raise ValueError('stdin and input arguments may not both be used.') + kwargs['stdin'] = PIPE + + with Popen(*popenargs, **kwargs) as process: + try: + stdout, stderr = process.communicate(input, timeout=timeout) + except TimeoutExpired: + process.kill() + stdout, stderr = process.communicate() + raise _with_stdout_stderr(TimeoutExpired(process.args, timeout, output=stdout), stderr) + except: + process.kill() + process.wait() + raise + retcode = process.poll() + if check and retcode: + raise _with_stdout_stderr(CalledProcessError(retcode, process.args, stdout), stderr) + + return CompletedProcess(process.args, retcode, stdout, stderr) diff --git a/python/gevent/thread.py b/python/gevent/thread.py new file mode 100644 index 0000000..0a1af38 --- /dev/null +++ b/python/gevent/thread.py @@ -0,0 +1,115 @@ +""" +Implementation of the standard :mod:`thread` module that spawns greenlets. + +.. note:: + + This module is a helper for :mod:`gevent.monkey` and is not + intended to be used directly. For spawning greenlets in your + applications, prefer higher level constructs like + :class:`gevent.Greenlet` class or :func:`gevent.spawn`. +""" +from __future__ import absolute_import +import sys + +__implements__ = ['allocate_lock', + 'get_ident', + 'exit', + 'LockType', + 'stack_size', + 'start_new_thread', + '_local'] + +__imports__ = ['error'] +if sys.version_info[0] <= 2: + import thread as __thread__ # pylint:disable=import-error +else: + import _thread as __thread__ # pylint:disable=import-error + __target__ = '_thread' + __imports__ += ['RLock', + 'TIMEOUT_MAX', + 'allocate', + 'exit_thread', + 'interrupt_main', + 'start_new'] +error = __thread__.error +from gevent._compat import PY3 +from gevent._compat import PYPY +from gevent._util import copy_globals +from gevent.hub import getcurrent, GreenletExit +from gevent.greenlet import Greenlet +from gevent.lock import BoundedSemaphore +from gevent.local import local as _local + + +def get_ident(gr=None): + if gr is None: + gr = getcurrent() + return id(gr) + + +def start_new_thread(function, args=(), kwargs=None): + if kwargs is not None: + greenlet = Greenlet.spawn(function, *args, **kwargs) + else: + greenlet = Greenlet.spawn(function, *args) + return get_ident(greenlet) + + +class LockType(BoundedSemaphore): + # Change the ValueError into the appropriate thread error + # and any other API changes we need to make to match behaviour + _OVER_RELEASE_ERROR = __thread__.error + + if PYPY and PY3: + _OVER_RELEASE_ERROR = RuntimeError + + if PY3: + _TIMEOUT_MAX = __thread__.TIMEOUT_MAX # python 2: pylint:disable=no-member + + def acquire(self, blocking=True, timeout=-1): + # Transform the default -1 argument into the None that our + # semaphore implementation expects, and raise the same error + # the stdlib implementation does. + if timeout == -1: + timeout = None + if not blocking and timeout is not None: + raise ValueError("can't specify a timeout for a non-blocking call") + if timeout is not None: + if timeout < 0: + # in C: if(timeout < 0 && timeout != -1) + raise ValueError("timeout value must be strictly positive") + if timeout > self._TIMEOUT_MAX: + raise OverflowError('timeout value is too large') + + return BoundedSemaphore.acquire(self, blocking, timeout) + +allocate_lock = LockType + + +def exit(): + raise GreenletExit + + +if hasattr(__thread__, 'stack_size'): + _original_stack_size = __thread__.stack_size + + def stack_size(size=None): + if size is None: + return _original_stack_size() + if size > _original_stack_size(): + return _original_stack_size(size) + else: + pass + # not going to decrease stack_size, because otherwise other greenlets in this thread will suffer +else: + __implements__.remove('stack_size') + +__imports__ = copy_globals(__thread__, globals(), + only_names=__imports__, + ignore_missing_names=True) + +__all__ = __implements__ + __imports__ +__all__.remove('_local') + +# XXX interrupt_main +# XXX _count() diff --git a/python/gevent/threading.py b/python/gevent/threading.py new file mode 100644 index 0000000..5098aed --- /dev/null +++ b/python/gevent/threading.py @@ -0,0 +1,231 @@ +""" +Implementation of the standard :mod:`threading` using greenlets. + +.. note:: + + This module is a helper for :mod:`gevent.monkey` and is not + intended to be used directly. For spawning greenlets in your + applications, prefer higher level constructs like + :class:`gevent.Greenlet` class or :func:`gevent.spawn`. +""" +from __future__ import absolute_import + + +__implements__ = [ + 'local', + '_start_new_thread', + '_allocate_lock', + 'Lock', + '_get_ident', + '_sleep', + '_DummyThread', +] + + +import threading as __threading__ +_DummyThread_ = __threading__._DummyThread +from gevent.local import local +from gevent.thread import start_new_thread as _start_new_thread, allocate_lock as _allocate_lock, get_ident as _get_ident +from gevent._compat import PYPY +from gevent.hub import sleep as _sleep, getcurrent + +# Exports, prevent unused import warnings +local = local +start_new_thread = _start_new_thread +allocate_lock = _allocate_lock +_get_ident = _get_ident +_sleep = _sleep +getcurrent = getcurrent + +Lock = _allocate_lock + + +def _cleanup(g): + __threading__._active.pop(id(g), None) + +def _make_cleanup_id(gid): + def _(_r): + __threading__._active.pop(gid, None) + return _ + +_weakref = None + +class _DummyThread(_DummyThread_): + # We avoid calling the superclass constructor. This makes us about + # twice as fast (1.16 vs 0.68usec on PyPy, 29.3 vs 17.7usec on + # CPython 2.7), and has the important effect of avoiding + # allocation and then immediate deletion of _Thread__block, a + # lock. This is especially important on PyPy where locks go + # through the cpyext API and Cython, which is known to be slow and + # potentially buggy (e.g., + # https://bitbucket.org/pypy/pypy/issues/2149/memory-leak-for-python-subclass-of-cpyext#comment-22347393) + + # These objects are constructed quite frequently in some cases, so + # the optimization matters: for example, in gunicorn, which uses + # pywsgi.WSGIServer, every request is handled in a new greenlet, + # and every request uses a logging.Logger to write the access log, + # and every call to a log method captures the current thread (by + # default). + # + # (Obviously we have to duplicate the effects of the constructor, + # at least for external state purposes, which is potentially + # slightly fragile.) + + # For the same reason, instances of this class will cleanup their own entry + # in ``threading._active`` + + # Capture the static things as class vars to save on memory/ + # construction time. + # In Py2, they're all private; in Py3, they become protected + _Thread__stopped = _is_stopped = _stopped = False + _Thread__initialized = _initialized = True + _Thread__daemonic = _daemonic = True + _Thread__args = _args = () + _Thread__kwargs = _kwargs = None + _Thread__target = _target = None + _Thread_ident = _ident = None + _Thread__started = _started = __threading__.Event() + _Thread__started.set() + _tstate_lock = None + + def __init__(self): + #_DummyThread_.__init__(self) # pylint:disable=super-init-not-called + + # It'd be nice to use a pattern like "greenlet-%d", but maybe somebody out + # there is checking thread names... + self._name = self._Thread__name = __threading__._newname("DummyThread-%d") + self._set_ident() + + g = getcurrent() + gid = _get_ident(g) # same as id(g) + __threading__._active[gid] = self + rawlink = getattr(g, 'rawlink', None) + if rawlink is not None: + # raw greenlet.greenlet greenlets don't + # have rawlink... + rawlink(_cleanup) + else: + # ... so for them we use weakrefs. + # See https://github.com/gevent/gevent/issues/918 + global _weakref + if _weakref is None: + _weakref = __import__('weakref') + ref = _weakref.ref(g, _make_cleanup_id(gid)) + self.__raw_ref = ref + + def _Thread__stop(self): + pass + + _stop = _Thread__stop # py3 + + def _wait_for_tstate_lock(self, *args, **kwargs): + # pylint:disable=arguments-differ + pass + +if hasattr(__threading__, 'main_thread'): # py 3.4+ + def main_native_thread(): + return __threading__.main_thread() # pylint:disable=no-member +else: + _main_threads = [(_k, _v) for _k, _v in __threading__._active.items() + if isinstance(_v, __threading__._MainThread)] + assert len(_main_threads) == 1, "Too many main threads" + + def main_native_thread(): + return _main_threads[0][1] + +# Make sure the MainThread can be found by our current greenlet ID, +# otherwise we get a new DummyThread, which cannot be joined. +# Fixes tests in test_threading_2 under PyPy, and generally makes things nicer +# when gevent.threading is imported before monkey patching or not at all +# XXX: This assumes that the import is happening in the "main" greenlet/thread. +# XXX: We should really only be doing this from gevent.monkey. +if _get_ident() not in __threading__._active: + _v = main_native_thread() + _k = _v.ident + del __threading__._active[_k] + _v._ident = _v._Thread__ident = _get_ident() + __threading__._active[_get_ident()] = _v + del _k + del _v + + # Avoid printing an error on shutdown trying to remove the thread entry + # we just replaced if we're not fully monkey patched in + # XXX: This causes a hang on PyPy for some unknown reason (as soon as class _active + # defines __delitem__, shutdown hangs. Maybe due to something with the GC? + # XXX: This may be fixed in 2.6.1+ + if not PYPY: + # pylint:disable=no-member + _MAIN_THREAD = __threading__._get_ident() if hasattr(__threading__, '_get_ident') else __threading__.get_ident() + + class _active(dict): + def __delitem__(self, k): + if k == _MAIN_THREAD and k not in self: + return + dict.__delitem__(self, k) + + __threading__._active = _active(__threading__._active) + + +import sys +if sys.version_info[:2] >= (3, 4): + # XXX: Issue 18808 breaks us on Python 3.4. + # Thread objects now expect a callback from the interpreter itself + # (threadmodule.c:release_sentinel). Because this never happens + # when a greenlet exits, join() and friends will block forever. + # The solution below involves capturing the greenlet when it is + # started and deferring the known broken methods to it. + + class Thread(__threading__.Thread): + _greenlet = None + + def is_alive(self): + return bool(self._greenlet) + + isAlive = is_alive + + def _set_tstate_lock(self): + self._greenlet = getcurrent() + + def run(self): + try: + super(Thread, self).run() + finally: + # avoid ref cycles, but keep in __dict__ so we can + # distinguish the started/never-started case + self._greenlet = None + self._stop() # mark as finished + + def join(self, timeout=None): + if '_greenlet' not in self.__dict__: + raise RuntimeError("Cannot join an inactive thread") + if self._greenlet is None: + return + self._greenlet.join(timeout=timeout) + + def _wait_for_tstate_lock(self, *args, **kwargs): + # pylint:disable=arguments-differ + raise NotImplementedError() + + __implements__.append('Thread') + + # The main thread is patched up with more care in monkey.py + #t = __threading__.current_thread() + #if isinstance(t, __threading__.Thread): + # t.__class__ = Thread + # t._greenlet = getcurrent() + +if sys.version_info[:2] >= (3, 3): + __implements__.remove('_get_ident') + __implements__.append('get_ident') + get_ident = _get_ident + __implements__.remove('_sleep') + + # Python 3 changed the implementation of threading.RLock + # Previously it was a factory function around threading._RLock + # which in turn used _allocate_lock. Now, it wants to use + # threading._CRLock, which is imported from _thread.RLock and as such + # is implemented in C. So it bypasses our _allocate_lock function. + # Fortunately they left the Python fallback in place + assert hasattr(__threading__, '_CRLock'), "Unsupported Python version" + _CRLock = None + __implements__.append('_CRLock') diff --git a/python/gevent/threadpool.py b/python/gevent/threadpool.py new file mode 100644 index 0000000..1d0e98d --- /dev/null +++ b/python/gevent/threadpool.py @@ -0,0 +1,498 @@ +# Copyright (c) 2012 Denis Bilenko. See LICENSE for details. +from __future__ import absolute_import +import sys +import os +from gevent._compat import integer_types +from gevent.hub import get_hub, getcurrent, sleep, _get_hub +from gevent.event import AsyncResult +from gevent.greenlet import Greenlet +from gevent.pool import GroupMappingMixin +from gevent.lock import Semaphore +from gevent._threading import Lock, Queue, start_new_thread + + +__all__ = ['ThreadPool', + 'ThreadResult'] + + +class ThreadPool(GroupMappingMixin): + """ + .. note:: The method :meth:`apply_async` will always return a new + greenlet, bypassing the threadpool entirely. + """ + + def __init__(self, maxsize, hub=None): + if hub is None: + hub = get_hub() + self.hub = hub + self._maxsize = 0 + self.manager = None + self.pid = os.getpid() + self.fork_watcher = hub.loop.fork(ref=False) + self._init(maxsize) + + def _set_maxsize(self, maxsize): + if not isinstance(maxsize, integer_types): + raise TypeError('maxsize must be integer: %r' % (maxsize, )) + if maxsize < 0: + raise ValueError('maxsize must not be negative: %r' % (maxsize, )) + difference = maxsize - self._maxsize + self._semaphore.counter += difference + self._maxsize = maxsize + self.adjust() + # make sure all currently blocking spawn() start unlocking if maxsize increased + self._semaphore._start_notify() + + def _get_maxsize(self): + return self._maxsize + + maxsize = property(_get_maxsize, _set_maxsize) + + def __repr__(self): + return '<%s at 0x%x %s/%s/%s>' % (self.__class__.__name__, id(self), len(self), self.size, self.maxsize) + + def __len__(self): + # XXX just do unfinished_tasks property + return self.task_queue.unfinished_tasks + + def _get_size(self): + return self._size + + def _set_size(self, size): + if size < 0: + raise ValueError('Size of the pool cannot be negative: %r' % (size, )) + if size > self._maxsize: + raise ValueError('Size of the pool cannot be bigger than maxsize: %r > %r' % (size, self._maxsize)) + if self.manager: + self.manager.kill() + while self._size < size: + self._add_thread() + delay = 0.0001 + while self._size > size: + while self._size - size > self.task_queue.unfinished_tasks: + self.task_queue.put(None) + if getcurrent() is self.hub: + break + sleep(delay) + delay = min(delay * 2, .05) + if self._size: + self.fork_watcher.start(self._on_fork) + else: + self.fork_watcher.stop() + + size = property(_get_size, _set_size) + + def _init(self, maxsize): + self._size = 0 + self._semaphore = Semaphore(1) + self._lock = Lock() + self.task_queue = Queue() + self._set_maxsize(maxsize) + + def _on_fork(self): + # fork() only leaves one thread; also screws up locks; + # let's re-create locks and threads. + # NOTE: See comment in gevent.hub.reinit. + pid = os.getpid() + if pid != self.pid: + self.pid = pid + # Do not mix fork() and threads; since fork() only copies one thread + # all objects referenced by other threads has refcount that will never + # go down to 0. + self._init(self._maxsize) + + def join(self): + """Waits until all outstanding tasks have been completed.""" + delay = 0.0005 + while self.task_queue.unfinished_tasks > 0: + sleep(delay) + delay = min(delay * 2, .05) + + def kill(self): + self.size = 0 + + def _adjust_step(self): + # if there is a possibility & necessity for adding a thread, do it + while self._size < self._maxsize and self.task_queue.unfinished_tasks > self._size: + self._add_thread() + # while the number of threads is more than maxsize, kill one + # we do not check what's already in task_queue - it could be all Nones + while self._size - self._maxsize > self.task_queue.unfinished_tasks: + self.task_queue.put(None) + if self._size: + self.fork_watcher.start(self._on_fork) + else: + self.fork_watcher.stop() + + def _adjust_wait(self): + delay = 0.0001 + while True: + self._adjust_step() + if self._size <= self._maxsize: + return + sleep(delay) + delay = min(delay * 2, .05) + + def adjust(self): + self._adjust_step() + if not self.manager and self._size > self._maxsize: + # might need to feed more Nones into the pool + self.manager = Greenlet.spawn(self._adjust_wait) + + def _add_thread(self): + with self._lock: + self._size += 1 + try: + start_new_thread(self._worker, ()) + except: + with self._lock: + self._size -= 1 + raise + + def spawn(self, func, *args, **kwargs): + """ + Add a new task to the threadpool that will run ``func(*args, **kwargs)``. + + Waits until a slot is available. Creates a new thread if necessary. + + :return: A :class:`gevent.event.AsyncResult`. + """ + while True: + semaphore = self._semaphore + semaphore.acquire() + if semaphore is self._semaphore: + break + + thread_result = None + try: + task_queue = self.task_queue + result = AsyncResult() + # XXX We're calling the semaphore release function in the hub, otherwise + # we get LoopExit (why?). Previously it was done with a rawlink on the + # AsyncResult and the comment that it is "competing for order with get(); this is not + # good, just make ThreadResult release the semaphore before doing anything else" + thread_result = ThreadResult(result, hub=self.hub, call_when_ready=semaphore.release) + task_queue.put((func, args, kwargs, thread_result)) + self.adjust() + except: + if thread_result is not None: + thread_result.destroy() + semaphore.release() + raise + return result + + def _decrease_size(self): + if sys is None: + return + _lock = getattr(self, '_lock', None) + if _lock is not None: + with _lock: + self._size -= 1 + + _destroy_worker_hub = False + + def _worker(self): + # pylint:disable=too-many-branches + need_decrease = True + try: + while True: + task_queue = self.task_queue + task = task_queue.get() + try: + if task is None: + need_decrease = False + self._decrease_size() + # we want first to decrease size, then decrease unfinished_tasks + # otherwise, _adjust might think there's one more idle thread that + # needs to be killed + return + func, args, kwargs, thread_result = task + try: + value = func(*args, **kwargs) + except: # pylint:disable=bare-except + exc_info = getattr(sys, 'exc_info', None) + if exc_info is None: + return + thread_result.handle_error((self, func), exc_info()) + else: + if sys is None: + return + thread_result.set(value) + del value + finally: + del func, args, kwargs, thread_result, task + finally: + if sys is None: + return # pylint:disable=lost-exception + task_queue.task_done() + finally: + if need_decrease: + self._decrease_size() + if sys is not None and self._destroy_worker_hub: + hub = _get_hub() + if hub is not None: + hub.destroy(True) + del hub + + def apply_e(self, expected_errors, function, args=None, kwargs=None): + """ + .. deprecated:: 1.1a2 + Identical to :meth:`apply`; the ``expected_errors`` argument is ignored. + """ + # pylint:disable=unused-argument + # Deprecated but never documented. In the past, before + # self.apply() allowed all errors to be raised to the caller, + # expected_errors allowed a caller to specify a set of errors + # they wanted to be raised, through the wrap_errors function. + # In practice, it always took the value Exception or + # BaseException. + return self.apply(function, args, kwargs) + + def _apply_immediately(self): + # If we're being called from a different thread than the one that + # created us, e.g., because a worker task is trying to use apply() + # recursively, we have no choice but to run the task immediately; + # if we try to AsyncResult.get() in the worker thread, it's likely to have + # nothing to switch to and lead to a LoopExit. + return get_hub() is not self.hub + + def _apply_async_cb_spawn(self, callback, result): + callback(result) + + def _apply_async_use_greenlet(self): + # Always go to Greenlet because our self.spawn uses threads + return True + + +class ThreadResult(object): + + # Using slots here helps to debug reference cycles/leaks + __slots__ = ('exc_info', 'async', '_call_when_ready', 'value', + 'context', 'hub', 'receiver') + + def __init__(self, receiver, hub=None, call_when_ready=None): + if hub is None: + hub = get_hub() + self.receiver = receiver + self.hub = hub + self.context = None + self.value = None + self.exc_info = () + self.async = hub.loop.async() + self._call_when_ready = call_when_ready + self.async.start(self._on_async) + + @property + def exception(self): + return self.exc_info[1] if self.exc_info else None + + def _on_async(self): + self.async.stop() + if self._call_when_ready: + # Typically this is pool.semaphore.release and we have to + # call this in the Hub; if we don't we get the dreaded + # LoopExit (XXX: Why?) + self._call_when_ready() + try: + if self.exc_info: + self.hub.handle_error(self.context, *self.exc_info) + self.context = None + self.async = None + self.hub = None + self._call_when_ready = None + if self.receiver is not None: + self.receiver(self) + finally: + self.receiver = None + self.value = None + if self.exc_info: + self.exc_info = (self.exc_info[0], self.exc_info[1], None) + + def destroy(self): + if self.async is not None: + self.async.stop() + self.async = None + self.context = None + self.hub = None + self._call_when_ready = None + self.receiver = None + + def _ready(self): + if self.async is not None: + self.async.send() + + def set(self, value): + self.value = value + self._ready() + + def handle_error(self, context, exc_info): + self.context = context + self.exc_info = exc_info + self._ready() + + # link protocol: + def successful(self): + return self.exception is None + + +def wrap_errors(errors, function, args, kwargs): + """ + .. deprecated:: 1.1a2 + Previously used by ThreadPool.apply_e. + """ + try: + return True, function(*args, **kwargs) + except errors as ex: + return False, ex + +try: + import concurrent.futures +except ImportError: + pass +else: + __all__.append("ThreadPoolExecutor") + + from gevent.timeout import Timeout as GTimeout + from gevent._util import Lazy + from concurrent.futures import _base as cfb + + def _wrap_error(future, fn): + def cbwrap(_): + del _ + # we're called with the async result, but + # be sure to pass in ourself. Also automatically + # unlink ourself so that we don't get called multiple + # times. + try: + fn(future) + except Exception: # pylint: disable=broad-except + future.hub.print_exception((fn, future), *sys.exc_info()) + cbwrap.auto_unlink = True + return cbwrap + + def _wrap(future, fn): + def f(_): + fn(future) + f.auto_unlink = True + return f + + class _FutureProxy(object): + def __init__(self, asyncresult): + self.asyncresult = asyncresult + + # Internal implementation details of a c.f.Future + + @Lazy + def _condition(self): + from gevent import monkey + if monkey.is_module_patched('threading') or self.done(): + import threading + return threading.Condition() + # We can only properly work with conditions + # when we've been monkey-patched. This is necessary + # for the wait/as_completed module functions. + raise AttributeError("_condition") + + @Lazy + def _waiters(self): + self.asyncresult.rawlink(self.__when_done) + return [] + + def __when_done(self, _): + # We should only be called when _waiters has + # already been accessed. + waiters = getattr(self, '_waiters') + for w in waiters: # pylint:disable=not-an-iterable + if self.successful(): + w.add_result(self) + else: + w.add_exception(self) + + __when_done.auto_unlink = True + + @property + def _state(self): + if self.done(): + return cfb.FINISHED + return cfb.RUNNING + + def set_running_or_notify_cancel(self): + # Does nothing, not even any consistency checks. It's + # meant to be internal to the executor and we don't use it. + return + + def result(self, timeout=None): + try: + return self.asyncresult.result(timeout=timeout) + except GTimeout: + # XXX: Theoretically this could be a completely + # unrelated timeout instance. Do we care about that? + raise concurrent.futures.TimeoutError() + + def exception(self, timeout=None): + try: + self.asyncresult.get(timeout=timeout) + return self.asyncresult.exception + except GTimeout: + raise concurrent.futures.TimeoutError() + + def add_done_callback(self, fn): + if self.done(): + fn(self) + else: + self.asyncresult.rawlink(_wrap_error(self, fn)) + + def rawlink(self, fn): + self.asyncresult.rawlink(_wrap(self, fn)) + + def __str__(self): + return str(self.asyncresult) + + def __getattr__(self, name): + return getattr(self.asyncresult, name) + + class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor): + """ + A version of :class:`concurrent.futures.ThreadPoolExecutor` that + always uses native threads, even when threading is monkey-patched. + + The ``Future`` objects returned from this object can be used + with gevent waiting primitives like :func:`gevent.wait`. + + .. caution:: If threading is *not* monkey-patched, then the ``Future`` + objects returned by this object are not guaranteed to work with + :func:`~concurrent.futures.as_completed` and :func:`~concurrent.futures.wait`. + The individual blocking methods like :meth:`~concurrent.futures.Future.result` + and :meth:`~concurrent.futures.Future.exception` will always work. + + .. versionadded:: 1.2a1 + This is a provisional API. + """ + + def __init__(self, max_workers): + super(ThreadPoolExecutor, self).__init__(max_workers) + self._threadpool = ThreadPool(max_workers) + self._threadpool._destroy_worker_hub = True + + def submit(self, fn, *args, **kwargs): + with self._shutdown_lock: # pylint:disable=not-context-manager + if self._shutdown: + raise RuntimeError('cannot schedule new futures after shutdown') + + future = self._threadpool.spawn(fn, *args, **kwargs) + return _FutureProxy(future) + + def shutdown(self, wait=True): + super(ThreadPoolExecutor, self).shutdown(wait) + # XXX: We don't implement wait properly + kill = getattr(self._threadpool, 'kill', None) + if kill: # pylint:disable=using-constant-test + self._threadpool.kill() + self._threadpool = None + + kill = shutdown # greentest compat + + def _adjust_thread_count(self): + # Does nothing. We don't want to spawn any "threads", + # let the threadpool handle that. + pass diff --git a/python/gevent/timeout.py b/python/gevent/timeout.py new file mode 100644 index 0000000..f08b81a --- /dev/null +++ b/python/gevent/timeout.py @@ -0,0 +1,261 @@ +# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details. +""" +Timeouts. + +Many functions in :mod:`gevent` have a *timeout* argument that allows +limiting the time the function will block. When that is not available, +the :class:`Timeout` class and :func:`with_timeout` function in this +module add timeouts to arbitrary code. + +.. warning:: + + Timeouts can only work when the greenlet switches to the hub. + If a blocking function is called or an intense calculation is ongoing during + which no switches occur, :class:`Timeout` is powerless. +""" + +from gevent._compat import string_types +from gevent.hub import getcurrent, _NONE, get_hub + +__all__ = ['Timeout', + 'with_timeout'] + + +class _FakeTimer(object): + # An object that mimics the API of get_hub().loop.timer, but + # without allocating any native resources. This is useful for timeouts + # that will never expire. + # Also partially mimics the API of Timeout itself for use in _start_new_or_dummy + pending = False + active = False + + def start(self, *args, **kwargs): + # pylint:disable=unused-argument + raise AssertionError("non-expiring timer cannot be started") + + def stop(self): + return + + def cancel(self): + return + +_FakeTimer = _FakeTimer() + + +class Timeout(BaseException): + """ + Raise *exception* in the current greenlet after given time period:: + + timeout = Timeout(seconds, exception) + timeout.start() + try: + ... # exception will be raised here, after *seconds* passed since start() call + finally: + timeout.cancel() + + .. note:: If the code that the timeout was protecting finishes + executing before the timeout elapses, be sure to ``cancel`` the + timeout so it is not unexpectedly raised in the future. Even if + it is raised, it is a best practice to cancel it. This + ``try/finally`` construct or a ``with`` statement is a + recommended pattern. + + When *exception* is omitted or ``None``, the :class:`Timeout` instance itself is raised: + + >>> import gevent + >>> gevent.Timeout(0.1).start() + >>> gevent.sleep(0.2) #doctest: +IGNORE_EXCEPTION_DETAIL + Traceback (most recent call last): + ... + Timeout: 0.1 seconds + + To simplify starting and canceling timeouts, the ``with`` statement can be used:: + + with gevent.Timeout(seconds, exception) as timeout: + pass # ... code block ... + + This is equivalent to the try/finally block above with one additional feature: + if *exception* is the literal ``False``, the timeout is still raised, but the context manager + suppresses it, so the code outside the with-block won't see it. + + This is handy for adding a timeout to the functions that don't + support a *timeout* parameter themselves:: + + data = None + with gevent.Timeout(5, False): + data = mysock.makefile().readline() + if data is None: + ... # 5 seconds passed without reading a line + else: + ... # a line was read within 5 seconds + + .. caution:: If ``readline()`` above catches and doesn't re-raise :class:`BaseException` + (for example, with a bare ``except:``), then your timeout will fail to function and control + won't be returned to you when you expect. + + When catching timeouts, keep in mind that the one you catch may + not be the one you have set (a calling function may have set its + own timeout); if you going to silence a timeout, always check that + it's the instance you need:: + + timeout = Timeout(1) + timeout.start() + try: + ... + except Timeout as t: + if t is not timeout: + raise # not my timeout + + If the *seconds* argument is not given or is ``None`` (e.g., + ``Timeout()``), then the timeout will never expire and never raise + *exception*. This is convenient for creating functions which take + an optional timeout parameter of their own. (Note that this is not the same thing + as a *seconds* value of 0.) + + .. caution:: + A *seconds* value less than 0.0 (e.g., -1) is poorly defined. In the future, + support for negative values is likely to do the same thing as a value + if ``None``. + + .. versionchanged:: 1.1b2 + If *seconds* is not given or is ``None``, no longer allocate a libev + timer that will never be started. + .. versionchanged:: 1.1 + Add warning about negative *seconds* values. + """ + + def __init__(self, seconds=None, exception=None, ref=True, priority=-1, _use_timer=True): + BaseException.__init__(self) + self.seconds = seconds + self.exception = exception + if seconds is None or not _use_timer: + # Avoid going through the timer codepath if no timeout is + # desired; this avoids some CFFI interactions on PyPy that can lead to a + # RuntimeError if this implementation is used during an `import` statement. See + # https://bitbucket.org/pypy/pypy/issues/2089/crash-in-pypy-260-linux64-with-gevent-11b1 + # and https://github.com/gevent/gevent/issues/618. + # Plus, in general, it should be more efficient + self.timer = _FakeTimer + else: + self.timer = get_hub().loop.timer(seconds or 0.0, ref=ref, priority=priority) + + def start(self): + """Schedule the timeout.""" + assert not self.pending, '%r is already started; to restart it, cancel it first' % self + if self.seconds is None: # "fake" timeout (never expires) + return + + if self.exception is None or self.exception is False or isinstance(self.exception, string_types): + # timeout that raises self + self.timer.start(getcurrent().throw, self) + else: # regular timeout with user-provided exception + self.timer.start(getcurrent().throw, self.exception) + + @classmethod + def start_new(cls, timeout=None, exception=None, ref=True): + """Create a started :class:`Timeout`. + + This is a shortcut, the exact action depends on *timeout*'s type: + + * If *timeout* is a :class:`Timeout`, then call its :meth:`start` method + if it's not already begun. + * Otherwise, create a new :class:`Timeout` instance, passing (*timeout*, *exception*) as + arguments, then call its :meth:`start` method. + + Returns the :class:`Timeout` instance. + """ + if isinstance(timeout, Timeout): + if not timeout.pending: + timeout.start() + return timeout + timeout = cls(timeout, exception, ref=ref) + timeout.start() + return timeout + + @staticmethod + def _start_new_or_dummy(timeout, exception=None): + # Internal use only in 1.1 + # Return an object with a 'cancel' method; if timeout is None, + # this will be a shared instance object that does nothing. Otherwise, + # return an actual Timeout. Because negative values are hard to reason about, + # and are often used as sentinels in Python APIs, in the future it's likely + # that a negative timeout will also return the shared instance. + # This saves the previously common idiom of 'timer = Timeout.start_new(t) if t is not None else None' + # followed by 'if timer is not None: timer.cancel()'. + # That idiom was used to avoid any object allocations. + # A staticmethod is slightly faster under CPython, compared to a classmethod; + # under PyPy in synthetic benchmarks it makes no difference. + if timeout is None: + return _FakeTimer + return Timeout.start_new(timeout, exception) + + @property + def pending(self): + """Return True if the timeout is scheduled to be raised.""" + return self.timer.pending or self.timer.active + + def cancel(self): + """If the timeout is pending, cancel it. Otherwise, do nothing.""" + self.timer.stop() + + def __repr__(self): + classname = type(self).__name__ + if self.pending: + pending = ' pending' + else: + pending = '' + if self.exception is None: + exception = '' + else: + exception = ' exception=%r' % self.exception + return '<%s at %s seconds=%s%s%s>' % (classname, hex(id(self)), self.seconds, exception, pending) + + def __str__(self): + """ + >>> raise Timeout #doctest: +IGNORE_EXCEPTION_DETAIL + Traceback (most recent call last): + ... + Timeout + """ + if self.seconds is None: + return '' + + suffix = '' if self.seconds == 1 else 's' + + if self.exception is None: + return '%s second%s' % (self.seconds, suffix) + if self.exception is False: + return '%s second%s (silent)' % (self.seconds, suffix) + return '%s second%s: %s' % (self.seconds, suffix, self.exception) + + def __enter__(self): + if not self.pending: + self.start() + return self + + def __exit__(self, typ, value, tb): + self.cancel() + if value is self and self.exception is False: + return True + + +def with_timeout(seconds, function, *args, **kwds): + """Wrap a call to *function* with a timeout; if the called + function fails to return before the timeout, cancel it and return a + flag value, provided by *timeout_value* keyword argument. + + If timeout expires but *timeout_value* is not provided, raise :class:`Timeout`. + + Keyword argument *timeout_value* is not passed to *function*. + """ + timeout_value = kwds.pop("timeout_value", _NONE) + timeout = Timeout.start_new(seconds) + try: + try: + return function(*args, **kwds) + except Timeout as ex: + if ex is timeout and timeout_value is not _NONE: + return timeout_value + raise + finally: + timeout.cancel() diff --git a/python/gevent/util.py b/python/gevent/util.py new file mode 100644 index 0000000..1438688 --- /dev/null +++ b/python/gevent/util.py @@ -0,0 +1,60 @@ +# Copyright (c) 2009 Denis Bilenko. See LICENSE for details. +""" +Low-level utilities. +""" + +from __future__ import absolute_import + +import functools + +__all__ = ['wrap_errors'] + + +class wrap_errors(object): + """ + Helper to make function return an exception, rather than raise it. + + Because every exception that is unhandled by greenlet will be logged, + it is desirable to prevent non-error exceptions from leaving a greenlet. + This can done with a simple ``try/except`` construct:: + + def wrapped_func(*args, **kwargs): + try: + return func(*args, **kwargs) + except (TypeError, ValueError, AttributeError) as ex: + return ex + + This class provides a shortcut to write that in one line:: + + wrapped_func = wrap_errors((TypeError, ValueError, AttributeError), func) + + It also preserves ``__str__`` and ``__repr__`` of the original function. + """ + # QQQ could also support using wrap_errors as a decorator + + def __init__(self, errors, func): + """ + Calling this makes a new function from *func*, such that it catches *errors* (an + :exc:`BaseException` subclass, or a tuple of :exc:`BaseException` subclasses) and + return it as a value. + """ + self.__errors = errors + self.__func = func + # Set __doc__, __wrapped__, etc, especially useful on Python 3. + functools.update_wrapper(self, func) + + def __call__(self, *args, **kwargs): + func = self.__func + try: + return func(*args, **kwargs) + except self.__errors as ex: + return ex + + def __str__(self): + return str(self.__func) + + def __repr__(self): + return repr(self.__func) + + def __getattr__(self, name): + return getattr(self.__func, name) diff --git a/python/gevent/win32util.py b/python/gevent/win32util.py new file mode 100644 index 0000000..7158d69 --- /dev/null +++ b/python/gevent/win32util.py @@ -0,0 +1,98 @@ +# Copyright (c) 2001-2007 Twisted Matrix Laboratories. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +"""Error formatting function for Windows. + +The code is taken from twisted.python.win32 module. +""" + +from __future__ import absolute_import +import os + + +__all__ = ['formatError'] + + +class _ErrorFormatter(object): + """ + Formatter for Windows error messages. + + @ivar winError: A callable which takes one integer error number argument + and returns an L{exceptions.WindowsError} instance for that error (like + L{ctypes.WinError}). + + @ivar formatMessage: A callable which takes one integer error number + argument and returns a C{str} giving the message for that error (like + L{win32api.FormatMessage}). + + @ivar errorTab: A mapping from integer error numbers to C{str} messages + which correspond to those errors (like L{socket.errorTab}). + """ + def __init__(self, WinError, FormatMessage, errorTab): + self.winError = WinError + self.formatMessage = FormatMessage + self.errorTab = errorTab + + @classmethod + def fromEnvironment(cls): + """ + Get as many of the platform-specific error translation objects as + possible and return an instance of C{cls} created with them. + """ + try: + from ctypes import WinError + except ImportError: + WinError = None + try: + from win32api import FormatMessage + except ImportError: + FormatMessage = None + try: + from socket import errorTab + except ImportError: + errorTab = None + return cls(WinError, FormatMessage, errorTab) + + def formatError(self, errorcode): + """ + Returns the string associated with a Windows error message, such as the + ones found in socket.error. + + Attempts direct lookup against the win32 API via ctypes and then + pywin32 if available), then in the error table in the socket module, + then finally defaulting to C{os.strerror}. + + @param errorcode: the Windows error code + @type errorcode: C{int} + + @return: The error message string + @rtype: C{str} + """ + if self.winError is not None: + return str(self.winError(errorcode)) + if self.formatMessage is not None: + return self.formatMessage(errorcode) + if self.errorTab is not None: + result = self.errorTab.get(errorcode) + if result is not None: + return result + return os.strerror(errorcode) + +formatError = _ErrorFormatter.fromEnvironment().formatError diff --git a/python/gevent/wsgi.py b/python/gevent/wsgi.py new file mode 100644 index 0000000..503d67b --- /dev/null +++ b/python/gevent/wsgi.py @@ -0,0 +1,15 @@ +"""Backwards compatibility alias for :mod:`gevent.pywsgi`. + +In the past, this used libevent's http support, but that was dropped +with the introduction of libev. libevent's http support had several +limitations, including not supporting stream, not supporting +pipelining, and not supporting SSL. + +.. deprecated:: 1.1 + Use :mod:`gevent.pywsgi` +""" + +from gevent.pywsgi import * # pylint:disable=wildcard-import,unused-wildcard-import +import gevent.pywsgi as _pywsgi +__all__ = _pywsgi.__all__ +del _pywsgi diff --git a/python/python.exe b/python/python.exe Binary files differnew file mode 100644 index 0000000..d99e5bc --- /dev/null +++ b/python/python.exe diff --git a/python/python3.dll b/python/python3.dll Binary files differnew file mode 100644 index 0000000..3fd2752 --- /dev/null +++ b/python/python3.dll diff --git a/python/python36._pth b/python/python36._pth new file mode 100644 index 0000000..901a723 --- /dev/null +++ b/python/python36._pth @@ -0,0 +1,6 @@ +python36.zip +. +.. + +# Uncomment to run site.main() automatically +#import site diff --git a/python/python36.dll b/python/python36.dll Binary files differnew file mode 100644 index 0000000..1c5ad2c --- /dev/null +++ b/python/python36.dll diff --git a/python/python36.zip b/python/python36.zip Binary files differnew file mode 100644 index 0000000..481cb58 --- /dev/null +++ b/python/python36.zip diff --git a/python/pythonw.exe b/python/pythonw.exe Binary files differnew file mode 100644 index 0000000..1dbff64 --- /dev/null +++ b/python/pythonw.exe diff --git a/python/socks.py b/python/socks.py new file mode 100644 index 0000000..7bcf590 --- /dev/null +++ b/python/socks.py @@ -0,0 +1,870 @@ +"""SocksiPy - Python SOCKS module. + +Copyright 2006 Dan-Haim. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of Dan Haim nor the names of his contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This module provides a standard socket-like interface for Python +for tunneling connections through SOCKS proxies. + +=============================================================================== + +Minor modifications made by Christopher Gilbert (http://motomastyle.com/) +for use in PyLoris (http://pyloris.sourceforge.net/) + +Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/) +mainly to merge bug fixes found in Sourceforge + +Modifications made by Anorov (https://github.com/Anorov) +-Forked and renamed to PySocks +-Fixed issue with HTTP proxy failure checking (same bug that was in the + old ___recvall() method) +-Included SocksiPyHandler (sockshandler.py), to be used as a urllib2 handler, + courtesy of e000 (https://github.com/e000): + https://gist.github.com/869791#file_socksipyhandler.py +-Re-styled code to make it readable + -Aliased PROXY_TYPE_SOCKS5 -> SOCKS5 etc. + -Improved exception handling and output + -Removed irritating use of sequence indexes, replaced with tuple unpacked + variables + -Fixed up Python 3 bytestring handling - chr(0x03).encode() -> b"\x03" + -Other general fixes +-Added clarification that the HTTP proxy connection method only supports + CONNECT-style tunneling HTTP proxies +-Various small bug fixes +""" + +from base64 import b64encode +from collections import Callable +from errno import EOPNOTSUPP, EINVAL, EAGAIN +import functools +from io import BytesIO +import logging +import os +from os import SEEK_CUR +import socket +import struct +import sys + +__version__ = "1.6.7" + + +if os.name == "nt" and sys.version_info < (3, 0): + try: + import win_inet_pton + except ImportError: + raise ImportError( + "To run PySocks on Windows you must install win_inet_pton") + +log = logging.getLogger(__name__) + +PROXY_TYPE_SOCKS4 = SOCKS4 = 1 +PROXY_TYPE_SOCKS5 = SOCKS5 = 2 +PROXY_TYPE_HTTP = HTTP = 3 + +PROXY_TYPES = {"SOCKS4": SOCKS4, "SOCKS5": SOCKS5, "HTTP": HTTP} +PRINTABLE_PROXY_TYPES = dict(zip(PROXY_TYPES.values(), PROXY_TYPES.keys())) + +_orgsocket = _orig_socket = socket.socket + + +def set_self_blocking(function): + + @functools.wraps(function) + def wrapper(*args, **kwargs): + self = args[0] + try: + _is_blocking = self.gettimeout() + if _is_blocking == 0: + self.setblocking(True) + return function(*args, **kwargs) + except Exception as e: + raise + finally: + # set orgin blocking + if _is_blocking == 0: + self.setblocking(False) + return wrapper + + +class ProxyError(IOError): + """Socket_err contains original socket.error exception.""" + def __init__(self, msg, socket_err=None): + self.msg = msg + self.socket_err = socket_err + + if socket_err: + self.msg += ": {0}".format(socket_err) + + def __str__(self): + return self.msg + + +class GeneralProxyError(ProxyError): + pass + + +class ProxyConnectionError(ProxyError): + pass + + +class SOCKS5AuthError(ProxyError): + pass + + +class SOCKS5Error(ProxyError): + pass + + +class SOCKS4Error(ProxyError): + pass + + +class HTTPError(ProxyError): + pass + +SOCKS4_ERRORS = { + 0x5B: "Request rejected or failed", + 0x5C: ("Request rejected because SOCKS server cannot connect to identd on" + " the client"), + 0x5D: ("Request rejected because the client program and identd report" + " different user-ids") +} + +SOCKS5_ERRORS = { + 0x01: "General SOCKS server failure", + 0x02: "Connection not allowed by ruleset", + 0x03: "Network unreachable", + 0x04: "Host unreachable", + 0x05: "Connection refused", + 0x06: "TTL expired", + 0x07: "Command not supported, or protocol error", + 0x08: "Address type not supported" +} + +DEFAULT_PORTS = {SOCKS4: 1080, SOCKS5: 1080, HTTP: 8080} + + +def set_default_proxy(proxy_type=None, addr=None, port=None, rdns=True, + username=None, password=None): + """Sets a default proxy. + + All further socksocket objects will use the default unless explicitly + changed. All parameters are as for socket.set_proxy().""" + socksocket.default_proxy = (proxy_type, addr, port, rdns, + username.encode() if username else None, + password.encode() if password else None) + + +def setdefaultproxy(*args, **kwargs): + if "proxytype" in kwargs: + kwargs["proxy_type"] = kwargs.pop("proxytype") + return set_default_proxy(*args, **kwargs) + + +def get_default_proxy(): + """Returns the default proxy, set by set_default_proxy.""" + return socksocket.default_proxy + +getdefaultproxy = get_default_proxy + + +def wrap_module(module): + """Attempts to replace a module's socket library with a SOCKS socket. + + Must set a default proxy using set_default_proxy(...) first. This will + only work on modules that import socket directly into the namespace; + most of the Python Standard Library falls into this category.""" + if socksocket.default_proxy: + module.socket.socket = socksocket + else: + raise GeneralProxyError("No default proxy specified") + +wrapmodule = wrap_module + + +def create_connection(dest_pair, + timeout=None, source_address=None, + proxy_type=None, proxy_addr=None, + proxy_port=None, proxy_rdns=True, + proxy_username=None, proxy_password=None, + socket_options=None): + """create_connection(dest_pair, *[, timeout], **proxy_args) -> socket object + + Like socket.create_connection(), but connects to proxy + before returning the socket object. + + dest_pair - 2-tuple of (IP/hostname, port). + **proxy_args - Same args passed to socksocket.set_proxy() if present. + timeout - Optional socket timeout value, in seconds. + source_address - tuple (host, port) for the socket to bind to as its source + address before connecting (only for compatibility) + """ + # Remove IPv6 brackets on the remote address and proxy address. + remote_host, remote_port = dest_pair + if remote_host.startswith("["): + remote_host = remote_host.strip("[]") + if proxy_addr and proxy_addr.startswith("["): + proxy_addr = proxy_addr.strip("[]") + + err = None + + # Allow the SOCKS proxy to be on IPv4 or IPv6 addresses. + for r in socket.getaddrinfo(proxy_addr, proxy_port, 0, socket.SOCK_STREAM): + family, socket_type, proto, canonname, sa = r + sock = None + try: + sock = socksocket(family, socket_type, proto) + + if socket_options: + for opt in socket_options: + sock.setsockopt(*opt) + + if isinstance(timeout, (int, float)): + sock.settimeout(timeout) + + if proxy_type: + sock.set_proxy(proxy_type, proxy_addr, proxy_port, proxy_rdns, + proxy_username, proxy_password) + if source_address: + sock.bind(source_address) + + sock.connect((remote_host, remote_port)) + return sock + + except (socket.error, ProxyConnectionError) as e: + err = e + if sock: + sock.close() + sock = None + + if err: + raise err + + raise socket.error("gai returned empty list.") + + +class _BaseSocket(socket.socket): + """Allows Python 2 delegated methods such as send() to be overridden.""" + def __init__(self, *pos, **kw): + _orig_socket.__init__(self, *pos, **kw) + + self._savedmethods = dict() + for name in self._savenames: + self._savedmethods[name] = getattr(self, name) + delattr(self, name) # Allows normal overriding mechanism to work + + _savenames = list() + + +def _makemethod(name): + return lambda self, *pos, **kw: self._savedmethods[name](*pos, **kw) +for name in ("sendto", "send", "recvfrom", "recv"): + method = getattr(_BaseSocket, name, None) + + # Determine if the method is not defined the usual way + # as a function in the class. + # Python 2 uses __slots__, so there are descriptors for each method, + # but they are not functions. + if not isinstance(method, Callable): + _BaseSocket._savenames.append(name) + setattr(_BaseSocket, name, _makemethod(name)) + + +class socksocket(_BaseSocket): + """socksocket([family[, type[, proto]]]) -> socket object + + Open a SOCKS enabled socket. The parameters are the same as + those of the standard socket init. In order for SOCKS to work, + you must specify family=AF_INET and proto=0. + The "type" argument must be either SOCK_STREAM or SOCK_DGRAM. + """ + + default_proxy = None + + def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, + proto=0, *args, **kwargs): + if type not in (socket.SOCK_STREAM, socket.SOCK_DGRAM): + msg = "Socket type must be stream or datagram, not {!r}" + raise ValueError(msg.format(type)) + + super(socksocket, self).__init__(family, type, proto, *args, **kwargs) + self._proxyconn = None # TCP connection to keep UDP relay alive + + if self.default_proxy: + self.proxy = self.default_proxy + else: + self.proxy = (None, None, None, None, None, None) + self.proxy_sockname = None + self.proxy_peername = None + + self._timeout = None + + def _readall(self, file, count): + """Receive EXACTLY the number of bytes requested from the file object. + + Blocks until the required number of bytes have been received.""" + data = b"" + while len(data) < count: + d = file.read(count - len(data)) + if not d: + raise GeneralProxyError("Connection closed unexpectedly") + data += d + return data + + def settimeout(self, timeout): + self._timeout = timeout + try: + # test if we're connected, if so apply timeout + peer = self.get_proxy_peername() + super(socksocket, self).settimeout(self._timeout) + except socket.error: + pass + + def gettimeout(self): + return self._timeout + + def setblocking(self, v): + if v: + self.settimeout(None) + else: + self.settimeout(0.0) + + def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, + username=None, password=None): + """ Sets the proxy to be used. + + proxy_type - The type of the proxy to be used. Three types + are supported: PROXY_TYPE_SOCKS4 (including socks4a), + PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP + addr - The address of the server (IP or DNS). + port - The port of the server. Defaults to 1080 for SOCKS + servers and 8080 for HTTP proxy servers. + rdns - Should DNS queries be performed on the remote side + (rather than the local side). The default is True. + Note: This has no effect with SOCKS4 servers. + username - Username to authenticate with to the server. + The default is no authentication. + password - Password to authenticate with to the server. + Only relevant when username is also provided.""" + self.proxy = (proxy_type, addr, port, rdns, + username.encode() if username else None, + password.encode() if password else None) + + def setproxy(self, *args, **kwargs): + if "proxytype" in kwargs: + kwargs["proxy_type"] = kwargs.pop("proxytype") + return self.set_proxy(*args, **kwargs) + + def bind(self, *pos, **kw): + """Implements proxy connection for UDP sockets. + + Happens during the bind() phase.""" + (proxy_type, proxy_addr, proxy_port, rdns, username, + password) = self.proxy + if not proxy_type or self.type != socket.SOCK_DGRAM: + return _orig_socket.bind(self, *pos, **kw) + + if self._proxyconn: + raise socket.error(EINVAL, "Socket already bound to an address") + if proxy_type != SOCKS5: + msg = "UDP only supported by SOCKS5 proxy type" + raise socket.error(EOPNOTSUPP, msg) + super(socksocket, self).bind(*pos, **kw) + + # Need to specify actual local port because + # some relays drop packets if a port of zero is specified. + # Avoid specifying host address in case of NAT though. + _, port = self.getsockname() + dst = ("0", port) + + self._proxyconn = _orig_socket() + proxy = self._proxy_addr() + self._proxyconn.connect(proxy) + + UDP_ASSOCIATE = b"\x03" + _, relay = self._SOCKS5_request(self._proxyconn, UDP_ASSOCIATE, dst) + + # The relay is most likely on the same host as the SOCKS proxy, + # but some proxies return a private IP address (10.x.y.z) + host, _ = proxy + _, port = relay + super(socksocket, self).connect((host, port)) + super(socksocket, self).settimeout(self._timeout) + self.proxy_sockname = ("0.0.0.0", 0) # Unknown + + def sendto(self, bytes, *args, **kwargs): + if self.type != socket.SOCK_DGRAM: + return super(socksocket, self).sendto(bytes, *args, **kwargs) + if not self._proxyconn: + self.bind(("", 0)) + + address = args[-1] + flags = args[:-1] + + header = BytesIO() + RSV = b"\x00\x00" + header.write(RSV) + STANDALONE = b"\x00" + header.write(STANDALONE) + self._write_SOCKS5_address(address, header) + + sent = super(socksocket, self).send(header.getvalue() + bytes, *flags, + **kwargs) + return sent - header.tell() + + def send(self, bytes, flags=0, **kwargs): + if self.type == socket.SOCK_DGRAM: + return self.sendto(bytes, flags, self.proxy_peername, **kwargs) + else: + return super(socksocket, self).send(bytes, flags, **kwargs) + + def recvfrom(self, bufsize, flags=0): + if self.type != socket.SOCK_DGRAM: + return super(socksocket, self).recvfrom(bufsize, flags) + if not self._proxyconn: + self.bind(("", 0)) + + buf = BytesIO(super(socksocket, self).recv(bufsize + 1024, flags)) + buf.seek(2, SEEK_CUR) + frag = buf.read(1) + if ord(frag): + raise NotImplementedError("Received UDP packet fragment") + fromhost, fromport = self._read_SOCKS5_address(buf) + + if self.proxy_peername: + peerhost, peerport = self.proxy_peername + if fromhost != peerhost or peerport not in (0, fromport): + raise socket.error(EAGAIN, "Packet filtered") + + return (buf.read(bufsize), (fromhost, fromport)) + + def recv(self, *pos, **kw): + bytes, _ = self.recvfrom(*pos, **kw) + return bytes + + def close(self): + if self._proxyconn: + self._proxyconn.close() + return super(socksocket, self).close() + + def get_proxy_sockname(self): + """Returns the bound IP address and port number at the proxy.""" + return self.proxy_sockname + + getproxysockname = get_proxy_sockname + + def get_proxy_peername(self): + """ + Returns the IP and port number of the proxy. + """ + return self.getpeername() + + getproxypeername = get_proxy_peername + + def get_peername(self): + """Returns the IP address and port number of the destination machine. + + Note: get_proxy_peername returns the proxy.""" + return self.proxy_peername + + getpeername = get_peername + + def _negotiate_SOCKS5(self, *dest_addr): + """Negotiates a stream connection through a SOCKS5 server.""" + CONNECT = b"\x01" + self.proxy_peername, self.proxy_sockname = self._SOCKS5_request( + self, CONNECT, dest_addr) + + def _SOCKS5_request(self, conn, cmd, dst): + """ + Send SOCKS5 request with given command (CMD field) and + address (DST field). Returns resolved DST address that was used. + """ + proxy_type, addr, port, rdns, username, password = self.proxy + + writer = conn.makefile("wb") + reader = conn.makefile("rb", 0) # buffering=0 renamed in Python 3 + try: + # First we'll send the authentication packages we support. + if username and password: + # The username/password details were supplied to the + # set_proxy method so we support the USERNAME/PASSWORD + # authentication (in addition to the standard none). + writer.write(b"\x05\x02\x00\x02") + else: + # No username/password were entered, therefore we + # only support connections with no authentication. + writer.write(b"\x05\x01\x00") + + # We'll receive the server's response to determine which + # method was selected + writer.flush() + chosen_auth = self._readall(reader, 2) + + if chosen_auth[0:1] != b"\x05": + # Note: string[i:i+1] is used because indexing of a bytestring + # via bytestring[i] yields an integer in Python 3 + raise GeneralProxyError( + "SOCKS5 proxy server sent invalid data") + + # Check the chosen authentication method + + if chosen_auth[1:2] == b"\x02": + # Okay, we need to perform a basic username/password + # authentication. + writer.write(b"\x01" + chr(len(username)).encode() + + username + + chr(len(password)).encode() + + password) + writer.flush() + auth_status = self._readall(reader, 2) + if auth_status[0:1] != b"\x01": + # Bad response + raise GeneralProxyError( + "SOCKS5 proxy server sent invalid data") + if auth_status[1:2] != b"\x00": + # Authentication failed + raise SOCKS5AuthError("SOCKS5 authentication failed") + + # Otherwise, authentication succeeded + + # No authentication is required if 0x00 + elif chosen_auth[1:2] != b"\x00": + # Reaching here is always bad + if chosen_auth[1:2] == b"\xFF": + raise SOCKS5AuthError( + "All offered SOCKS5 authentication methods were" + " rejected") + else: + raise GeneralProxyError( + "SOCKS5 proxy server sent invalid data") + + # Now we can request the actual connection + writer.write(b"\x05" + cmd + b"\x00") + resolved = self._write_SOCKS5_address(dst, writer) + writer.flush() + + # Get the response + resp = self._readall(reader, 3) + if resp[0:1] != b"\x05": + raise GeneralProxyError( + "SOCKS5 proxy server sent invalid data") + + status = ord(resp[1:2]) + if status != 0x00: + # Connection failed: server returned an error + error = SOCKS5_ERRORS.get(status, "Unknown error") + raise SOCKS5Error("{0:#04x}: {1}".format(status, error)) + + # Get the bound address/port + bnd = self._read_SOCKS5_address(reader) + + super(socksocket, self).settimeout(self._timeout) + return (resolved, bnd) + finally: + reader.close() + writer.close() + + def _write_SOCKS5_address(self, addr, file): + """ + Return the host and port packed for the SOCKS5 protocol, + and the resolved address as a tuple object. + """ + host, port = addr + proxy_type, _, _, rdns, username, password = self.proxy + family_to_byte = {socket.AF_INET: b"\x01", socket.AF_INET6: b"\x04"} + + # If the given destination address is an IP address, we'll + # use the IP address request even if remote resolving was specified. + # Detect whether the address is IPv4/6 directly. + for family in (socket.AF_INET, socket.AF_INET6): + try: + addr_bytes = socket.inet_pton(family, host) + file.write(family_to_byte[family] + addr_bytes) + host = socket.inet_ntop(family, addr_bytes) + file.write(struct.pack(">H", port)) + return host, port + except socket.error: + continue + + # Well it's not an IP number, so it's probably a DNS name. + if rdns: + # Resolve remotely + host_bytes = host.encode("idna") + file.write(b"\x03" + chr(len(host_bytes)).encode() + host_bytes) + else: + # Resolve locally + addresses = socket.getaddrinfo(host, port, socket.AF_UNSPEC, + socket.SOCK_STREAM, + socket.IPPROTO_TCP, + socket.AI_ADDRCONFIG) + # We can't really work out what IP is reachable, so just pick the + # first. + target_addr = addresses[0] + family = target_addr[0] + host = target_addr[4][0] + + addr_bytes = socket.inet_pton(family, host) + file.write(family_to_byte[family] + addr_bytes) + host = socket.inet_ntop(family, addr_bytes) + file.write(struct.pack(">H", port)) + return host, port + + def _read_SOCKS5_address(self, file): + atyp = self._readall(file, 1) + if atyp == b"\x01": + addr = socket.inet_ntoa(self._readall(file, 4)) + elif atyp == b"\x03": + length = self._readall(file, 1) + addr = self._readall(file, ord(length)) + elif atyp == b"\x04": + addr = socket.inet_ntop(socket.AF_INET6, self._readall(file, 16)) + else: + raise GeneralProxyError("SOCKS5 proxy server sent invalid data") + + port = struct.unpack(">H", self._readall(file, 2))[0] + return addr, port + + def _negotiate_SOCKS4(self, dest_addr, dest_port): + """Negotiates a connection through a SOCKS4 server.""" + proxy_type, addr, port, rdns, username, password = self.proxy + + writer = self.makefile("wb") + reader = self.makefile("rb", 0) # buffering=0 renamed in Python 3 + try: + # Check if the destination address provided is an IP address + remote_resolve = False + try: + addr_bytes = socket.inet_aton(dest_addr) + except socket.error: + # It's a DNS name. Check where it should be resolved. + if rdns: + addr_bytes = b"\x00\x00\x00\x01" + remote_resolve = True + else: + addr_bytes = socket.inet_aton( + socket.gethostbyname(dest_addr)) + + # Construct the request packet + writer.write(struct.pack(">BBH", 0x04, 0x01, dest_port)) + writer.write(addr_bytes) + + # The username parameter is considered userid for SOCKS4 + if username: + writer.write(username) + writer.write(b"\x00") + + # DNS name if remote resolving is required + # NOTE: This is actually an extension to the SOCKS4 protocol + # called SOCKS4A and may not be supported in all cases. + if remote_resolve: + writer.write(dest_addr.encode("idna") + b"\x00") + writer.flush() + + # Get the response from the server + resp = self._readall(reader, 8) + if resp[0:1] != b"\x00": + # Bad data + raise GeneralProxyError( + "SOCKS4 proxy server sent invalid data") + + status = ord(resp[1:2]) + if status != 0x5A: + # Connection failed: server returned an error + error = SOCKS4_ERRORS.get(status, "Unknown error") + raise SOCKS4Error("{0:#04x}: {1}".format(status, error)) + + # Get the bound address/port + self.proxy_sockname = (socket.inet_ntoa(resp[4:]), + struct.unpack(">H", resp[2:4])[0]) + if remote_resolve: + self.proxy_peername = socket.inet_ntoa(addr_bytes), dest_port + else: + self.proxy_peername = dest_addr, dest_port + finally: + reader.close() + writer.close() + + def _negotiate_HTTP(self, dest_addr, dest_port): + """Negotiates a connection through an HTTP server. + + NOTE: This currently only supports HTTP CONNECT-style proxies.""" + proxy_type, addr, port, rdns, username, password = self.proxy + + # If we need to resolve locally, we do this now + addr = dest_addr if rdns else socket.gethostbyname(dest_addr) + + http_headers = [ + (b"CONNECT " + addr.encode("idna") + b":" + + str(dest_port).encode() + b" HTTP/1.1"), + b"Host: " + dest_addr.encode("idna") + ] + + if username and password: + http_headers.append(b"Proxy-Authorization: basic " + + b64encode(username + b":" + password)) + + http_headers.append(b"\r\n") + + self.sendall(b"\r\n".join(http_headers)) + + # We just need the first line to check if the connection was successful + fobj = self.makefile() + status_line = fobj.readline() + fobj.close() + + if not status_line: + raise GeneralProxyError("Connection closed unexpectedly") + + try: + proto, status_code, status_msg = status_line.split(" ", 2) + except ValueError: + raise GeneralProxyError("HTTP proxy server sent invalid response") + + if not proto.startswith("HTTP/"): + raise GeneralProxyError( + "Proxy server does not appear to be an HTTP proxy") + + try: + status_code = int(status_code) + except ValueError: + raise HTTPError( + "HTTP proxy server did not return a valid HTTP status") + + if status_code != 200: + error = "{0}: {1}".format(status_code, status_msg) + if status_code in (400, 403, 405): + # It's likely that the HTTP proxy server does not support the + # CONNECT tunneling method + error += ("\n[*] Note: The HTTP proxy server may not be" + " supported by PySocks (must be a CONNECT tunnel" + " proxy)") + raise HTTPError(error) + + self.proxy_sockname = (b"0.0.0.0", 0) + self.proxy_peername = addr, dest_port + + _proxy_negotiators = { + SOCKS4: _negotiate_SOCKS4, + SOCKS5: _negotiate_SOCKS5, + HTTP: _negotiate_HTTP + } + + @set_self_blocking + def connect(self, dest_pair): + """ + Connects to the specified destination through a proxy. + Uses the same API as socket's connect(). + To select the proxy server, use set_proxy(). + + dest_pair - 2-tuple of (IP/hostname, port). + """ + if len(dest_pair) != 2 or dest_pair[0].startswith("["): + # Probably IPv6, not supported -- raise an error, and hope + # Happy Eyeballs (RFC6555) makes sure at least the IPv4 + # connection works... + raise socket.error("PySocks doesn't support IPv6: %s" + % str(dest_pair)) + + dest_addr, dest_port = dest_pair + + if self.type == socket.SOCK_DGRAM: + if not self._proxyconn: + self.bind(("", 0)) + dest_addr = socket.gethostbyname(dest_addr) + + # If the host address is INADDR_ANY or similar, reset the peer + # address so that packets are received from any peer + if dest_addr == "0.0.0.0" and not dest_port: + self.proxy_peername = None + else: + self.proxy_peername = (dest_addr, dest_port) + return + + (proxy_type, proxy_addr, proxy_port, rdns, username, + password) = self.proxy + + # Do a minimal input check first + if (not isinstance(dest_pair, (list, tuple)) + or len(dest_pair) != 2 + or not dest_addr + or not isinstance(dest_port, int)): + # Inputs failed, raise an error + raise GeneralProxyError( + "Invalid destination-connection (host, port) pair") + + # We set the timeout here so that we don't hang in connection or during + # negotiation. + super(socksocket, self).settimeout(self._timeout) + + if proxy_type is None: + # Treat like regular socket object + self.proxy_peername = dest_pair + super(socksocket, self).settimeout(self._timeout) + super(socksocket, self).connect((dest_addr, dest_port)) + return + + proxy_addr = self._proxy_addr() + + try: + # Initial connection to proxy server. + super(socksocket, self).connect(proxy_addr) + + except socket.error as error: + # Error while connecting to proxy + self.close() + proxy_addr, proxy_port = proxy_addr + proxy_server = "{0}:{1}".format(proxy_addr, proxy_port) + printable_type = PRINTABLE_PROXY_TYPES[proxy_type] + + msg = "Error connecting to {0} proxy {1}".format(printable_type, + proxy_server) + log.debug("%s due to: %s", msg, error) + raise ProxyConnectionError(msg, error) + + else: + # Connected to proxy server, now negotiate + try: + # Calls negotiate_{SOCKS4, SOCKS5, HTTP} + negotiate = self._proxy_negotiators[proxy_type] + negotiate(self, dest_addr, dest_port) + except socket.error as error: + # Wrap socket errors + self.close() + raise GeneralProxyError("Socket error", error) + except ProxyError: + # Protocol error while negotiating with proxy + self.close() + raise + + def _proxy_addr(self): + """ + Return proxy address to connect to as tuple object + """ + (proxy_type, proxy_addr, proxy_port, rdns, username, + password) = self.proxy + proxy_port = proxy_port or DEFAULT_PORTS.get(proxy_type) + if not proxy_port: + raise GeneralProxyError("Invalid proxy type") + return proxy_addr, proxy_port diff --git a/python/sqlite3.dll b/python/sqlite3.dll Binary files differnew file mode 100644 index 0000000..4db8b77 --- /dev/null +++ b/python/sqlite3.dll diff --git a/python/vcruntime140.dll b/python/vcruntime140.dll Binary files differnew file mode 100644 index 0000000..1ea2577 --- /dev/null +++ b/python/vcruntime140.dll |