Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
PK!Sq]e]e sslproto.pynu[import collections import warnings try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import compat from . import protocols from . import transports from .log import logger def _create_transport_context(server_side, server_hostname): if server_side: raise ValueError('Server side SSL needs a valid SSLContext') # Client side may pass ssl=True to use a default # context; in that case the sslcontext passed is None. # The default is secure for client connections. if hasattr(ssl, 'create_default_context'): # Python 3.4+: use up-to-date strong settings. sslcontext = ssl.create_default_context() if not server_hostname: sslcontext.check_hostname = False else: # Fallback for Python 3.3. sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslcontext.options |= ssl.OP_NO_SSLv2 sslcontext.options |= ssl.OP_NO_SSLv3 sslcontext.set_default_verify_paths() sslcontext.verify_mode = ssl.CERT_REQUIRED return sslcontext def _is_sslproto_available(): return hasattr(ssl, "MemoryBIO") # States of an _SSLPipe. _UNWRAPPED = "UNWRAPPED" _DO_HANDSHAKE = "DO_HANDSHAKE" _WRAPPED = "WRAPPED" _SHUTDOWN = "SHUTDOWN" class _SSLPipe(object): """An SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). """ max_size = 256 * 1024 # Buffer size passed to read() def __init__(self, context, server_side, server_hostname=None): """ The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). """ self._context = context self._server_side = server_side self._server_hostname = server_hostname self._state = _UNWRAPPED self._incoming = ssl.MemoryBIO() self._outgoing = ssl.MemoryBIO() self._sslobj = None self._need_ssldata = False self._handshake_cb = None self._shutdown_cb = None @property def context(self): """The SSL context passed to the constructor.""" return self._context @property def ssl_object(self): """The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. """ return self._sslobj @property def need_ssldata(self): """Whether more record level data is needed to complete a handshake that is currently in progress.""" return self._need_ssldata @property def wrapped(self): """ Whether a security layer is currently in effect. Return False during handshake. """ return self._state == _WRAPPED def do_handshake(self, callback=None): """Start the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. """ if self._state != _UNWRAPPED: raise RuntimeError('handshake in progress or completed') self._sslobj = self._context.wrap_bio( self._incoming, self._outgoing, server_side=self._server_side, server_hostname=self._server_hostname) self._state = _DO_HANDSHAKE self._handshake_cb = callback ssldata, appdata = self.feed_ssldata(b'', only_handshake=True) assert len(appdata) == 0 return ssldata def shutdown(self, callback=None): """Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. """ if self._state == _UNWRAPPED: raise RuntimeError('no security layer present') if self._state == _SHUTDOWN: raise RuntimeError('shutdown in progress') assert self._state in (_WRAPPED, _DO_HANDSHAKE) self._state = _SHUTDOWN self._shutdown_cb = callback ssldata, appdata = self.feed_ssldata(b'') assert appdata == [] or appdata == [b''] return ssldata def feed_eof(self): """Send a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. """ self._incoming.write_eof() ssldata, appdata = self.feed_ssldata(b'') assert appdata == [] or appdata == [b''] def feed_ssldata(self, data, only_handshake=False): """Feed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). """ if self._state == _UNWRAPPED: # If unwrapped, pass plaintext data straight through. if data: appdata = [data] else: appdata = [] return ([], appdata) self._need_ssldata = False if data: self._incoming.write(data) ssldata = [] appdata = [] try: if self._state == _DO_HANDSHAKE: # Call do_handshake() until it doesn't raise anymore. self._sslobj.do_handshake() self._state = _WRAPPED if self._handshake_cb: self._handshake_cb(None) if only_handshake: return (ssldata, appdata) # Handshake done: execute the wrapped block if self._state == _WRAPPED: # Main state: read data from SSL until close_notify while True: chunk = self._sslobj.read(self.max_size) appdata.append(chunk) if not chunk: # close_notify break elif self._state == _SHUTDOWN: # Call shutdown() until it doesn't raise anymore. self._sslobj.unwrap() self._sslobj = None self._state = _UNWRAPPED if self._shutdown_cb: self._shutdown_cb() elif self._state == _UNWRAPPED: # Drain possible plaintext data after close_notify. appdata.append(self._incoming.read()) except (ssl.SSLError, ssl.CertificateError) as exc: if getattr(exc, 'errno', None) not in ( ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): if self._state == _DO_HANDSHAKE and self._handshake_cb: self._handshake_cb(exc) raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # Check for record level data that needs to be sent back. # Happens for the initial handshake and renegotiations. if self._outgoing.pending: ssldata.append(self._outgoing.read()) return (ssldata, appdata) def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc.errno = ssl.SSL_ERROR_WANT_READ if exc.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset) class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): def __init__(self, loop, ssl_protocol, app_protocol): self._loop = loop # SSLProtocol instance self._ssl_protocol = ssl_protocol self._app_protocol = app_protocol self._closed = False def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._ssl_protocol._get_extra_info(name, default) def set_protocol(self, protocol): self._app_protocol = protocol def get_protocol(self): return self._app_protocol def is_closing(self): return self._closed def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. """ self._closed = True self._ssl_protocol._start_shutdown() # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if not self._closed: warnings.warn("unclosed transport %r" % self, ResourceWarning) self.close() def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ self._ssl_protocol._transport.pause_reading() def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ self._ssl_protocol._transport.resume_reading() def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ self._ssl_protocol._transport.set_write_buffer_limits(high, low) def get_write_buffer_size(self): """Return the current size of the write buffer.""" return self._ssl_protocol._transport.get_write_buffer_size() def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError("data: expecting a bytes-like instance, got {!r}" .format(type(data).__name__)) if not data: return self._ssl_protocol._write_appdata(data) def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" return False def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ self._ssl_protocol._abort() class SSLProtocol(protocols.Protocol): """SSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. """ def __init__(self, loop, app_protocol, sslcontext, waiter, server_side=False, server_hostname=None, call_connection_made=True): if ssl is None: raise RuntimeError('stdlib ssl module not available') if not sslcontext: sslcontext = _create_transport_context(server_side, server_hostname) self._server_side = server_side if server_hostname and not server_side: self._server_hostname = server_hostname else: self._server_hostname = None self._sslcontext = sslcontext # SSL-specific extra info. More info are set when the handshake # completes. self._extra = dict(sslcontext=sslcontext) # App data write buffering self._write_backlog = collections.deque() self._write_buffer_size = 0 self._waiter = waiter self._loop = loop self._app_protocol = app_protocol self._app_transport = _SSLProtocolTransport(self._loop, self, self._app_protocol) # _SSLPipe instance (None until the connection is made) self._sslpipe = None self._session_established = False self._in_handshake = False self._in_shutdown = False # transport, ex: SelectorSocketTransport self._transport = None self._call_connection_made = call_connection_made def _wakeup_waiter(self, exc=None): if self._waiter is None: return if not self._waiter.cancelled(): if exc is not None: self._waiter.set_exception(exc) else: self._waiter.set_result(None) self._waiter = None def connection_made(self, transport): """Called when the low-level connection is made. Start the SSL handshake. """ self._transport = transport self._sslpipe = _SSLPipe(self._sslcontext, self._server_side, self._server_hostname) self._start_handshake() def connection_lost(self, exc): """Called when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ if self._session_established: self._session_established = False self._loop.call_soon(self._app_protocol.connection_lost, exc) self._transport = None self._app_transport = None self._wakeup_waiter(exc) def pause_writing(self): """Called when the low-level transport's buffer goes over the high-water mark. """ self._app_protocol.pause_writing() def resume_writing(self): """Called when the low-level transport's buffer drains below the low-water mark. """ self._app_protocol.resume_writing() def data_received(self, data): """Called when some SSL data is received. The argument is a bytes object. """ try: ssldata, appdata = self._sslpipe.feed_ssldata(data) except ssl.SSLError as e: if self._loop.get_debug(): logger.warning('%r: SSL error %s (reason %s)', self, e.errno, e.reason) self._abort() return for chunk in ssldata: self._transport.write(chunk) for chunk in appdata: if chunk: self._app_protocol.data_received(chunk) else: self._start_shutdown() break def eof_received(self): """Called when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ try: if self._loop.get_debug(): logger.debug("%r received EOF", self) self._wakeup_waiter(ConnectionResetError) if not self._in_handshake: keep_open = self._app_protocol.eof_received() if keep_open: logger.warning('returning true from eof_received() ' 'has no effect when using ssl') finally: self._transport.close() def _get_extra_info(self, name, default=None): if name in self._extra: return self._extra[name] elif self._transport is not None: return self._transport.get_extra_info(name, default) else: return default def _start_shutdown(self): if self._in_shutdown: return if self._in_handshake: self._abort() else: self._in_shutdown = True self._write_appdata(b'') def _write_appdata(self, data): self._write_backlog.append((data, 0)) self._write_buffer_size += len(data) self._process_write_backlog() def _start_handshake(self): if self._loop.get_debug(): logger.debug("%r starts SSL handshake", self) self._handshake_start_time = self._loop.time() else: self._handshake_start_time = None self._in_handshake = True # (b'', 1) is a special value in _process_write_backlog() to do # the SSL handshake self._write_backlog.append((b'', 1)) self._loop.call_soon(self._process_write_backlog) def _on_handshake_complete(self, handshake_exc): self._in_handshake = False sslobj = self._sslpipe.ssl_object try: if handshake_exc is not None: raise handshake_exc peercert = sslobj.getpeercert() if not hasattr(self._sslcontext, 'check_hostname'): # Verify hostname if requested, Python 3.4+ uses check_hostname # and checks the hostname in do_handshake() if (self._server_hostname and self._sslcontext.verify_mode != ssl.CERT_NONE): ssl.match_hostname(peercert, self._server_hostname) except BaseException as exc: if self._loop.get_debug(): if isinstance(exc, ssl.CertificateError): logger.warning("%r: SSL handshake failed " "on verifying the certificate", self, exc_info=True) else: logger.warning("%r: SSL handshake failed", self, exc_info=True) self._transport.close() if isinstance(exc, Exception): self._wakeup_waiter(exc) return else: raise if self._loop.get_debug(): dt = self._loop.time() - self._handshake_start_time logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3) # Add extra info that becomes available after handshake. self._extra.update(peercert=peercert, cipher=sslobj.cipher(), compression=sslobj.compression(), ssl_object=sslobj, ) if self._call_connection_made: self._app_protocol.connection_made(self._app_transport) self._wakeup_waiter() self._session_established = True # In case transport.write() was already called. Don't call # immediately _process_write_backlog(), but schedule it: # _on_handshake_complete() can be called indirectly from # _process_write_backlog(), and _process_write_backlog() is not # reentrant. self._loop.call_soon(self._process_write_backlog) def _process_write_backlog(self): # Try to make progress on the write backlog. if self._transport is None: return try: for i in range(len(self._write_backlog)): data, offset = self._write_backlog[0] if data: ssldata, offset = self._sslpipe.feed_appdata(data, offset) elif offset: ssldata = self._sslpipe.do_handshake( self._on_handshake_complete) offset = 1 else: ssldata = self._sslpipe.shutdown(self._finalize) offset = 1 for chunk in ssldata: self._transport.write(chunk) if offset < len(data): self._write_backlog[0] = (data, offset) # A short write means that a write is blocked on a read # We need to enable reading if it is paused! assert self._sslpipe.need_ssldata if self._transport._paused: self._transport.resume_reading() break # An entire chunk from the backlog was processed. We can # delete it and reduce the outstanding buffer size. del self._write_backlog[0] self._write_buffer_size -= len(data) except BaseException as exc: if self._in_handshake: # BaseExceptions will be re-raised in _on_handshake_complete. self._on_handshake_complete(exc) else: self._fatal_error(exc, 'Fatal error on SSL transport') if not isinstance(exc, Exception): # BaseException raise def _fatal_error(self, exc, message='Fatal error on transport'): # Should be called from exception handler only. if isinstance(exc, base_events._FATAL_ERROR_IGNORE): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self._transport, 'protocol': self, }) if self._transport: self._transport._force_close(exc) def _finalize(self): self._sslpipe = None if self._transport is not None: self._transport.close() def _abort(self): try: if self._transport is not None: self._transport.abort() finally: self._finalize() PK!/(W __init__.pynu["""The asyncio package, tracking PEP 3156.""" import sys # The selectors module is in the stdlib in Python 3.4 but not in 3.3. # Do this first, so the other submodules can use "from . import selectors". # Prefer asyncio/selectors.py over the stdlib one, as ours may be newer. try: from . import selectors except ImportError: import selectors # Will also be exported. if sys.platform == 'win32': # Similar thing for _overlapped. try: from . import _overlapped except ImportError: import _overlapped # Will also be exported. # This relies on each of the submodules having an __all__ variable. from .base_events import * from .coroutines import * from .events import * from .futures import * from .locks import * from .protocols import * from .queues import * from .streams import * from .subprocess import * from .tasks import * from .transports import * __all__ = (base_events.__all__ + coroutines.__all__ + events.__all__ + futures.__all__ + locks.__all__ + protocols.__all__ + queues.__all__ + streams.__all__ + subprocess.__all__ + tasks.__all__ + transports.__all__) if sys.platform == 'win32': # pragma: no cover from .windows_events import * __all__ += windows_events.__all__ else: from .unix_events import * # pragma: no cover __all__ += unix_events.__all__ PK! NNR'R' transports.pynu["""Abstract Transport class.""" from asyncio import compat __all__ = ['BaseTransport', 'ReadTransport', 'WriteTransport', 'Transport', 'DatagramTransport', 'SubprocessTransport', ] class BaseTransport: """Base class for transports.""" def __init__(self, extra=None): if extra is None: extra = {} self._extra = extra def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._extra.get(name, default) def is_closing(self): """Return True if the transport is closing or closed.""" raise NotImplementedError def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. """ raise NotImplementedError def set_protocol(self, protocol): """Set a new protocol.""" raise NotImplementedError def get_protocol(self): """Return the current protocol.""" raise NotImplementedError class ReadTransport(BaseTransport): """Interface for read-only transports.""" def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ raise NotImplementedError def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ raise NotImplementedError class WriteTransport(BaseTransport): """Interface for write-only transports.""" def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ raise NotImplementedError def get_write_buffer_size(self): """Return the current size of the write buffer.""" raise NotImplementedError def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ raise NotImplementedError def writelines(self, list_of_data): """Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. """ data = compat.flatten_list_bytes(list_of_data) self.write(data) def write_eof(self): """Close the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. """ raise NotImplementedError def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class Transport(ReadTransport, WriteTransport): """Interface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. """ class DatagramTransport(BaseTransport): """Interface for datagram (UDP) transports.""" def sendto(self, data, addr=None): """Send data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. """ raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class SubprocessTransport(BaseTransport): def get_pid(self): """Get subprocess id.""" raise NotImplementedError def get_returncode(self): """Get subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode """ raise NotImplementedError def get_pipe_transport(self, fd): """Get transport for pipe with number fd.""" raise NotImplementedError def send_signal(self, signal): """Send signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal """ raise NotImplementedError def terminate(self): """Stop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate """ raise NotImplementedError def kill(self): """Kill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill """ raise NotImplementedError class _FlowControlMixin(Transport): """All the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. """ def __init__(self, extra=None, loop=None): super().__init__(extra) assert loop is not None self._loop = loop self._protocol_paused = False self._set_write_buffer_limits() def _maybe_pause_protocol(self): size = self.get_write_buffer_size() if size <= self._high_water: return if not self._protocol_paused: self._protocol_paused = True try: self._protocol.pause_writing() except Exception as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def _maybe_resume_protocol(self): if (self._protocol_paused and self.get_write_buffer_size() <= self._low_water): self._protocol_paused = False try: self._protocol.resume_writing() except Exception as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def get_write_buffer_limits(self): return (self._low_water, self._high_water) def _set_write_buffer_limits(self, high=None, low=None): if high is None: if low is None: high = 64*1024 else: high = 4*low if low is None: low = high // 4 if not high >= low >= 0: raise ValueError('high (%r) must be >= low (%r) must be >= 0' % (high, low)) self._high_water = high self._low_water = low def set_write_buffer_limits(self, high=None, low=None): self._set_write_buffer_limits(high=high, low=low) self._maybe_pause_protocol() def get_write_buffer_size(self): raise NotImplementedError PK!yPaa exceptions.pynu["""asyncio exceptions.""" __all__ = ('CancelledError', 'InvalidStateError', 'TimeoutError', 'IncompleteReadError', 'LimitOverrunError', 'SendfileNotAvailableError') class CancelledError(BaseException): """The Future or Task was cancelled.""" class TimeoutError(Exception): """The operation exceeded the given deadline.""" class InvalidStateError(Exception): """The operation is not allowed in this state.""" class SendfileNotAvailableError(RuntimeError): """Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. """ class IncompleteReadError(EOFError): """ Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) """ def __init__(self, partial, expected): r_expected = 'undefined' if expected is None else repr(expected) super().__init__(f'{len(partial)} bytes read on a total of ' f'{r_expected} expected bytes') self.partial = partial self.expected = expected def __reduce__(self): return type(self), (self.partial, self.expected) class LimitOverrunError(Exception): """Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. """ def __init__(self, message, consumed): super().__init__(message) self.consumed = consumed def __reduce__(self): return type(self), (self.args[0], self.consumed) PK!n base_tasks.pynu[import linecache import traceback from . import base_futures from . import coroutines def _task_repr_info(task): info = base_futures._future_repr_info(task) if task._must_cancel: # replace status info[0] = 'cancelling' info.insert(1, 'name=%r' % task.get_name()) coro = coroutines._format_coroutine(task._coro) info.insert(2, f'coro=<{coro}>') if task._fut_waiter is not None: info.insert(3, f'wait_for={task._fut_waiter!r}') return info def _task_get_stack(task, limit): frames = [] if hasattr(task._coro, 'cr_frame'): # case 1: 'async def' coroutines f = task._coro.cr_frame elif hasattr(task._coro, 'gi_frame'): # case 2: legacy coroutines f = task._coro.gi_frame elif hasattr(task._coro, 'ag_frame'): # case 3: async generators f = task._coro.ag_frame else: # case 4: unknown objects f = None if f is not None: while f is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(f) f = f.f_back frames.reverse() elif task._exception is not None: tb = task._exception.__traceback__ while tb is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(tb.tb_frame) tb = tb.tb_next return frames def _task_print_stack(task, limit, file): extracted_list = [] checked = set() for f in task.get_stack(limit=limit): lineno = f.f_lineno co = f.f_code filename = co.co_filename name = co.co_name if filename not in checked: checked.add(filename) linecache.checkcache(filename) line = linecache.getline(filename, lineno, f.f_globals) extracted_list.append((filename, lineno, name, line)) exc = task._exception if not extracted_list: print(f'No stack for {task!r}', file=file) elif exc is not None: print(f'Traceback for {task!r} (most recent call last):', file=file) else: print(f'Stack for {task!r} (most recent call last):', file=file) traceback.print_list(extracted_list, file=file) if exc is not None: for line in traceback.format_exception_only(exc.__class__, exc): print(line, file=file, end='') PK!fTYTY events.pynu["""Event loop and event loop policy.""" __all__ = ['AbstractEventLoopPolicy', 'AbstractEventLoop', 'AbstractServer', 'Handle', 'TimerHandle', 'get_event_loop_policy', 'set_event_loop_policy', 'get_event_loop', 'set_event_loop', 'new_event_loop', 'get_child_watcher', 'set_child_watcher', '_set_running_loop', '_get_running_loop', ] import functools import inspect import os import reprlib import socket import subprocess import sys import threading import traceback from asyncio import compat def _get_function_source(func): if compat.PY34: func = inspect.unwrap(func) elif hasattr(func, '__wrapped__'): func = func.__wrapped__ if inspect.isfunction(func): code = func.__code__ return (code.co_filename, code.co_firstlineno) if isinstance(func, functools.partial): return _get_function_source(func.func) if compat.PY34 and isinstance(func, functools.partialmethod): return _get_function_source(func.func) return None def _format_args_and_kwargs(args, kwargs): """Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). """ # use reprlib to limit the length of the output items = [] if args: items.extend(reprlib.repr(arg) for arg in args) if kwargs: items.extend('{}={}'.format(k, reprlib.repr(v)) for k, v in kwargs.items()) return '(' + ', '.join(items) + ')' def _format_callback(func, args, kwargs, suffix=''): if isinstance(func, functools.partial): suffix = _format_args_and_kwargs(args, kwargs) + suffix return _format_callback(func.func, func.args, func.keywords, suffix) if hasattr(func, '__qualname__'): func_repr = getattr(func, '__qualname__') elif hasattr(func, '__name__'): func_repr = getattr(func, '__name__') else: func_repr = repr(func) func_repr += _format_args_and_kwargs(args, kwargs) if suffix: func_repr += suffix return func_repr def _format_callback_source(func, args): func_repr = _format_callback(func, args, None) source = _get_function_source(func) if source: func_repr += ' at %s:%s' % source return func_repr class Handle: """Object returned by callback registration methods.""" __slots__ = ('_callback', '_args', '_cancelled', '_loop', '_source_traceback', '_repr', '__weakref__') def __init__(self, callback, args, loop): self._loop = loop self._callback = callback self._args = args self._cancelled = False self._repr = None if self._loop.get_debug(): self._source_traceback = traceback.extract_stack(sys._getframe(1)) else: self._source_traceback = None def _repr_info(self): info = [self.__class__.__name__] if self._cancelled: info.append('cancelled') if self._callback is not None: info.append(_format_callback_source(self._callback, self._args)) if self._source_traceback: frame = self._source_traceback[-1] info.append('created at %s:%s' % (frame[0], frame[1])) return info def __repr__(self): if self._repr is not None: return self._repr info = self._repr_info() return '<%s>' % ' '.join(info) def cancel(self): if not self._cancelled: self._cancelled = True if self._loop.get_debug(): # Keep a representation in debug mode to keep callback and # parameters. For example, to log the warning # "Executing took 2.5 second" self._repr = repr(self) self._callback = None self._args = None def _run(self): try: self._callback(*self._args) except Exception as exc: cb = _format_callback_source(self._callback, self._args) msg = 'Exception in callback {}'.format(cb) context = { 'message': msg, 'exception': exc, 'handle': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self = None # Needed to break cycles when an exception occurs. class TimerHandle(Handle): """Object returned by timed callback registration methods.""" __slots__ = ['_scheduled', '_when'] def __init__(self, when, callback, args, loop): assert when is not None super().__init__(callback, args, loop) if self._source_traceback: del self._source_traceback[-1] self._when = when self._scheduled = False def _repr_info(self): info = super()._repr_info() pos = 2 if self._cancelled else 1 info.insert(pos, 'when=%s' % self._when) return info def __hash__(self): return hash(self._when) def __lt__(self, other): return self._when < other._when def __le__(self, other): if self._when < other._when: return True return self.__eq__(other) def __gt__(self, other): return self._when > other._when def __ge__(self, other): if self._when > other._when: return True return self.__eq__(other) def __eq__(self, other): if isinstance(other, TimerHandle): return (self._when == other._when and self._callback == other._callback and self._args == other._args and self._cancelled == other._cancelled) return NotImplemented def __ne__(self, other): equal = self.__eq__(other) return NotImplemented if equal is NotImplemented else not equal def cancel(self): if not self._cancelled: self._loop._timer_handle_cancelled(self) super().cancel() class AbstractServer: """Abstract server returned by create_server().""" def close(self): """Stop serving. This leaves existing connections open.""" return NotImplemented def wait_closed(self): """Coroutine to wait until service is closed.""" return NotImplemented class AbstractEventLoop: """Abstract event loop.""" # Running and stopping the event loop. def run_forever(self): """Run the event loop until stop() is called.""" raise NotImplementedError def run_until_complete(self, future): """Run the event loop until a Future is done. Return the Future's result, or raise its exception. """ raise NotImplementedError def stop(self): """Stop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. """ raise NotImplementedError def is_running(self): """Return whether the event loop is currently running.""" raise NotImplementedError def is_closed(self): """Returns True if the event loop was closed.""" raise NotImplementedError def close(self): """Close the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. """ raise NotImplementedError def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" raise NotImplementedError # Methods scheduling callbacks. All these return Handles. def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" raise NotImplementedError def call_soon(self, callback, *args): return self.call_later(0, callback, *args) def call_later(self, delay, callback, *args): raise NotImplementedError def call_at(self, when, callback, *args): raise NotImplementedError def time(self): raise NotImplementedError def create_future(self): raise NotImplementedError # Method scheduling a coroutine object: create a task. def create_task(self, coro): raise NotImplementedError # Methods for interacting with threads. def call_soon_threadsafe(self, callback, *args): raise NotImplementedError def run_in_executor(self, executor, func, *args): raise NotImplementedError def set_default_executor(self, executor): raise NotImplementedError # Network I/O methods returning Futures. def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): raise NotImplementedError def getnameinfo(self, sockaddr, flags=0): raise NotImplementedError def create_connection(self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None): raise NotImplementedError def create_server(self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None): """A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. """ raise NotImplementedError def create_unix_connection(self, protocol_factory, path, *, ssl=None, sock=None, server_hostname=None): raise NotImplementedError def create_unix_server(self, protocol_factory, path, *, sock=None, backlog=100, ssl=None): """A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. """ raise NotImplementedError def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None): """A coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. """ raise NotImplementedError # Pipes and subprocesses. def connect_read_pipe(self, protocol_factory, pipe): """Register read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vise versa. raise NotImplementedError def connect_write_pipe(self, protocol_factory, pipe): """Register write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vise versa. raise NotImplementedError def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError def subprocess_exec(self, protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError # Ready-based callback registration methods. # The add_*() methods return None. # The remove_*() methods return True if something was removed, # False if there was nothing to delete. def add_reader(self, fd, callback, *args): raise NotImplementedError def remove_reader(self, fd): raise NotImplementedError def add_writer(self, fd, callback, *args): raise NotImplementedError def remove_writer(self, fd): raise NotImplementedError # Completion based I/O methods returning Futures. def sock_recv(self, sock, nbytes): raise NotImplementedError def sock_sendall(self, sock, data): raise NotImplementedError def sock_connect(self, sock, address): raise NotImplementedError def sock_accept(self, sock): raise NotImplementedError # Signal handling. def add_signal_handler(self, sig, callback, *args): raise NotImplementedError def remove_signal_handler(self, sig): raise NotImplementedError # Task factory. def set_task_factory(self, factory): raise NotImplementedError def get_task_factory(self): raise NotImplementedError # Error handlers. def get_exception_handler(self): raise NotImplementedError def set_exception_handler(self, handler): raise NotImplementedError def default_exception_handler(self, context): raise NotImplementedError def call_exception_handler(self, context): raise NotImplementedError # Debug flag management. def get_debug(self): raise NotImplementedError def set_debug(self, enabled): raise NotImplementedError class AbstractEventLoopPolicy: """Abstract policy for accessing the event loop.""" def get_event_loop(self): """Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.""" raise NotImplementedError def set_event_loop(self, loop): """Set the event loop for the current context to loop.""" raise NotImplementedError def new_event_loop(self): """Create and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.""" raise NotImplementedError # Child processes handling (Unix only). def get_child_watcher(self): "Get the watcher for child processes." raise NotImplementedError def set_child_watcher(self, watcher): """Set the watcher for child processes.""" raise NotImplementedError class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy): """Default policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). """ _loop_factory = None class _Local(threading.local): _loop = None _set_called = False def __init__(self): self._local = self._Local() def get_event_loop(self): """Get the event loop. This may be None or an instance of EventLoop. """ if (self._local._loop is None and not self._local._set_called and isinstance(threading.current_thread(), threading._MainThread)): self.set_event_loop(self.new_event_loop()) if self._local._loop is None: raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) return self._local._loop def set_event_loop(self, loop): """Set the event loop.""" self._local._set_called = True assert loop is None or isinstance(loop, AbstractEventLoop) self._local._loop = loop def new_event_loop(self): """Create a new event loop. You must call set_event_loop() to make this the current event loop. """ return self._loop_factory() # Event loop policy. The policy itself is always global, even if the # policy's rules say that there is an event loop per thread (or other # notion of context). The default policy is installed by the first # call to get_event_loop_policy(). _event_loop_policy = None # Lock for protecting the on-the-fly creation of the event loop policy. _lock = threading.Lock() # A TLS for the running event loop, used by _get_running_loop. class _RunningLoop(threading.local): _loop = None _pid = None _running_loop = _RunningLoop() def _get_running_loop(): """Return the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. """ running_loop = _running_loop._loop if running_loop is not None and _running_loop._pid == os.getpid(): return running_loop def _set_running_loop(loop): """Set the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. """ _running_loop._pid = os.getpid() _running_loop._loop = loop def _init_event_loop_policy(): global _event_loop_policy with _lock: if _event_loop_policy is None: # pragma: no branch from . import DefaultEventLoopPolicy _event_loop_policy = DefaultEventLoopPolicy() def get_event_loop_policy(): """Get the current event loop policy.""" if _event_loop_policy is None: _init_event_loop_policy() return _event_loop_policy def set_event_loop_policy(policy): """Set the current event loop policy. If policy is None, the default policy is restored.""" global _event_loop_policy assert policy is None or isinstance(policy, AbstractEventLoopPolicy) _event_loop_policy = policy def get_event_loop(): """Return an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. """ current_loop = _get_running_loop() if current_loop is not None: return current_loop return get_event_loop_policy().get_event_loop() def set_event_loop(loop): """Equivalent to calling get_event_loop_policy().set_event_loop(loop).""" get_event_loop_policy().set_event_loop(loop) def new_event_loop(): """Equivalent to calling get_event_loop_policy().new_event_loop().""" return get_event_loop_policy().new_event_loop() def get_child_watcher(): """Equivalent to calling get_event_loop_policy().get_child_watcher().""" return get_event_loop_policy().get_child_watcher() def set_child_watcher(watcher): """Equivalent to calling get_event_loop_policy().set_child_watcher(watcher).""" return get_event_loop_policy().set_child_watcher(watcher) PK!3 subprocess.pynu[__all__ = ['create_subprocess_exec', 'create_subprocess_shell'] import subprocess from . import events from . import protocols from . import streams from . import tasks from .coroutines import coroutine from .log import logger PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT DEVNULL = subprocess.DEVNULL class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol): """Like StreamReaderProtocol, but for a subprocess.""" def __init__(self, limit, loop): super().__init__(loop=loop) self._limit = limit self.stdin = self.stdout = self.stderr = None self._transport = None self._process_exited = False self._pipe_fds = [] def __repr__(self): info = [self.__class__.__name__] if self.stdin is not None: info.append('stdin=%r' % self.stdin) if self.stdout is not None: info.append('stdout=%r' % self.stdout) if self.stderr is not None: info.append('stderr=%r' % self.stderr) return '<%s>' % ' '.join(info) def connection_made(self, transport): self._transport = transport stdout_transport = transport.get_pipe_transport(1) if stdout_transport is not None: self.stdout = streams.StreamReader(limit=self._limit, loop=self._loop) self.stdout.set_transport(stdout_transport) self._pipe_fds.append(1) stderr_transport = transport.get_pipe_transport(2) if stderr_transport is not None: self.stderr = streams.StreamReader(limit=self._limit, loop=self._loop) self.stderr.set_transport(stderr_transport) self._pipe_fds.append(2) stdin_transport = transport.get_pipe_transport(0) if stdin_transport is not None: self.stdin = streams.StreamWriter(stdin_transport, protocol=self, reader=None, loop=self._loop) def pipe_data_received(self, fd, data): if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader is not None: reader.feed_data(data) def pipe_connection_lost(self, fd, exc): if fd == 0: pipe = self.stdin if pipe is not None: pipe.close() self.connection_lost(exc) return if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader != None: if exc is None: reader.feed_eof() else: reader.set_exception(exc) if fd in self._pipe_fds: self._pipe_fds.remove(fd) self._maybe_close_transport() def process_exited(self): self._process_exited = True self._maybe_close_transport() def _maybe_close_transport(self): if len(self._pipe_fds) == 0 and self._process_exited: self._transport.close() self._transport = None class Process: def __init__(self, transport, protocol, loop): self._transport = transport self._protocol = protocol self._loop = loop self.stdin = protocol.stdin self.stdout = protocol.stdout self.stderr = protocol.stderr self.pid = transport.get_pid() def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self.pid) @property def returncode(self): return self._transport.get_returncode() @coroutine def wait(self): """Wait until the process exit and return the process return code. This method is a coroutine.""" return (yield from self._transport._wait()) def send_signal(self, signal): self._transport.send_signal(signal) def terminate(self): self._transport.terminate() def kill(self): self._transport.kill() @coroutine def _feed_stdin(self, input): debug = self._loop.get_debug() self.stdin.write(input) if debug: logger.debug('%r communicate: feed stdin (%s bytes)', self, len(input)) try: yield from self.stdin.drain() except (BrokenPipeError, ConnectionResetError) as exc: # communicate() ignores BrokenPipeError and ConnectionResetError if debug: logger.debug('%r communicate: stdin got %r', self, exc) if debug: logger.debug('%r communicate: close stdin', self) self.stdin.close() @coroutine def _noop(self): return None @coroutine def _read_stream(self, fd): transport = self._transport.get_pipe_transport(fd) if fd == 2: stream = self.stderr else: assert fd == 1 stream = self.stdout if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: read %s', self, name) output = yield from stream.read() if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: close %s', self, name) transport.close() return output @coroutine def communicate(self, input=None): if input is not None: stdin = self._feed_stdin(input) else: stdin = self._noop() if self.stdout is not None: stdout = self._read_stream(1) else: stdout = self._noop() if self.stderr is not None: stderr = self._read_stream(2) else: stderr = self._noop() stdin, stdout, stderr = yield from tasks.gather(stdin, stdout, stderr, loop=self._loop) yield from self.wait() return (stdout, stderr) @coroutine def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, loop=None, limit=streams._DEFAULT_LIMIT, **kwds): if loop is None: loop = events.get_event_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = yield from loop.subprocess_shell( protocol_factory, cmd, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) @coroutine def create_subprocess_exec(program, *args, stdin=None, stdout=None, stderr=None, loop=None, limit=streams._DEFAULT_LIMIT, **kwds): if loop is None: loop = events.get_event_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = yield from loop.subprocess_exec( protocol_factory, program, *args, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) PK!mX3 3 __main__.pynu[import ast import asyncio import code import concurrent.futures import inspect import sys import threading import types import warnings from . import futures class AsyncIOInteractiveConsole(code.InteractiveConsole): def __init__(self, locals, loop): super().__init__(locals) self.compile.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT self.loop = loop def runcode(self, code): future = concurrent.futures.Future() def callback(): global repl_future global repl_future_interrupted repl_future = None repl_future_interrupted = False func = types.FunctionType(code, self.locals) try: coro = func() except SystemExit: raise except KeyboardInterrupt as ex: repl_future_interrupted = True future.set_exception(ex) return except BaseException as ex: future.set_exception(ex) return if not inspect.iscoroutine(coro): future.set_result(coro) return try: repl_future = self.loop.create_task(coro) futures._chain_future(repl_future, future) except BaseException as exc: future.set_exception(exc) loop.call_soon_threadsafe(callback) try: return future.result() except SystemExit: raise except BaseException: if repl_future_interrupted: self.write("\nKeyboardInterrupt\n") else: self.showtraceback() class REPLThread(threading.Thread): def run(self): try: banner = ( f'asyncio REPL {sys.version} on {sys.platform}\n' f'Use "await" directly instead of "asyncio.run()".\n' f'Type "help", "copyright", "credits" or "license" ' f'for more information.\n' f'{getattr(sys, "ps1", ">>> ")}import asyncio' ) console.interact( banner=banner, exitmsg='exiting asyncio REPL...') finally: warnings.filterwarnings( 'ignore', message=r'^coroutine .* was never awaited$', category=RuntimeWarning) loop.call_soon_threadsafe(loop.stop) if __name__ == '__main__': sys.audit("cpython.run_stdin") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) repl_locals = {'asyncio': asyncio} for key in {'__name__', '__package__', '__loader__', '__spec__', '__builtins__', '__file__'}: repl_locals[key] = locals()[key] console = AsyncIOInteractiveConsole(repl_locals, loop) repl_future = None repl_future_interrupted = False try: import readline # NoQA except ImportError: pass repl_thread = REPLThread() repl_thread.daemon = True repl_thread.start() while True: try: loop.run_forever() except KeyboardInterrupt: if repl_future and not repl_future.done(): repl_future.cancel() repl_future_interrupted = True continue else: break PK!  base_futures.pynu[__all__ = () import reprlib from _thread import get_ident from . import format_helpers # States for Future. _PENDING = 'PENDING' _CANCELLED = 'CANCELLED' _FINISHED = 'FINISHED' def isfuture(obj): """Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. """ return (hasattr(obj.__class__, '_asyncio_future_blocking') and obj._asyncio_future_blocking is not None) def _format_callbacks(cb): """helper function for Future.__repr__""" size = len(cb) if not size: cb = '' def format_cb(callback): return format_helpers._format_callback_source(callback, ()) if size == 1: cb = format_cb(cb[0][0]) elif size == 2: cb = '{}, {}'.format(format_cb(cb[0][0]), format_cb(cb[1][0])) elif size > 2: cb = '{}, <{} more>, {}'.format(format_cb(cb[0][0]), size - 2, format_cb(cb[-1][0])) return f'cb=[{cb}]' # bpo-42183: _repr_running is needed for repr protection # when a Future or Task result contains itself directly or indirectly. # The logic is borrowed from @reprlib.recursive_repr decorator. # Unfortunately, the direct decorator usage is impossible because of # AttributeError: '_asyncio.Task' object has no attribute '__module__' error. # # After fixing this thing we can return to the decorator based approach. _repr_running = set() def _future_repr_info(future): # (Future) -> str """helper function for Future.__repr__""" info = [future._state.lower()] if future._state == _FINISHED: if future._exception is not None: info.append(f'exception={future._exception!r}') else: key = id(future), get_ident() if key in _repr_running: result = '...' else: _repr_running.add(key) try: # use reprlib to limit the length of the output, especially # for very long strings result = reprlib.repr(future._result) finally: _repr_running.discard(key) info.append(f'result={result}') if future._callbacks: info.append(_format_callbacks(future._callbacks)) if future._source_traceback: frame = future._source_traceback[-1] info.append(f'created at {frame[0]}:{frame[1]}') return info PK!ҰɥNNproactor_events.pynu["""Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. """ __all__ = ['BaseProactorEventLoop'] import socket import warnings from . import base_events from . import compat from . import constants from . import futures from . import sslproto from . import transports from .log import logger class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): """Base class for pipe and socket transports.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(extra, loop) self._set_extra(sock) self._sock = sock self._protocol = protocol self._server = server self._buffer = None # None or bytearray. self._read_fut = None self._write_fut = None self._pending_write = 0 self._conn_lost = 0 self._closing = False # Set when close() called. self._eof_written = False if self._server is not None: self._server._attach() self._loop.call_soon(self._protocol.connection_made, self) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') if self._sock is not None: info.append('fd=%s' % self._sock.fileno()) if self._read_fut is not None: info.append('read=%s' % self._read_fut) if self._write_fut is not None: info.append("write=%r" % self._write_fut) if self._buffer: bufsize = len(self._buffer) info.append('write_bufsize=%s' % bufsize) if self._eof_written: info.append('EOF written') return '<%s>' % ' '.join(info) def _set_extra(self, sock): self._extra['pipe'] = sock def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._closing: return self._closing = True self._conn_lost += 1 if not self._buffer and self._write_fut is None: self._loop.call_soon(self._call_connection_lost, None) if self._read_fut is not None: self._read_fut.cancel() self._read_fut = None # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if self._sock is not None: warnings.warn("unclosed transport %r" % self, ResourceWarning) self.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): if isinstance(exc, base_events._FATAL_ERROR_IGNORE): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._force_close(exc) def _force_close(self, exc): if self._closing: return self._closing = True self._conn_lost += 1 if self._write_fut: self._write_fut.cancel() self._write_fut = None if self._read_fut: self._read_fut.cancel() self._read_fut = None self._pending_write = 0 self._buffer = None self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: # XXX If there is a pending overlapped read on the other # end then it may fail with ERROR_NETNAME_DELETED if we # just close our end. First calling shutdown() seems to # cure it, but maybe using DisconnectEx() would be better. if hasattr(self._sock, 'shutdown'): self._sock.shutdown(socket.SHUT_RDWR) self._sock.close() self._sock = None server = self._server if server is not None: server._detach() self._server = None def get_write_buffer_size(self): size = self._pending_write if self._buffer is not None: size += len(self._buffer) return size class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): """Transport for read pipes.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(loop, sock, protocol, waiter, extra, server) self._paused = False self._loop.call_soon(self._loop_reading) def pause_reading(self): if self._closing: raise RuntimeError('Cannot pause_reading() when closing') if self._paused: raise RuntimeError('Already paused') self._paused = True if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if not self._paused: raise RuntimeError('Not paused') self._paused = False if self._closing: return self._loop.call_soon(self._loop_reading, self._read_fut) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def _loop_reading(self, fut=None): if self._paused: return data = None try: if fut is not None: assert self._read_fut is fut or (self._read_fut is None and self._closing) self._read_fut = None data = fut.result() # deliver data later in "finally" clause if self._closing: # since close() has been called we ignore any read data data = None return if data == b'': # we got end-of-file so no need to reschedule a new read return # reschedule a new read self._read_fut = self._loop._proactor.recv(self._sock, 4096) except ConnectionAbortedError as exc: if not self._closing: self._fatal_error(exc, 'Fatal read error on pipe transport') elif self._loop.get_debug(): logger.debug("Read error on pipe transport while closing", exc_info=True) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') except futures.CancelledError: if not self._closing: raise else: self._read_fut.add_done_callback(self._loop_reading) finally: if data: self._protocol.data_received(data) elif data is not None: if self._loop.get_debug(): logger.debug("%r received EOF", self) keep_open = self._protocol.eof_received() if not keep_open: self.close() class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): """Transport for write pipes.""" def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): msg = ("data argument must be a bytes-like object, not '%s'" % type(data).__name__) raise TypeError(msg) if self._eof_written: raise RuntimeError('write_eof() already called') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return # Observable states: # 1. IDLE: _write_fut and _buffer both None # 2. WRITING: _write_fut set; _buffer None # 3. BACKED UP: _write_fut set; _buffer a bytearray # We always copy the data, so the caller can't modify it # while we're still waiting for the I/O to happen. if self._write_fut is None: # IDLE -> WRITING assert self._buffer is None # Pass a copy, except if it's already immutable. self._loop_writing(data=bytes(data)) elif not self._buffer: # WRITING -> BACKED UP # Make a mutable copy which we can extend. self._buffer = bytearray(data) self._maybe_pause_protocol() else: # BACKED UP # Append to buffer (also copies). self._buffer.extend(data) self._maybe_pause_protocol() def _loop_writing(self, f=None, data=None): try: assert f is self._write_fut self._write_fut = None self._pending_write = 0 if f: f.result() if data is None: data = self._buffer self._buffer = None if not data: if self._closing: self._loop.call_soon(self._call_connection_lost, None) if self._eof_written: self._sock.shutdown(socket.SHUT_WR) # Now that we've reduced the buffer size, tell the # protocol to resume writing if it was paused. Note that # we do this last since the callback is called immediately # and it may add more data to the buffer (even causing the # protocol to be paused again). self._maybe_resume_protocol() else: self._write_fut = self._loop._proactor.send(self._sock, data) if not self._write_fut.done(): assert self._pending_write == 0 self._pending_write = len(data) self._write_fut.add_done_callback(self._loop_writing) self._maybe_pause_protocol() else: self._write_fut.add_done_callback(self._loop_writing) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal write error on pipe transport') def can_write_eof(self): return True def write_eof(self): self.close() def abort(self): self._force_close(None) class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): def __init__(self, *args, **kw): super().__init__(*args, **kw) self._read_fut = self._loop._proactor.recv(self._sock, 16) self._read_fut.add_done_callback(self._pipe_closed) def _pipe_closed(self, fut): if fut.cancelled(): # the transport has been closed return assert fut.result() == b'' if self._closing: assert self._read_fut is None return assert fut is self._read_fut, (fut, self._read_fut) self._read_fut = None if self._write_fut is not None: self._force_close(BrokenPipeError()) else: self.close() class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for duplex pipes.""" def can_write_eof(self): return False def write_eof(self): raise NotImplementedError class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for connected sockets.""" def _set_extra(self, sock): self._extra['socket'] = sock try: self._extra['sockname'] = sock.getsockname() except (socket.error, AttributeError): if self._loop.get_debug(): logger.warning("getsockname() failed on %r", sock, exc_info=True) if 'peername' not in self._extra: try: self._extra['peername'] = sock.getpeername() except (socket.error, AttributeError): if self._loop.get_debug(): logger.warning("getpeername() failed on %r", sock, exc_info=True) def can_write_eof(self): return True def write_eof(self): if self._closing or self._eof_written: return self._eof_written = True if self._write_fut is None: self._sock.shutdown(socket.SHUT_WR) class BaseProactorEventLoop(base_events.BaseEventLoop): def __init__(self, proactor): super().__init__() logger.debug('Using proactor: %s', proactor.__class__.__name__) self._proactor = proactor self._selector = proactor # convenient alias self._self_reading_future = None self._accept_futures = {} # socket file descriptor => Future proactor.set_loop(self) self._make_self_pipe() def _make_socket_transport(self, sock, protocol, waiter=None, extra=None, server=None): return _ProactorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None): if not sslproto._is_sslproto_available(): raise NotImplementedError("Proactor event loop requires Python 3.5" " or newer (ssl.MemoryBIO) to support " "SSL") ssl_protocol = sslproto.SSLProtocol(self, protocol, sslcontext, waiter, server_side, server_hostname) _ProactorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_duplex_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorDuplexPipeTransport(self, sock, protocol, waiter, extra) def _make_read_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorReadPipeTransport(self, sock, protocol, waiter, extra) def _make_write_pipe_transport(self, sock, protocol, waiter=None, extra=None): # We want connection_lost() to be called when other end closes return _ProactorWritePipeTransport(self, sock, protocol, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return # Call these methods before closing the event loop (before calling # BaseEventLoop.close), because they can schedule callbacks with # call_soon(), which is forbidden when the event loop is closed. self._stop_accept_futures() self._close_self_pipe() self._proactor.close() self._proactor = None self._selector = None # Close the event loop super().close() def sock_recv(self, sock, n): return self._proactor.recv(sock, n) def sock_sendall(self, sock, data): return self._proactor.send(sock, data) def sock_connect(self, sock, address): return self._proactor.connect(sock, address) def sock_accept(self, sock): return self._proactor.accept(sock) def _socketpair(self): raise NotImplementedError def _close_self_pipe(self): if self._self_reading_future is not None: self._self_reading_future.cancel() self._self_reading_future = None self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = self._socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 self.call_soon(self._loop_self_reading) def _loop_self_reading(self, f=None): try: if f is not None: f.result() # may raise f = self._proactor.recv(self._ssock, 4096) except futures.CancelledError: # _close_self_pipe() has been called, stop waiting for data return except Exception as exc: self.call_exception_handler({ 'message': 'Error on reading from the event loop self pipe', 'exception': exc, 'loop': self, }) else: self._self_reading_future = f f.add_done_callback(self._loop_self_reading) def _write_to_self(self): self._csock.send(b'\0') def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100): def loop(f=None): try: if f is not None: conn, addr = f.result() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) protocol = protocol_factory() if sslcontext is not None: self._make_ssl_transport( conn, protocol, sslcontext, server_side=True, extra={'peername': addr}, server=server) else: self._make_socket_transport( conn, protocol, extra={'peername': addr}, server=server) if self.is_closed(): return f = self._proactor.accept(sock) except OSError as exc: if sock.fileno() != -1: self.call_exception_handler({ 'message': 'Accept failed on a socket', 'exception': exc, 'socket': sock, }) sock.close() elif self._debug: logger.debug("Accept failed on socket %r", sock, exc_info=True) except futures.CancelledError: sock.close() else: self._accept_futures[sock.fileno()] = f f.add_done_callback(loop) self.call_soon(loop) def _process_events(self, event_list): # Events are processed in the IocpProactor._poll() method pass def _stop_accept_futures(self): for future in self._accept_futures.values(): future.cancel() self._accept_futures.clear() def _stop_serving(self, sock): self._stop_accept_futures() self._proactor._stop_serving(sock) sock.close() PK!#)!!$__pycache__/protocols.cpython-38.pycnu[U if@sbdZdZGdddZGdddeZGdddeZGdd d eZGd d d eZd d ZdS)zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s4eZdZdZdZddZddZddZd d Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)selfZ transportrr6/opt/alt/python38/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrrexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrrrrr pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrr rrrresume_writing;szBaseProtocol.resume_writingN) __name__ __module__ __qualname____doc__ __slots__r r rrrrrrr s  rc@s$eZdZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_received^szProtocol.data_receivedcCsdSzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrr rrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZddZddZddZd S) raInterface for stream protocol with manual buffer control. Important: this has been added to asyncio in Python 3.7 *on a provisional basis*! Consider it as an experimental API that might be changed or removed in Python 3.8. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcCsdS)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdS)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)rnbytesrrrbuffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrr rrrrszBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms  rc@s$eZdZdZdZddZddZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrr rrrerror_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrrrrsrc@s,eZdZdZdZddZddZddZd S) rz,Interface for protocol for subprocess calls.rcCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr rrrprocess_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrrs rcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr_feed_data_to_buffered_protos     r&N)r__all__rrrrrr&rrrrs9+9PK!مTT*__pycache__/constants.cpython-38.opt-1.pycnu[U ifx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r 6/opt/alt/python38/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s PK!#)!!*__pycache__/protocols.cpython-38.opt-1.pycnu[U if@sbdZdZGdddZGdddeZGdddeZGdd d eZGd d d eZd d ZdS)zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s4eZdZdZdZddZddZddZd d Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)selfZ transportrr6/opt/alt/python38/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrrexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrrrrr pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrr rrrresume_writing;szBaseProtocol.resume_writingN) __name__ __module__ __qualname____doc__ __slots__r r rrrrrrr s  rc@s$eZdZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_received^szProtocol.data_receivedcCsdSzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrr rrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZddZddZddZd S) raInterface for stream protocol with manual buffer control. Important: this has been added to asyncio in Python 3.7 *on a provisional basis*! Consider it as an experimental API that might be changed or removed in Python 3.8. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcCsdS)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdS)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)rnbytesrrrbuffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrr rrrrszBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms  rc@s$eZdZdZdZddZddZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrr rrrerror_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrrrrsrc@s,eZdZdZdZddZddZddZd S) rz,Interface for protocol for subprocess calls.rcCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr rrrprocess_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrrs rcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr_feed_data_to_buffered_protos     r&N)r__all__rrrrrr&rrrrs9+9PK!) yy,__pycache__/base_events.cpython-38.opt-1.pycnu[U if@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%e dZ&dZ'e(Z)ddZ*ddZ+ddZ,d+ddZ-d,ddZ.dd Z/e%e d!rd"d#Z0nd$d#Z0Gd%d&d&ej1Z2Gd'd(d(ej3Z4Gd)d*d*ej5Z6dS)-aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr8/opt/alt/python38/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETr"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs|jd7_dSrZ)rrqrrr_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|dS)Nrr)rr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdS)NT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.r)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)zDSchedule a coroutine object. Return a task object. N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)zRun until stop() is called.) firstiter finalizerFN)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonr)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rZHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrrrr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r&c s2|jr|j}ntj}|d|||||||IdHSrB)rr+r$r$r)rfr;r<r=r>r?r&Z getaddr_funcrrrr$2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr&rrrr-<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr.rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr1rfr*r3r4r5rrrr0Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r9minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r3r4r5 blocksizebuf total_sentviewreadrrrr2Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)Nbmodez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r})) rr%r>r$r1rr4r5formatr8rrrr/os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)z$Create, bind and connect one socket.Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr'rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r&r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfd d |D| d IdH\}}}|dkr d d Dt dkrdnJt dt fdd Dr҈dtd d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r&r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrP)rCr))r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r"css|]}t|VqdSrBr]r^rrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrPr Zstaggered_racerrallrEr#r>_create_connection_transportrget_extra_inforr)rfrr;r<rQr=r?r&r*rRrrrSrTinfosr)rOrnrr)rr[r_rfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rHrdrboolrrr) rfr*rrQrrrrrrrnrrrrc%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)aSend a file to transport. Return the total number of bytes which were sent. The method uses high-performance os.sendfile if available. file must be a regular file object opened in binary mode. 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. fallback set to True makes asyncio to manually read and send the file when the platform does not support the sendfile syscall (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support sendfile syscall and fallback is False. zTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr1_sendfile_fallback)rfrnr3r4r5r.rDrWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr7)rfrgr3r4r5rrrrinszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr9) r9r:r;r\r#r{r<rr=rkwrite) rfrgr3r4r5r>r?r@r?rArBrrrrjrs* z BaseEventLoop._sendfile_fallbackrgc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS) zzUpgrade transport to TLS. Return a new transport that *protocol* should start using immediately. Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rQrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r& reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| d d} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st dqڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk r|j||tj|||dIdH}|std|D]:\}}}}}||f}||krddg||<||||<qqfdd|D}|sHtdg}|tk rv|rftdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tjtjd| d r| |r| s| | |IdH|} Wn^tk rJ}z | dk r0| !|"|W5d}~XYn&| dk rb| !YnXq|qz|d |}|#}|$| || |}|j%r̈rt&d||nt'd||z|IdHWn|!YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rR remote_addrr=r?r&rorprqr"css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrrWrXcs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrRrrrrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r) stacklevelrFz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%dictr#itemsrHr#rwrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorra_unsetrrrr+r&r'Z SO_BROADCASTrIrNrr9rdrrr%r) rfrrRrrr=r?r&rorprqr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxreZfamrOZprorryrZ local_addressZremote_addressrWrrrnrrzrcreate_datagram_endpoints$                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nrr,)rAr$) rfrr=r>r?r&rr;r<r%rrrraLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r&rz getaddrinfo(z) returned empty list)rar$r1r()rfr;r<r=r&rerrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r&r*rrQrorprrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd |D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d dYqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNrUrVposixcygwinr.csg|]}j|dqS))r=r&)r)rCr;r=r&r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedr`rrz %r is serving).rrhr5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrIr(rLrJrKr>r1rHrrrr%)rfrr;r<r=r&r*rrQrorprrrZhostsZfsreZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rQrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS) aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r`NrUr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rcrrdrr)rfrr*rQrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrrfilenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrrrrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrrr#)rfr'rrrr%rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) Nzcmd must be a string universal_newlines must be Falsezshell must be Truerbufsize must be 0text must be Falseencoding must be Noneerrors must be Nonezrun shell command %rT%s: %r) rr3rr%rrrrr%)rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr%)rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz+A callable object or None is expected, got )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrd t|}d }|| 7}n2|dkrd t|}d }|| 7}nt |}| |d |qnt j d ||ddS)aEDefault exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>rRrr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rG r)getr> __traceback__rrsortedr# traceback format_listrstriprr9rr) rfr rrRrZ log_linesryvaluetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)aDCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'task' (optional): Task instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrmrr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs|jr dS|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrr9rfrrrr _add_callbackszBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsd                  ;   DoPK!XFY  %__pycache__/exceptions.cpython-38.pycnu[U ifa@sldZdZGdddeZGdddeZGdddeZGdd d eZGd d d e Z Gd d d eZ dS)zasyncio exceptions.)CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__r r 7/opt/alt/python38/lib64/python3.8/asyncio/exceptions.pyr src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrr r r r r src@seZdZdZdS)rz+The operation is not allowed in this state.Nrr r r r rsrc@seZdZdZdS)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nrr r r r rsrcs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r r rr __classcell__r r rr rs rcs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) r __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r sPK!kނxx*__pycache__/staggered.cpython-38.opt-1.pycnu[U ifh @sdZdZddlZddlZddlmZddlmZddlmZddlm Z dd ej ej gej fej eejejejej eejej efd d d ZdS) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|z.run_one_coror) rZget_running_looprtypingOptionalrrrrrlenrr)r r rZ first_taskr Z done_countZdone_r#r!r$rs(=  0  r)__doc____all__r r%rrrrrIterableCallable Awaitabler&floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr#r#r#r$s&    PK!? (__pycache__/runners.cpython-38.opt-1.pycnu[U if@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr4/opt/alt/python38/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .PK!fmfm0__pycache__/selector_events.cpython-38.opt-2.pycnu[U ifT@s*dZddlZddlZddlZddlZddlZddlZddlZz ddlZWne k r`dZYnXddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd dZddZGddde jZGdddejejZGdddeZGdddeZdS))BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyrd?Z!d@dAZ"dBdCZ#dDdEZ$dFdGZ%dHdIZ&dJdKZ'dLdMZ(dNdOZ)dPdQZ*Z+S)VrNcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdSr}) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|Sr+)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||Sr+)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|Sr+)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||Sr+)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHSNrthe socket must be non-blocking)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHSr)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHSr)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)NrrAF_UNIX)familyprotoloop) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)NrrF)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN),r! __module__ __qualname__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s|        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)N/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progresssocket.send() raised exception.r%Fatal write error on socket transport)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs|jr dSz|j|j}Wnttfk r4Ynttfk rLYntk r}z>|j |j |j | |d|jdk r|j|W5d}~XYnnX|r|jd|=||js|j |j |jdk r|jd|jr|dn|jr|jtjdS)Nr)rrrOrrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs2       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrrrrrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsD            1oPK!,PP"__pycache__/streams.cpython-38.pycnu[U if h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS) aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr4/opt/alt/python38/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS) z@Similar to `open_connection` but works with UNIX Domain Sockets.NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs*|jr td|_|jr&td|dS)NTz%r pauses writing)r5AssertionErrorr4 get_debugrdebugr8rrr pause_writings  zFlowControlMixin.pause_writingcCsP|js td|_|jr&td||j}|dk rLd|_|sL|ddS)NFz%r resumes writing) r5r:r4r;rr<r6done set_resultr8waiterrrrresume_writings   zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r?r@ set_exceptionr8excrBrrrconnection_losts z FlowControlMixin.connection_lostcsP|jrtd|jsdS|j}|dks2|s2t|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6 cancelledr:r4 create_futurerArrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname____doc__r9r>rCrHrLrPrrrrr2s   r2csfeZdZdZdZdfdd ZeddZddZfd d Z d d Z d dZ ddZ ddZ ZS)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rK_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rXr=rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)r[rYr4Zcall_exception_handlerabortr]rc set_transportget_extra_infor_r^rr\r Z iscoroutineZ create_taskrZ)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) rcfeed_eofrEr`r?r@rUrHrXr\r])r8rGr'rarrrH s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)rc feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)rcrkr_)r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r`rNrrrrP+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r`r?rJ exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rQrRrSrTrYr9propertyrcrjrHrnrorPrr __classcell__rrrarrs   rc@sveZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdddZddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCsJ||_||_|dks"t|ts"t||_||_|j|_|j ddSr) r] _protocol isinstancerr:_readerr4rKZ _complete_futr@)r8r(rr'rrrrr9@s zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )rbrQr]rwappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSr)r]r=rrrr(PszStreamWriter.transportcCs|j|dSr)r]writer8rmrrrrTszStreamWriter.writecCs|j|dSr)r] writelinesrrrrrWszStreamWriter.writelinescCs |jSr)r] write_eofr=rrrrZszStreamWriter.write_eofcCs |jSr)r] can_write_eofr=rrrr]szStreamWriter.can_write_eofcCs |jSr)r]closer=rrrr`szStreamWriter.closecCs |jSr)r] is_closingr=rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rurPr=rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)r]rg)r8namedefaultrrrrgiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)rwrpr]rrrurL)r8rGrrrdrainls   zStreamWriter.drain)N)rQrRrSrTr9rrsr(rrrrrrrrgrrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionr]r5r;r extract_stacksys _getframerY)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=rxZpausedryrz) rr{lenrr_DEFAULT_LIMITrrr]r5r|r}r~rrrrs    zStreamReader.__repr__cCs|jSr)rr=rrrrpszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrJrErFrrrrEs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddS)z1Wakeup read*() functions waiting for data or EOF.N)rrJr@rArrr_wakeup_waiters zStreamReader._wakeup_waitercCs|jdkstd||_dS)NzTransport already set)r]r:)r8r(rrrrfszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrr]resume_readingr=rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrD)rrr=rrrrkszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rrr=rrrat_eofszStreamReader.at_eofcCs|jrtd|sdS|j|||jdk r~|js~t|jd|jkr~z|j Wnt k rvd|_YnXd|_dS)Nzfeed_data after feed_eofrT) rr:rextendrr]r5rrZ pause_readingrMrrrrrls   zStreamReader.feed_datacsf|jdk rt|d|jr&td|jr         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rrrr{r}rrrrr)r8nZblocksblockrmrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrr rrr)r8rZ incompletermrrrrs&       zStreamReader.readexactlycCs|Srrr=rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rQrRrSrYrr9rrprErrfrrkrrlrrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rVhasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkPPK!֬$__pycache__/log.cpython-38.opt-2.pycnu[U if|@sddlZeeZdS)N)ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python38/lib64/python3.8/asyncio/log.pysPK!J]J]0__pycache__/proactor_events.cpython-38.opt-1.pycnu[U if<}@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZddZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZ Gddde j!Z"dS) zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname____doc__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s   rcsTeZdZdZdfdd ZddZddZd d Zd d Zd dZ dddZ Z S)_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rfr(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rfrrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rfr$rr*rgre_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr||_dS|s |dSt|jtjrzt|j|Wqtt fk rZYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.) rfrerqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ data_received)r-rlrUrrrrjs"z)_ProactorReadPipeTransport._data_receivedc Cstd}zRzp|dk r2d|_|r*|}n||jrHd}WWdS|dkr\WWdS|jsv|jj |j d|_Wnt k r}z0|js| |dn|j rtjdddW5d}~XYntk r}z||W5d}~XYnftk r}z| |dW5d}~XYn8tjk r>|js:YnX|jsV|j|jW5|dk rn||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$rXresultrHr(rfr _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrg)r-futrlrUrrrrgs@     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_r`rrhrirmrqrjrgrcrrr3rrds rdcs^eZdZdZdZfddZddZddd Zd d Zd d Z ddZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportzTransport for write pipes.Tcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr% _loop_writingr#_maybe_pause_protocolextendrkrrrwriteKs,       z%_ProactorBaseWritePipeTransport.writeNc CsVz|dk r |jdkr |jr WdSd|_d|_|r8||dkrL|j}d|_|s|jrf|j|jd|jrz|j t j | nN|jj|j ||_|jst||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk r"}z||W5d}~XYn0tk rP}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rsr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrtsendrXr;ryrrrWrYrwrPrRrV)r-frlrUrrrrqs8    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerrrrrrrrrcrrr3rr{As & )r{cs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrtrur r$ry _pipe_closedr|r3rrrsz$_ProactorWritePipeTransport.__init__cCs@|r dS|jrdSd|_|jdk r4|tn|dSrB)Z cancelledr(r$r%rPBrokenPipeErrorrI)r-rzrrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrcrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rg)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rl_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQrrrrrr ValueErrorr'rrr rr#r9r%rr)r-rladdrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Cs z|jrWdSd|_|r ||jr2|jrN|jrN|jrH|j|jdWdS|j \}}|jdk r||jj |j ||_n|jj j |j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rsr#rr(rr*rGpopleftrtrr rrRr+error_received ExceptionrVryrr)r-rzrlrrUrrrrs2    z(_ProactorDatagramTransport._loop_writingc Cs4d}zz|jrWWdSd|_|dk rf|}|jrFd}WWdS|jdk r^||j}}n|\}}|jrvWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnJt k r}z|j|W5d}~XYn8tjk r|jsYnX|jdk r|j|jW5|r.|j||XdSrB)r+Zdatagram_receivedr'r$rsr(rrrtrur max_sizeZrecvfromrRrrrxryrg)r-rzrlrresrUrrrrgs>         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrgrcrrr3rrs   !rc@s eZdZdZddZddZdS)_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`rrrrrrrEsrcsBeZdZdZejjZd fdd ZddZ ddZ d d Z Z S) _ProactorSocketTransportz Transport for connected sockets.Ncs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_r`rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrcrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8rt _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rdrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_pipertrIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rtru)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)rtZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rtr)r-rrlrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)rtZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)rtacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrtsendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rhrirrrmZ sock_sendfiler )r-Ztransprrrrmrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rsrrtrurrrxrnrorprTry_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rsrr rSrrrrtrrRr:rTr rrIrrxrry)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHrt _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrcrrr3rrks\            +r)#r`__all__rrr rarrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrdZWriteTransportr{rrZ TransportrrZ BaseEventLooprrrrrsR           n  PK! //%__pycache__/transports.cpython-38.pycnu[U if(@s|dZdZGdddZGdddeZGdddeZGdd d eeZGd d d eZGd d d eZGdddeZdS)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sHeZdZdZdZdddZdddZdd Zd d Zd d Z ddZ dS)rzBase class for transports._extraNcCs|dkr i}||_dSNr)selfextrar 7/opt/alt/python38/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||S)z#Get optional transport information.)rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.NNotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdS)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r closeszBaseTransport.closecCstdS)zSet a new protocol.Nr)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdS)zReturn the current protocol.Nrrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__ __slots__rrrrrrr r r r r s   rc@s,eZdZdZdZddZddZddZd S) rz#Interface for read-only transports.r cCstdS)z*Return True if the transport is receiving.Nrrr r r is_reading3szReadTransport.is_readingcCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. Nrrr r r pause_reading7szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. Nrrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"r r r r r.s rc@sNeZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ dS)rz$Interface for write-only transports.r NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. Nrr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.Nrrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. Nr)r datar r r writefszWriteTransport.writecCsd|}||dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)joinr))r Z list_of_datar(r r r writelinesns zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. Nrrr r r write_eofwszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.Nrrr r r can_write_eofszWriteTransport.can_write_eofcCstdSzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r abortszWriteTransport.abort)NN) rrrrrr&r'r)r,r-r.r0r r r r rHs   rc@seZdZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r N)rrrrrr r r r rsrc@s&eZdZdZdZdddZddZdS) rz(Interface for datagram (UDP) transports.r NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. Nr)r r(Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr/rrr r r r0szDatagramTransport.abort)N)rrrrrr1r0r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdS)zGet subprocess id.Nrrr r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode Nrrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.Nr)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal Nr)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate Nrrr r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill Nrrr r r kills zSubprocessTransport.killN) rrrrr2r3r5r7r8r9r r r r rsrcsZeZdZdZdZdfdd ZddZdd Zd d Zdd d Z dddZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_waterNcs0t||dk st||_d|_|dS)NF)superrAssertionErrorr;r<_set_write_buffer_limits)r r Zloop __class__r r rs   z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r'r=r< _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr;call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrD) r<r'r>rFZresume_writingrGrHrIr;rJ)r rLr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r>r=rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr=r>r#r r r rA4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r$r%)rArMr#r r r r&Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrrMrNrOrAr&r' __classcell__r r rBr r:s  r:N) r__all__rrrrrrr:r r r r s%F6PK!E2!2!'__pycache__/trsock.cpython-38.opt-1.pycnu[U if@s"ddlZddlZGdddZdS)Nc@seZdZdZdZejdddZddZedd Z ed d Z ed d Z ddZ ddZ ddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(dHdIZ)dJdKZ*dLdMZ+dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d\S)]TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _sock)sockcCs ||_dSNr)selfrr3/opt/alt/python38/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rsb   r)rr rrrrr sPK!%i )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname____doc__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcseZdZdZddgZdfdd ZfddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ fddZddZZS)rz7Object returned by timed callback registration methods. _scheduled_whenNcs0t|||||jr |jd=||_d|_dS)Nr*F)superr(rrLrK)r!whenr"r#r$r%r,r&r'r(hs zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rMr2rinsertrL)r!r0posrOr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrLr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rLr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rL__eq__rVr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rUrVr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rYrVr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrLrrrNotImplementedrVr&r&r'rZs     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)rZr_)r!rWZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrMr:r9rOr&r'r:s zTimerHandle.cancelcCs|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). rUr9r&r&r'rNszTimerHandle.when)N)r-rGrHrIrJr(r2rTrXr[r\r]rZr`r:rN __classcell__r&r&rOr'rcs  rc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rz,Abstract server returned by create_server().cCstdS)z5Stop serving. This leaves existing connections open.NNotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdS)z4Get the event loop the Server object is attached to.Nrcr9r&r&r'get_loopszAbstractServer.get_loopcCstdS)z3Return True if the server is accepting connections.Nrcr9r&r&r' is_servingszAbstractServer.is_servingcstdS)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. Nrcr9r&r&r' start_servingszAbstractServer.start_servingcstdS)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. Nrcr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdS)z*Coroutine to wait until service is closed.Nrcr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rerj)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrIrerfrgrhrirjrkrlr&r&r&r'rsrc @sVeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddddZd d!Zd"d#Zd$d%Zd&d&d&d&d'd(d)Zdud*d+Zdvdd&d&d&ddddddd, d-d.Zdwejejdd/ddddd0d1 d2d3Zdxd0d4d5d6Zd7ddd8d9d:Zdyddddd;dd?d@Zd{d&d&d&dddddAdBdCZ dDdEZ!dFdGZ"e#j$e#j$e#j$dHdIdJZ%e#j$e#j$e#j$dHdKdLZ&dMdNZ'dOdPZ(dQdRZ)dSdTZ*dUdVZ+dWdXZ,dYdZZ-d[d\Z.d]d^Z/d|dd4d_d`Z0dadbZ1dcddZ2dedfZ3dgdhZ4didjZ5dkdlZ6dmdnZ7dodpZ8dqdrZ9dsdtZ:dS)}rzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.Nrcr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. Nrc)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. Nrcr9r&r&r'stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.Nrcr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.Nrcr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. Nrcr9r&r&r'res zAbstractEventLoop.closecstdS)z,Shutdown all active asynchronous generators.Nrcr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.Nrc)r!r=r&r&r'rasz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rc)r!Zdelayr"r#r&r&r'rsszAbstractEventLoop.call_latercGstdSr;rc)r!rNr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rcr9r&r&r'time szAbstractEventLoop.timecCstdSr;rcr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rc)r!cororyr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rcrtr&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rc)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rc)r!r}r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rc)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rc)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rc)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrrhc stdS)adA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrc) r!rrrrrrrrrrrrhr&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdS)zRSend a file through a transport. Return an amount of sent bytes. Nrc)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdS)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. Nrc)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rc)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrrhcstdS)aA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrc)r!rrrrrrrhr&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. Nrc) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.Nrcr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.Nrcrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rc)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rc)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rcr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rcr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rcrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rcrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rc)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rc)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rc)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rc)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rc)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rc)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rc)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rc)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rc)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rcr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rcr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rc)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rcr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rcrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rcr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rc)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrmrnrorprqrerrrarursrvrwrxr{r|rrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.Nrcr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.Nrcr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.Nrcr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.Nrcr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.Nrc)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN) r-rGrHrIrr r r r r&r&r&r'r<s  rc@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nz,There is no current event loop in thread %r.) rrrr^ threadingZcurrent_threadZ _MainThreadr r RuntimeErrorryr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)rrrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrIrrlocalrr(rr r r&r&r&r'r^s rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr&r&r&r'rsrcCs|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r)Zpolicyr&r&r'rsrcCst}|dk r|StS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr&r&r'rs rcCst|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rr&r&r'r sr cCs tS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r&r&r&r'r sr cCs tS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r&r&r&r'r sr cCs t|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr&r&r'r sr )rr rr),rI__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sX   J@*q"9    PK!r\%__pycache__/subprocess.cpython-38.pycnu[U if@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsXeZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__7/opt/alt/python38/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname____doc__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrBr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrGszProcess.send_signalcCs|jdSr:)r terminater7rrrrIszProcess.terminatecCs|jdSr:)rkillr7rrrrJsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrMr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|dks(t|j}|jrV|dkrDdnd}td||| IdH}|jr|dkrzdnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rAssertionErrorrrrKr rMreadr1)rr.r,r;nameoutputrrr _read_streams    zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rQrRrrWrrZgatherrrF)rrPrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrErFrGrIrJrQrRrWrXrrrrrAts  rAc sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellrA) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrZr&r[cs tdSr]r^rr%rrr_sz(create_subprocess_exec..r`)rrarbrcrdZsubprocess_execrA) Zprogramrrrr rargsrfrgr,r'rr%rrs( r)__all__ subprocessrbrrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr rAZ_DEFAULT_LIMITrrrrrrs.     bV PK!^1__pycache__/log.cpython-38.pycnu[U if|@sdZddlZeeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python38/lib64/python3.8/asyncio/log.pysPK! ##*__pycache__/staggered.cpython-38.opt-2.pycnu[U ifh @sdZddlZddlZddlmZddlmZddlmZddlmZddej ej gej fej e ejejejej eejej efd d d ZdS) )staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|z.run_one_coror) rZget_running_looprtypingOptionalrrrrrlenrr)r r rZ first_taskr Z done_countZdone_r#r!r$rs(=  0  r)__all__r r%rrrrrIterableCallable Awaitabler&floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr#r#r#r$s$    PK!VwF+__pycache__/exceptions.cpython-38.opt-2.pycnu[U ifa@shdZGdddeZGdddeZGdddeZGdddeZGd d d eZ Gd d d eZ d S))CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@s eZdZdS)rN__name__ __module__ __qualname__r r 7/opt/alt/python38/lib64/python3.8/asyncio/exceptions.pyr src@s eZdZdS)rNrr r r r r src@s eZdZdS)rNrr r r r rsrc@s eZdZdS)rNrr r r r rsrcs$eZdZfddZddZZS)rcs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r rr __classcell__r r rr rs rcs$eZdZfddZddZZS)rcst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r s PK!EX>f[[0__pycache__/proactor_events.cpython-38.opt-2.pycnu[U if<}@sPdZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZd dZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZGddde j Z!dS))BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s  rcsPeZdZdfdd ZddZddZdd Zd d Zd d ZdddZ Z S)_ProactorReadPipeTransportNcs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rer(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rerrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rer$rr*rfrd_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr||_dS|s |dSt|jtjrzt|j|Wqtt fk rZYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.) rerdrprQr+rZBufferedProtocolZ_feed_data_to_buffered_protormrnrorVZ data_received)r-rkrUrrrris"z)_ProactorReadPipeTransport._data_receivedc Cstd}zRzp|dk r2d|_|r*|}n||jrHd}WWdS|dkr\WWdS|jsv|jj |j d|_Wnt k r}z0|js| |dn|j rtjdddW5d}~XYntk r}z||W5d}~XYnftk r}z| |dW5d}~XYn8tjk r>|js:YnX|jsV|j|jW5|dk rn||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rir$rXresultrHr(rer _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrf)r-futrkrUrrrrfs@     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_rrgrhrlrprirfrbrrr3rrcs rccsZeZdZdZfddZddZdddZd d Zd d Zd dZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportTcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rk)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr% _loop_writingr#_maybe_pause_protocolextendrjrrrwriteKs,       z%_ProactorBaseWritePipeTransport.writeNc CsVz|dk r |jdkr |jr WdSd|_d|_|r8||dkrL|j}d|_|s|jrf|j|jd|jrz|j t j | nN|jj|j ||_|jst||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk r"}z||W5d}~XYn0tk rP}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rrr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrssendrXr;rxrrrWrYrvrPrRrV)r-frkrUrrrrqs8    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN) r8r^r_Z_start_tls_compatiblerrrrrrrrrbrrr3rrzAs & )rzcs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrsrtr r$rx _pipe_closedr{r3rrrsz$_ProactorWritePipeTransport.__init__cCs@|r dS|jrdSd|_|jdk r4|tn|dSrB)Z cancelledr(r$r%rPBrokenPipeErrorrI)r-ryrrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrbrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rf)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rk_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQr~rrrrr ValueErrorr'rrr rr#r9r%rr)r-rkaddrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Cs z|jrWdSd|_|r ||jr2|jrN|jrN|jrH|j|jdWdS|j \}}|jdk r||jj |j ||_n|jj j |j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rrr#rr(rr*rGpopleftrsrr rrRr+error_received ExceptionrVrxrr)r-ryrkrrUrrrrs2    z(_ProactorDatagramTransport._loop_writingc Cs4d}zz|jrWWdSd|_|dk rf|}|jrFd}WWdS|jdk r^||j}}n|\}}|jrvWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnJt k r}z|j|W5d}~XYn8tjk r|jsYnX|jdk r|j|jW5|r.|j||XdSrB)r+Zdatagram_receivedr'r$rrr(rrrsrtr max_sizeZrecvfromrRrrrwrxrf)r-ryrkrresrUrrrrfs>         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrfrbrrr3rrs   !rc@seZdZddZddZdS)_ProactorDuplexPipeTransportcCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_rrrrrrrEsrcs>eZdZejjZd fdd ZddZddZ dd Z Z S) _ProactorSocketTransportNcs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrbrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8rs _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rcrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_pipersrIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rsrt)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)rsZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rsr)r-rrkrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)rsZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)rsacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrssendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rgrhrrrlZ sock_sendfiler )r-Ztransprrrrlrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rrrrsrtrrrwrmrnrorTrx_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rrrr rSrrrrsrrRr:rTr rrIrrwrrx)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHrs _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrbrrr3rrks\            +r)"__all__rrr r`rrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrcZWriteTransportrzrrZ TransportrrZ BaseEventLooprrrrrsP           n  PK!/v//+__pycache__/transports.cpython-38.opt-1.pycnu[U if(@s|dZdZGdddZGdddeZGdddeZGdd d eeZGd d d eZGd d d eZGdddeZdS)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sHeZdZdZdZdddZdddZdd Zd d Zd d Z ddZ dS)rzBase class for transports._extraNcCs|dkr i}||_dSNr)selfextrar 7/opt/alt/python38/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||S)z#Get optional transport information.)rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.NNotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdS)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r closeszBaseTransport.closecCstdS)zSet a new protocol.Nr)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdS)zReturn the current protocol.Nrrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__ __slots__rrrrrrr r r r r s   rc@s,eZdZdZdZddZddZddZd S) rz#Interface for read-only transports.r cCstdS)z*Return True if the transport is receiving.Nrrr r r is_reading3szReadTransport.is_readingcCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. Nrrr r r pause_reading7szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. Nrrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"r r r r r.s rc@sNeZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ dS)rz$Interface for write-only transports.r NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. Nrr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.Nrrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. Nr)r datar r r writefszWriteTransport.writecCsd|}||dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)joinr))r Z list_of_datar(r r r writelinesns zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. Nrrr r r write_eofwszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.Nrrr r r can_write_eofszWriteTransport.can_write_eofcCstdSzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r abortszWriteTransport.abort)NN) rrrrrr&r'r)r,r-r.r0r r r r rHs   rc@seZdZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r N)rrrrrr r r r rsrc@s&eZdZdZdZdddZddZdS) rz(Interface for datagram (UDP) transports.r NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. Nr)r r(Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr/rrr r r r0szDatagramTransport.abort)N)rrrrrr1r0r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdS)zGet subprocess id.Nrrr r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode Nrrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.Nr)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal Nr)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate Nrrr r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill Nrrr r r kills zSubprocessTransport.killN) rrrrr2r3r5r7r8r9r r r r rsrcsZeZdZdZdZdfdd ZddZdd Zd d Zdd d Z dddZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_waterNcs$t|||_d|_|dS)NF)superrr;r<_set_write_buffer_limits)r r Zloop __class__r r rs z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r'r=r< _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr;call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrC) r<r'r>rEZresume_writingrFrGrHr;rI)r rKr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r>r=rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr=r>r#r r r r@4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r$r%)r@rLr#r r r r&Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrrLrMrNr@r&r' __classcell__r r rAr r:s  r:N) r__all__rrrrrrr:r r r r s%F6PK!r ss0__pycache__/selector_events.cpython-38.opt-1.pycnu[U ifT@s.dZdZddlZddlZddlZddlZddlZddlZddlZz ddl Z Wne k rddZ YnXddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddZddZGddde jZGdddejejZGdddeZGdddeZdS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. )BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyrZ!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+Z,S)WrzJSelector event loop. See events.EventLoop for API specification. NcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdS)Remove a writer callback.FNT) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|S)zAdd a reader callback.)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||S)zRemove a reader callback.)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|S)zAdd a writer callback..)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||S)r)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. rthe socket must be non-blockingN)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rrN)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHS)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. rrN)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)zTConnect to a remote socket at address. This method is a coroutine. rrAF_UNIX)familyprotoloopN) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)aWAccept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. rrFN)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r! __module__ __qualname____doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s~        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)N/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progresssocket.send() raised exception.r%Fatal write error on socket transport)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs|jr dSz|j|j}Wnttfk r4Ynttfk rLYntk r}z>|j |j |j | |d|jdk r|j|W5d}~XYnnX|r|jd|=||js|j |j |jdk r|jd|jr|dn|jr|jtjdS)Nr)rrrOrrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs2       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrrr rrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)r__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsF            1oPK!d5yy-__pycache__/base_futures.cpython-38.opt-1.pycnu[U if @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r)objrr9/opt/alt/python38/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) #helper function for Future.__repr__cSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d |S) r Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r&)__all__r _threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr&rrrr s   PK!مTT$__pycache__/constants.cpython-38.pycnu[U ifx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r 6/opt/alt/python38/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s PK!^1$__pycache__/log.cpython-38.opt-1.pycnu[U if|@sdZddlZeeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python38/lib64/python3.8/asyncio/log.pysPK!cndd,__pycache__/base_events.cpython-38.opt-2.pycnu[U if@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlm Z dZ!dZ"dZ#e$edZ%dZ&e'Z(ddZ)ddZ*ddZ+d*ddZ,d+ddZ-ddZ.e$ed rd!d"Z/nd#d"Z/Gd$d%d%ej0Z1Gd&d'd'ej2Z3Gd(d)d)ej4Z5dS),N) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr8/opt/alt/python38/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETr"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)Nrrcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs|jd7_dSrZ)rrqrrr_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|dS)Nrr)rr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdSNT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)Nr)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)Nz'task factory must be a callable or None)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jSrB)rrqrrrget_task_factoryszBaseEventLoop.get_task_factory)extraservercCstdSrBNotImplementedError)rfr*protocolrrrrrr_make_socket_transportsz$BaseEventLoop._make_socket_transportFT) server_sideserver_hostnamerrrcall_connection_madec CstdSrBr) rfZrawsockr sslcontextrrrrrrrrrr_make_ssl_transportsz!BaseEventLoop._make_ssl_transportcCstdSrBr)rfr*raddressrrrrr_make_datagram_transportsz&BaseEventLoop._make_datagram_transportcCstdSrBrrfpiperrrrrr_make_read_pipe_transportsz'BaseEventLoop._make_read_pipe_transportcCstdSrBrrrrr_make_write_pipe_transportsz(BaseEventLoop._make_write_pipe_transportc stdSrBr) rfrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportsz(BaseEventLoop._make_subprocess_transportcCstdSrBrrqrrr_write_to_selfszBaseEventLoop._write_to_selfcCstdSrBr)rf event_listrrr_process_eventsszBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rrmrqrrrrszBaseEventLoop._check_closedcCs*|j||s&||j|dSrB)rdiscardrcall_soon_threadsaferacloserfagenrrr_asyncgen_finalizer_hooks z&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|dt|d|j|dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() callsource)rwarningswarnResourceWarningraddrrrr_asyncgen_firstiter_hooks z&BaseEventLoop._asyncgen_firstiter_hookcsd|_t|jsdSt|j}|jtjdd|Dd|dIdH}t||D]*\}}t|t rT| d|||dqTdS)NTcSsg|] }|qSr)r)rCZagrrr sz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)N) firstiter finalizerF)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|S)N call_soonr)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rZHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)Nrr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrr rr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r'c s2|jr|j}ntj}|d|||||||IdHSrB)rr,r$r%r)rfr;r<r=r>r?r'Z getaddr_funcrrrr%2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr'rrrr.<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr/rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr2rfr*r4r5r6rrrr1Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r:minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r4r5r6 blocksizebuf total_sentviewreadrrrr3Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)Nbmodez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r})) rr%r>r$r1rr4r5formatr9rrrr0os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr(rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r'r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfdd |D| d IdH\}}}|dkr d d Dt dkrd nJt d t fdd Dr҈d td d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r'r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrQ)rCr*)r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r#css|]}t|VqdSrBr^r_rrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrQr Zstaggered_racerrallrFr$r>_create_connection_transportrget_extra_inforr )rfrr;r<rRr=r?r'r*rSrrrTrUinfosr*rPrnrr)rr\r`rfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rIrdrboolrrr) rfr*rrRrrrrrrrnrrrrd%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)NzTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr2_sendfile_fallback)rfrnr4r5r6r/rErWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr8)rfrgr4r5r6rrrrjnszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr:) r:r;r<r\r#r{r=rr>rkwrite) rfrgr4r5r6r?r@rAr?rBrCrrrrkrs* z BaseEventLoop._sendfile_fallbackrhc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS)Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rRrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r' reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| dd} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st d qڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk r|j||tj|||dIdH}|std|D]:\}}}}}||f}||krddg||<||||<qqfdd|D}|sHtdg}|tk rv|rftdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tjtjd| dr| |r| s| | |IdH|} Wn^tk rJ}z | dk r0| !|"|W5d}~XYn&| dk rb| !YnXq|qz|d |}|#}|$| || |}|j%r̈rt&d||nt'd||z|IdHWn|!YnX||fS)NzA UDP Socket was expected, got )rS remote_addrr=r?r'rprqrrr#css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrrXrYcs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrSrsrrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r) stacklevelrGz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%dictr$itemsrIr#rxrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorrb_unsetrrr r+r&r'Z SO_BROADCASTrJrOrr9rdrrr&r ) rfrrSrsr=r?r'rprqrrr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxrfZfamrPZprorrzrZ local_addressZremote_addressrWrrrnrr{rcreate_datagram_endpoints$                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nrr-)rAr%) rfrr=r>r?r'rr;r<r&rrrrbLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r'rz getaddrinfo(z) returned empty list)rbr$r1r()rfr;r<r=r'rfrrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r'r*rrRrprqrrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd|D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d d YqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)Nz*ssl argument must be an SSLContext or NonerVrWposixcygwinr.csg|]}j|dqS))r=r')r)rCr;r=r'r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrarrz %r is serving).rrir5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrJr(rMrKrLr>r1rIrrrr&)rfrr;r<r=r'r*rrRrprqrrrZhostsZfsrfZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rRrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS)NrarVr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rdrrerr )rfrr*rRrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrr filenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrr rrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrr r$)rfr(rrrr&rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) Nzcmd must be a string universal_newlines must be Falsezshell must be Truerbufsize must be 0text must be Falseencoding must be Noneerrors must be Nonezrun shell command %rT%s: %r) rr3rr%rrrrr&)rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr&)rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jSrB)rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)Nz+A callable object or None is expected, got )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrdt|}d }|| 7}n2|dkrdt|}d }|| 7}nt |}| |d |qnt j d ||d dS)Nrz!Unhandled exception in event looprRFZsource_tracebackZhandle_traceback>rRrr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rH r)getr> __traceback__rrsortedr$ traceback format_listrstriprr9rr) rfr rrRrZ log_linesrzvaluetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)Nz&Exception in default exception handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrnrr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs|jr dS|j|dSrB) _cancelledrr9rfrrrr _add_callbackszBaseEventLoop._add_callbackcCs|||dSrB)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dSrZ)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsb                  ;   DoPK!_P+__pycache__/base_tasks.cpython-38.opt-2.pycnu[U if @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror 7/opt/alt/python38/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #PK!mmtt*__pycache__/selector_events.cpython-38.pycnu[U ifT@s.dZdZddlZddlZddlZddlZddlZddlZddlZz ddl Z Wne k rddZ YnXddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddZddZGddde jZGdddejejZGdddeZGdddeZdS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. )BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyrZ!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+Z,S)WrzJSelector event loop. See events.EventLoop for API specification. NcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdS)Remove a writer callback.FNT) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|S)zAdd a reader callback.)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||S)zRemove a reader callback.)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|S)zAdd a writer callback..)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||S)r)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. rthe socket must be non-blockingN)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rrN)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHS)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. rrN)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)zTConnect to a remote socket at address. This method is a coroutine. rrAF_UNIX)familyprotoloopN) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)aWAccept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. rrFN)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r! __module__ __qualname____doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s~        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)N/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progresssocket.send() raised exception.r%Fatal write error on socket transport)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs(|jstd|jrdSz|j|j}Wnttfk rBYnttfk rZYnt k r}z>|j |j |j ||d|jdk r|j|W5d}~XYnpX|r|jd|=||js$|j |j |jdk r|jd|jr|dn|jr$|jtjdS)NzData should not be emptyr)rAssertionErrorrrrOrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs4       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrr r rrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)r__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsF            1oPK!M!`!`)__pycache__/windows_events.cpython-38.pycnu[U if@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd ZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZ Gddde!Z"Gdddej#Z$Gdd d ej%Z&Gd!d"d"Z'Gd#d$d$e j(Z)e$Z*Gd%d&d&e j+Z,Gd'd(d(e j+Z-e-Z.dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__;/opt/alt/python38/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rr%r6r0r9r; __classcell__r r rr!r+s   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrDZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrDrKrEr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rFrE _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rOrrHr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rUrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rUrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rUrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s   rCcsFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrcstj||||dd|_dS)Nr)rr_done_callback)rreventrHrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rWr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rWr:rr r!r9s  z_WaitCancelFuture.set_exception) r>r?r@rArr0r;r9rBr r rr!rVs  rVcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrQZ CreateEvent_event _event_fut)rrrGrHproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r\rJ CloseHandler]r[ _unregisterrrrOrMrr r!rOs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[ _wait_cancelrOr]rTr r r!rUs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZs rZc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|S)NF)rhrj)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlergadd)rfirstflagshpiper r r!rjs(     zPipeServer._server_pipe_handlecCs |jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rir0rdrgcloserhclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rArrlrjrmru__del__r r r r!rbs  rbc@seZdZdZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd fdd ZfddZddZd d Zdd d ZZ S)r z2Windows version of proactor event loop using IOCP.Ncs|dkrt}t|dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c slz(|jdkst||jt W5|jdk rf|jj}|j|dk r`|js`|j|d|_XdSr7) Z_self_reading_futurerr0r"r[r`AssertionError call_soonZ_loop_self_readingr run_foreverrrrr r!r{8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)r[ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr}r~rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rgdiscardrmrurrlr[ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorriadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rbrz)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizerkwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rArr{rrrrBr r rr!r 0s 0r c@seZdZdZd;ddZddZddZd d ZdddZ d?ddZ d@ddZ dAddZddZddZdd Zd!d"Zd#d$ZdBd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2ZdCd3d4Zd5d6Zd7d8Zd9d:Zd S)Drz#Proactor implementation using IOCP.rcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrI) r2_resultsrQCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cachererfrF _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrYr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrLrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrK)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerNr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprQ Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrQrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrQrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrQrrnZ WSASendTorr)rrrrrr}rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrQrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrQrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrI)rrrrrQZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrQZ WSAConnectrr2rr;rZ BindLocalrr1rRerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rNerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrQrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrQrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrQZ ConnectPiper1rRZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrGr4r r r!rs  zIocpProactor.connect_pipecCs|||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rrGrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Src)rrW)rrXZ done_callbackrNr r r!raszIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rKrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrJINFINITEmathceilrQrrnZRegisterWaitWithQueuerr'rVr2rZrr)rrGrZ _is_cancelmsrrHrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrI)rFrprQrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrrLr|r r r!r`szIocpProactor._unregistercCst|}|d|SrI)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrQZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrJr_rr0Zdoner1r9rrLr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rKsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrVr0r1r2rr3time monotonicr debugrKrrJr_) rr'rNrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArrrrrrrrrrrrrrrrrrarrrr`rrKrrurwr r r r!rs8        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2r[rintrDr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr)/rArQrJrrrrrrrerrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrCrVrZobjectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sR         0J4;e`PK!-+__pycache__/transports.cpython-38.opt-2.pycnu[U if(@sxdZGdddZGdddeZGdddeZGdddeeZGd d d eZGd d d eZGd ddeZdS)) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)r_extraNcCs|dkr i}||_dSNr)selfextrar 7/opt/alt/python38/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||Sr )rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdSr NotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdSr rrr r r closeszBaseTransport.closecCstdSr r)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdSr rrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname__ __slots__rrrrrrr r r r r s   rc@s(eZdZdZddZddZddZdS) rr cCstdSr rrr r r is_reading3szReadTransport.is_readingcCstdSr rrr r r pause_reading7szReadTransport.pause_readingcCstdSr rrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r r r r r.src@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rr NcCstdSr rr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdSr rrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdSr r)r datar r r writefszWriteTransport.writecCsd|}||dS)N)joinr()r Z list_of_datar'r r r writelinesns zWriteTransport.writelinescCstdSr rrr r r write_eofwszWriteTransport.write_eofcCstdSr rrr r r can_write_eofszWriteTransport.can_write_eofcCstdSr rrr r r abortszWriteTransport.abort)NN) rrrrr%r&r(r+r,r-r.r r r r rHs   rc@seZdZdZdS)rr N)rrrrr r r r rsrc@s"eZdZdZdddZddZdS)rr NcCstdSr r)r r'Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr rrr r r r.szDatagramTransport.abort)N)rrrrr/r.r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdSr rrr r r get_pidszSubprocessTransport.get_pidcCstdSr rrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdSr r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdSr r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdSr rrr r r terminates zSubprocessTransport.terminatecCstdSr rrr r r kills zSubprocessTransport.killN) rrrrr0r1r3r5r6r7r r r r rsrcsVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixin)_loop_protocol_paused _high_water _low_waterNcs$t|||_d|_|dS)NF)superrr9r:_set_write_buffer_limits)r r Zloop __class__r r rs z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r&r;r: _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr9call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrA) r:r&r<rCZresume_writingrDrErFr9rG)r rIr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r<r;rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr;r<r"r r r r>4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r#r$)r>rJr"r r r r%Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r&Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrJrKrLr>r%r& __classcell__r r r?r r8s  r8N)__all__rrrrrrr8r r r r s%F6PK!Zy y #__pycache__/__main__.cpython-38.pycnu[U if3 @sXddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrTed eZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez e Wn8e!k rJtr@t"s@t#d aYqYnXqTqdS)N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__5/opt/alt/python38/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__zcpython.run_stdinasyncio>r$__file__ __package__ __builtins__ __loader____spec__FT)$r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$auditZnew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsH 6       PK!2 2 '__pycache__/trsock.cpython-38.opt-2.pycnu[U if@s"ddlZddlZGdddZdS)Nc@seZdZdZejdddZddZeddZed d Z ed d Z d dZ ddZ ddZ ddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Z d9d:Z!d;d<Z"d=d>Z#d?d@Z$dAdBZ%dCdDZ&dEdFZ'dGdHZ(dIdJZ)dKdLZ*dMdNZ+dOdPZ,dQdRZ-dSdTZ.dUdVZ/dWdXZ0dYdZZ1d[S)\TransportSocket_sock)sockcCs ||_dSNr)selfrr3/opt/alt/python38/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rs`    r)rr rrrrr sPK!f Vq(__pycache__/windows_utils.cpython-38.pycnu[U if@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr:/opt/alt/python38/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname____doc__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drt|dddks"td}}}d} } } |tkrbtddd\} } t| tj}n|}|tkrtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz t j |f|||d |Wn0| | | fD]}|dk rt |qYn>X| dk r,t| |_| dk r@t| |_| dk rTt| |_W5|tkrlt ||tkrt ||tkrt |XdS) NZuniversal_newlinesrr)FTT)rr)TFr )stdinstdoutstderr)getAssertionErrorrrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr7r8r9)rargsr7r8r9kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsR              zPopen.__init__)NNN)r#r1r2r3r __classcell__rrrCrr}sr)r3sysplatform ImportErrorr itertoolsr<r subprocessr r5__all__ZBUFSIZErr>countrrrrrrrrs$ 1,PK!b5?? __pycache__/locks.cpython-38.pycnu[U if|C@sdZdZddlZddlZddlZddlmZddlmZddlmZddlm Z Gd d d Z Gd d d Z Gd dde Z GdddZ Gddde ZGddde ZGdddeZdS)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s(eZdZdZddZddZddZdS) _ContextManagera\Context manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: Deprecated, use 'async with' statement: async with lock: cCs ||_dSN)_lock)selflockr2/opt/alt/python38/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r&r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%!_ContextManagerMixin__acquire_ctx __await__rrrrr)Ys z_ContextManagerMixin.__await__cs|IdHdSr )r&rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner'r Z _is_coroutiner(r)r*r.rrrrr1s rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... NloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)_waiters_lockedrget_event_loop_loopr#r$r%rr2rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r6r5lenrresZextra __class__rrrBs  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r6r5all collectionsdequer8 create_futureappendremover CancelledError_wake_up_firstrfutrrrr&s&    z Lock.acquirecCs"|jrd|_|ntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r6rSrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddS)z*Wake up the first waiter if it isn't done.NT)r5nextiter StopIterationdone set_resultrTrrrrSszLock._wake_up_first) rrrrrrBr;r&rrS __classcell__rrrFrrjs5  rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. Nr1cCs>t|_d|_|dkr$t|_n||_tjdt dddSr3) rMrNr5_valuerr7r8r#r$r%r9rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrB s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)r\r5rYrZrTrrrr]s  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)r\r8rOr5rPrQrTrrrwait(s   z Event.wait) rrrrrrBr_r]r`rar[rrrFrrs  rcsReZdZdZdddddZfddZdd Zd d Zdd dZddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr1cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r ValueErrorrr;r&rrMrNr5)rrr2rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr:)rArBr;r5rCrDrFrrrB[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockFNT) r;rrr&r rRr8rOr5rPrQ)rrHrUrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)rnidxrUrrrnotifys  zCondition.notifycCs|t|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rgrCr5rrrr notify_allszCondition.notify_all)N)r) rrrrrrBrardrgrhr[rrrFrr;s  % rcsPeZdZdZdddddZfddZd d Zd d Zd dZddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rNr1cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r4r r!) rbr\rMrNr5rr7r8r#r$r%rvaluer2rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrBs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r5popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&s    zSemaphore.acquirecCs|jd7_|dS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)r\rlrrrrrszSemaphore.release)r) rrrrrrBrlr;r&rr[rrrFrrs rcs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rNr1cs.|rtjdtdd||_tj||ddS)Nr4r r!r1)r#r$r% _bound_valuerArrirFrrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrs zBoundedSemaphore.release)r)rrrrrrr[rrrFrrs r)r__all__rMr/r#rr r r r rrrrrrrrrrs     "9DzNPK!.__pycache__/windows_utils.cpython-38.opt-2.pycnu[U if@sddlZejdkredddlZddlZddlZddlZddlZddlZddl Z dZ dZ ej Z ej Z eZdde dd d ZGd d d ZGd ddejZdS)NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)Nz\\.\pipe\python-pipe-{:d}-{:d}-)prefixrTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr:/opt/alt/python38/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@s^eZdZddZddZeddZddZej d d d Z e j fd d Z ddZddZdS)rcCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcseZdZdfdd ZZS)rNc sxd}}}d} } } |tkr@tddd\} } t| tj}n|}|tkrhtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d|Wn0| | | fD]}|dk rt |qւYn>X| dk r t | |_ | dk rt | |_| dk r2t | |_W5|tkrJt||tkr^t||tkrrt|XdS)N)FTT)rr)TFr r)stdinstdoutstderr)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr6r7r8)rargsr6r7r8kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsN              zPopen.__init__)NNN)r#r1r2r __classcell__rrr@rr}sr)sysplatform ImportErrorr itertoolsr9r subprocessr r4__all__ZBUFSIZErr;countrrrrrrrrs" 1,PK!~(__pycache__/runners.cpython-38.opt-2.pycnu[U if@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr4/opt/alt/python38/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .PK!)__pycache__/__init__.cpython-38.opt-1.pycnu[U if@sdZddlZddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddl mZejejejejejejeje je je je je jejZejdkrddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N)*)_all_tasks_compatZwin32)__doc__sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r 5/opt/alt/python38/lib64/python3.8/asyncio/__init__.pysZ       PK!6l[P++"__pycache__/futures.cpython-38.pycnu[U ifb3@sdZdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ej Z ej Z ejZejZejdZGd d d ZeZd d Zd dZddZddZddZddZddddZz ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZd d Zed d Zejd d ZddZddZddZddZddZddZddZddddZdd Zd!d"Zd#d$Zd%d&Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r/r1rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r/r1rr:r;r<r#r$rrrrr!s    zFuture.exceptionr4cCsB|jtkr|jj|||dn |dkr.t}|j||fdS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. r4N)r/r0r r5 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs g|]\}}|kr||fqSrr).0fr7rArr sz/Future.remove_done_callback..N)rlen)rrAZfiltered_callbacksZ removed_countrrErremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r/r0rr<r=r;r2)rr>rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN) r/r0rr< isinstancetype StopIteration TypeErrorr$r;r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r9_asyncio_future_blockingr-r>rrrr __await__s zFuture.__await__)"r __module__ __qualname____doc__r0r/r=r$r rrPr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r8r9r>r!rBrHrJrOrQ__iter__rrrrrs:    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rL concurrentfuturesr:rargs TimeoutErrorr<)r%Z exc_classrrr_convert_future_exc#s      r`cCs^|s t|r||s(dS|}|dk rH|t|n|}| |dS)z8Copy state from a future to a concurrent.futures.Future.N) r9AssertionErrorr8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\sourcer!r>rrr_set_concurrent_future_state/s rccCsl|s t|rdS|r$t|r6|n2|}|dk rV|t|n|}||dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N) r9rar8r3r!rOr`r>rJ)rbdestr!r>rrr_copy_future_state>s   recststtjjstdts._set_statecs2|r.dkskr"n jdSr()r8r3call_soon_threadsafe) destination) dest_looprb source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r8Z is_closedrh)rb)rgrjrirkrr_call_set_stateos z&_chain_future.._call_set_state)rrKr\r]rrNrZrB)rbrirlrmr)rgrjrirbrkr _chain_futureRs   rnr cCsNt|r |St|tjjs(td||dkr8t}|}t |||S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got N) rrKr\r]rrarr Z create_futurern)r"r Z new_futurerrrr|s r)rT__all__Zconcurrent.futuresr\r?Zloggingrrrrr rr0r1r;DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rcrernrZ_asyncio ImportErrorZ_CFuturerrrrs:     q  *  PK!EK{{-__pycache__/base_futures.cpython-38.opt-2.pycnu[U if @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)N_asyncio_future_blocking)hasattr __class__r)objrr9/opt/alt/python38/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) NcSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d|S) Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r%)__all__r_threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr%rrrr s   PK!ոlUU'__pycache__/queues.cpython-38.opt-2.pycnu[U if @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@s eZdZdS)rN__name__ __module__ __qualname__rr3/opt/alt/python38/lib64/python3.8/asyncio/queues.pyr src@s eZdZdS)rNr rrrrrsrc@seZdZd(ddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ e ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'ZdS))rrNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer!r"rrrr 6sz Queue._initcCs |jSr$)r%popleftr!rrr_get9sz Queue._getcCs|j|dSr$r%appendr!itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr$)r'ZdoneZ set_result)r!waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr(rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr1r2r3)r4r r6r(rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r%z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr%rlenrr)r!resultrrrr6Os  z Queue._formatcCs t|jSr$)r<r%r(rrrqsize[sz Queue.qsizecCs|jSr$)rr(rrrr"_sz Queue.maxsizecCs|j Sr$r%r(rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)NrF)rr>r(rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |Sr$) rAr create_futurerr+cancelremove ValueError cancelledr0 put_nowait)r!r-Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)Nr)rArr.rrclearr0rr,rrrrGs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| Sr$) r@rrBrr+rCrDrErFr0 get_nowait)r!getterrrrgets    z Queue.getcCs$|r t|}||j|Sr$)r@rr)r0rr,rrrrJs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)Nrz!task_done() called too many timesr)rrErrr(rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)Nr)rrwaitr(rrrjoins z Queue.join)r)r r r r#r r)r.r0r7r8r6r>propertyr"r@rArHrGrLrJrMrOrrrrrs&      rc@s0eZdZddZejfddZejfddZdS)rcCs g|_dSr$r?r&rrrr szPriorityQueue._initcCs||j|dSr$r?)r!r-heappushrrrr.szPriorityQueue._putcCs ||jSr$r?)r!heappoprrrr)szPriorityQueue._getN) r r r r heapqrQr.rRr)rrrrrsrc@s$eZdZddZddZddZdS)rcCs g|_dSr$r?r&rrrr szLifoQueue._initcCs|j|dSr$r*r,rrrr.szLifoQueue._putcCs |jSr$)r%popr(rrrr)szLifoQueue._getN)r r r r r.r)rrrrrsr) __all__rrSrrr Exceptionrrrrrrrrrs  KPK!b5??&__pycache__/locks.cpython-38.opt-1.pycnu[U if|C@sdZdZddlZddlZddlZddlmZddlmZddlmZddlm Z Gd d d Z Gd d d Z Gd dde Z GdddZ Gddde ZGddde ZGdddeZdS)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s(eZdZdZddZddZddZdS) _ContextManagera\Context manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: Deprecated, use 'async with' statement: async with lock: cCs ||_dSN)_lock)selflockr2/opt/alt/python38/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r&r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%!_ContextManagerMixin__acquire_ctx __await__rrrrr)Ys z_ContextManagerMixin.__await__cs|IdHdSr )r&rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner'r Z _is_coroutiner(r)r*r.rrrrr1s rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... NloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)_waiters_lockedrget_event_loop_loopr#r$r%rr2rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r6r5lenrresZextra __class__rrrBs  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r6r5all collectionsdequer8 create_futureappendremover CancelledError_wake_up_firstrfutrrrr&s&    z Lock.acquirecCs"|jrd|_|ntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r6rSrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddS)z*Wake up the first waiter if it isn't done.NT)r5nextiter StopIterationdone set_resultrTrrrrSszLock._wake_up_first) rrrrrrBr;r&rrS __classcell__rrrFrrjs5  rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. Nr1cCs>t|_d|_|dkr$t|_n||_tjdt dddSr3) rMrNr5_valuerr7r8r#r$r%r9rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrB s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)r\r5rYrZrTrrrr]s  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)r\r8rOr5rPrQrTrrrwait(s   z Event.wait) rrrrrrBr_r]r`rar[rrrFrrs  rcsReZdZdZdddddZfddZdd Zd d Zdd dZddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr1cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r ValueErrorrr;r&rrMrNr5)rrr2rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr:)rArBr;r5rCrDrFrrrB[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockFNT) r;rrr&r rRr8rOr5rPrQ)rrHrUrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)rnidxrUrrrnotifys  zCondition.notifycCs|t|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rgrCr5rrrr notify_allszCondition.notify_all)N)r) rrrrrrBrardrgrhr[rrrFrr;s  % rcsPeZdZdZdddddZfddZd d Zd d Zd dZddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rNr1cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r4r r!) rbr\rMrNr5rr7r8r#r$r%rvaluer2rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrBs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r5popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&s    zSemaphore.acquirecCs|jd7_|dS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)r\rlrrrrrszSemaphore.release)r) rrrrrrBrlr;r&rr[rrrFrrs rcs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rNr1cs.|rtjdtdd||_tj||ddS)Nr4r r!r1)r#r$r% _bound_valuerArrirFrrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrs zBoundedSemaphore.release)r)rrrrrrr[rrrFrrs r)r__all__rMr/r#rr r r r rrrrrrrrrrs     "9DzNPK!@[{ )__pycache__/__init__.cpython-38.opt-2.pycnu[U if@sddlZddlTddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl Tddl mZejejejejejejejeje je je je je jZejdkrddlTeej7ZnddlTeej7ZdS)N)*)_all_tasks_compatZwin32)sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r 5/opt/alt/python38/lib64/python3.8/asyncio/__init__.pysX       PK!")+ + )__pycache__/format_helpers.cpython-38.pycnu[U ifd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   PK!x*0&__pycache__/unix_events.cpython-38.pycnu[U ifۿ@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe jdkredddZGdddejZGdddej Z!Gdddej"ej#Z$Gdddej%Z&GdddZ'ddZ(Gd d!d!e'Z)Gd"d#d#e)Z*Gd$d%d%e)Z+Gd&d'd'e'Z,Gd(d)d)e'Z-Gd*d+d+ej.Z/eZ0e/Z1dS),z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python38/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZdZd)fdd ZfddZddZd d Zd d Zd dZ ddZ d*ddZ d+ddZ d,ddZ ddZd-dddddddZd.dddddddd Zd!d"Zd#d$Zd%d&Zd'd(ZZS)/_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncst|i|_dSN)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fr5r6Nr3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |dkst|tst|r,|dkrLtdn |dk r.cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname____doc__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sH -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrxrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rxreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrxrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc CsRt|tttfstt|t|tr.t|}|s6dS|jsB|jrj|jtj krXt d|jd7_dS|j s8zt |j|}Wntttfk rd}YnZttfk rYnBtk r}z$|jd7_||dWYdSd}~XYnX|t|kr dS|dkr&t||d}|j|j|j|j |7_ |dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr#Fatal write error on pipe transport)rObytesr memoryviewrwreprrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrxwriterrrrarbrcrrrZ _add_writer _write_readyZ_maybe_pause_protocol)rr1nrFrrrrs8      z_UnixWritePipeTransport.writec Cs|jstdzt|j|j}Wnttfk r:Ynttfk rRYnt k r}z6|j |j d7_ |j |j||dW5d}~XYnhX|t|jkr|j |j |j||jr|j |j|ddS|dkr |jd|=dS)NzData should not be emptyrrr)rrwrxrrrrrarbrcr-rr_remove_writerrrZ_maybe_resume_protocolrrr)rrrFrrrrs,    z$_UnixWritePipeTransport._write_readycCsdSrrrrrr can_write_eofsz%_UnixWritePipeTransport.can_write_eofcCsB|jr dS|jstd|_|js>|j|j|j|jddSr) rrrwrrrrrrrrrr write_eofs z!_UnixWritePipeTransport.write_eofcCs ||_dSrrrrrrrsz$_UnixWritePipeTransport.set_protocolcCs|jSrrrrrrrsz$_UnixWritePipeTransport.get_protocolcCs|jSrrrrrrrsz"_UnixWritePipeTransport.is_closingcCs|jdk r|js|dSr)rrr rrrrr%sz_UnixWritePipeTransport.closecCs,|jdk r(|d|t|d|jdSrrrrrrrs z_UnixWritePipeTransport.__del__cCs|ddSr)rrrrrabortsz_UnixWritePipeTransport.abortrcCsNt|tr(|jr@tjd||ddn|j||||jd||dSr) rOr=rrr rrrrrrrrrs  z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j|j|j|j|j|j|j|dSr) rrrr rr-rrrrrrrrs  z_UnixWritePipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrrrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrr r rrrr%r*r+rr rrrrrrr!rrY<s"% #   rYc@seZdZddZdS)r^c Ksd}|tjkrt\}}zPtj|f||||d|d||_|dk rh|t|d|d|j_ d}W5|dk r||XdS)NF)rdrerfrgZuniversal_newlinesrhwb) buffering) subprocessPIPErzZ socketpairr%Popen_procrdetachre) rrErdrerfrgrhriZstdin_wrrr_start s.  z_UnixSubprocessTransport._startN)rrrrrrrrr^ sr^c@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. NNotImplementedErrorrrnrDrErrrr_9s z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.Nrrrnrrrremove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. Nrrrrrr attach_loopLsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. Nrrrrrr%VszAbstractChildWatcher.closecCs tdS)zReturn ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. Nrrrrrr\]szAbstractChildWatcher.is_activecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfNrrrrr __enter__fszAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextNrrabcrrr__exit__lszAbstractChildWatcher.__exit__N) rrrrr_rrr%r\rr!rrrrr"s   rcCs2t|rt| St|r*t|S|SdSr)rx WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)statusrrr_compute_returncodeqs     r'c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dSr)r _callbacksrrrrrszBaseChildWatcher.__init__cCs|ddSr)rrrrrr%szBaseChildWatcher.closecCs|jdk o|jSr)rZ is_runningrrrrr\szBaseChildWatcher.is_activecCs tdSrr)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdSrrrrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs~|dkst|tjst|jdk r<|dkr<|jrrr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r=r?rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r=r?r>r?r-r r)rrrr Zcollateral_victimsrrrr!s  zFastChildWatcher.__exit__c Gst|jstd|jFz|j|}Wn.tk rT||f|j|<YW5QRdSXW5QRX|||f|dS)NzMust use the context manager)r?rwr=r>r;rJr))rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr1r2rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr6z8Caught subprocess termination from unknown pid: %d -> %d)rxr8r9r:r'r=r)r;rJr?r>rrr rr)rrnr&rorDrErrrr,<s@    z FastChildWatcher._do_waitpid_all) rrrrrr%rr!r_rr,rrrr!rrs  rc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cCsi|_d|_dSr)r)_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r@rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r)r-r@r9 getsignalr.r/r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrr!szMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr)r+)rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr1r2rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..N)r(rIvaluesr)rthreadsrOrrrrJsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrrBrrrr!szThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rKrMrrrrP sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rIrQr"r,)rrrRrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErL) rrDr<ZThreadr+nextrHrIstart)rrnrDrErrOrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCs|dks tzt|d\}}Wn(tk rH|}d}td|Yn Xt|}|rhtd||| rtd||n|j |||f||j |dS)Nrr4r5r6rE) rwrxr8r:r rr'rrrFrmrIr;)rrr*rDrErnr&rorrrr+"s(  z ThreadedChildWatcher._do_waitpidN)rrrrrr\r%rJrr!r*r+rr_rrr+rrrrrs  rcsHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr=rXrrOr<current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprXrOr<rYrZrrr!rrr]Ms   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. N)rXr\rrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|tst|jdk r*|j||_dS)z$Set the watcher for child processes.N)rOrrwrXr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrr\r]r[r^rrrr!rrW=s   rW)2rrBrrGrxrr9rzrrr&r<r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr'r(rrrrZBaseDefaultEventLoopPolicyrWrrrrrrs`             NO5Ji}Y3PK!%%$__pycache__/staggered.cpython-38.pycnu[U ifh @sdZdZddlZddlZddlmZddlmZddlmZddlm Z dd ej ej gej fej eejejejej eejej efd d d ZdS) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|zfd}|t krt IdH\}}t |}|D]$}| r|s|r|qqlfWSD] }| qXdS)aRun coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. N)previous_failedr c sN|dk r6ttjt|IdHW5QRXzt\}}Wntk r\YdSXt } |} |t |dkst dt |dkstz|IdH}WnLttfk rYnptk r }z||<|W5d}~XYn>Xdkst||tD]\}}||kr,|q,dS)Nr) contextlibsuppressexceptions_mod TimeoutErrorrZwait_forwaitnext StopIterationrEvent create_taskappendlenAssertionError SystemExitKeyboardInterrupt BaseExceptionset enumeratecancel) r Z this_indexZcoro_fnZ this_failedZ next_taskresulteitr Z enum_coro_fnsrr run_one_coroZ running_tasksZ winner_indexZ winner_result6/opt/alt/python38/lib64/python3.8/asyncio/staggered.pyr%Rs4    z$staggered_race..run_one_coror)rZget_running_looprtypingOptionalrrrrrrrrdoneZ cancelledZ exception) r r rZ first_taskr#Z done_countr*_dr&r$r'rs,=  0   r)__doc____all__rr(rrrrrIterableCallable Awaitabler)floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr&r&r&r's&    PK!!88(__pycache__/streams.cpython-38.opt-2.pycnu[U if h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS)N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr4/opt/alt/python38/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS)NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@s>eZdZdddZddZddZdd Zd d Zd d ZdS)FlowControlMixinNcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs d|_|jrtd|dS)NTz%r pauses writing)r5r4 get_debugrdebugr8rrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jrtd||j}|dk rBd|_|sB|ddS)NFz%r resumes writing)r5r4r:rr;r6done set_resultr8waiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r>r? set_exceptionr8excrArrrconnection_losts z FlowControlMixin.connection_lostcs<|jrtd|jsdS|j}|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6r4 create_futurer@rrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname__r9r=rBrGrJrNrrrrr2s    r2csbeZdZdZdfdd ZeddZddZfdd Zd d Z d d Z ddZ ddZ Z S)rNcsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rI_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rUr<rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)rXrVr4Zcall_exception_handlerabortrZr` set_transportget_extra_infor\r[rrYr Z iscoroutineZ create_taskrW)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) r`feed_eofrDr]r>r?rRrGrUrYrZ)r8rFr'r^rrrG s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)r` feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)r`rhr\)r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r]rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r]r> cancelled exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrVr9propertyr`rgrGrkrlrNrp __classcell__rrr^rrs    rc@sreZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZddZdS)rcCs4||_||_||_||_|j|_|jddSr)rZ _protocol_readerr4rIZ _complete_futr?)r8r(rr'rrrrr9@s  zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )r_rOrZrtappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSrrZr<rrrr(PszStreamWriter.transportcCs|j|dSr)rZwriter8rjrrrrTszStreamWriter.writecCs|j|dSr)rZ writelinesrrrrrWszStreamWriter.writelinescCs |jSr)rZ write_eofr<rrrrZszStreamWriter.write_eofcCs |jSr)rZ can_write_eofr<rrrr]szStreamWriter.can_write_eofcCs |jSr)rZcloser<rrrr`szStreamWriter.closecCs |jSr)rZ is_closingr<rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rsrNr<rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)rZrd)r8namedefaultrrrrdiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)Nr)rtrnrZrrrsrJ)r8rFrrrdrainls   zStreamWriter.drain)N)rOrPrQr9r}rqr(rrrrrrrrdrrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionrZr5r:r extract_stacksys _getframerV)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=ruZpausedrvrw) rrxlenrr_DEFAULT_LIMITrrrZr5ryrzr{rrrr}s    zStreamReader.__repr__cCs|jSr)rr<rrrrnszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrmrDrErrrrDs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddSr)rrmr?r@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dSrr~)r8r(rrrrcszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrrZresume_readingr<rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrC)rrr<rrrrhszStreamReader.feed_eofcCs|jo |j Sr)rrr<rrrat_eofszStreamReader.at_eofcCst|sdS|j|||jdk rp|jspt|jd|jkrpz|jWntk rhd|_YnXd|_dS)NrT) rextendrrZr5rrZ pause_readingrKrrrrris   zStreamReader.feed_datacsX|jdk rt|d|jr.d|_|j|j|_z|jIdHW5d|_XdS)NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr5rZrr4rI)r8Z func_namerrr_wait_for_datas   zStreamReader._wait_for_datac sd}t|}z||IdH}Wntjk rN}z|jWYSd}~XYnhtjk r}zH|j||jr|jd|j|=n |j | t |j dW5d}~XYnX|S)N r) r readuntilr IncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)r8sepseplenlineerrrreadline s  zStreamReader.readlinercst|}|dkrtd|jdk r(|jd}t|j}|||kr||j||}|dkrZq|d|}||jkr|td||jrt |j}|j t |d| dIdHq,||jkrtd||jd||}|jd||=| t |S)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrr rrbytesrrrr)r8Z separatorroffsetZbuflenZisepchunkrrrr(s>         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)Nrrread) rrrrxrzrrrrr)r8nZblocksblockrjrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)Nrz*readexactly size can not be less than zeror readexactly) rrrrrrrr rrr)r8rZ incompleterjrrrrs&       zStreamReader.readexactlycCs|Srrr<rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rOrPrQrVrr9r}rnrDrrcrrhrrirrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rShasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkPPK!{`^`^*__pycache__/proactor_events.cpython-38.pycnu[U if<}@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZddZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZ Gddde j!Z"dS) zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname____doc__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s   rcsTeZdZdZdfdd ZddZddZd d Zd d Zd dZ dddZ Z S)_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rfr(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rfrrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rfr$rr*rgre_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr|jdkst||_dS|s.|dSt|jtjrzt|j|Wqt t fk rhYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.)rfreAssertionErrorrqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ data_received)r-rlrUrrrrjs$z)_ProactorReadPipeTransport._data_receivedc Csd}zrz|dk rP|j|ks0|jdkr,|js0td|_|rH|}n||jrfd}WWdS|dkrzWWdS|js|jj |j d|_Wnt k r}z0|js| |dn|jrtjdddW5d}~XYntk r}z||W5d}~XYnftk r>}z| |dW5d}~XYn8tjk r^|jsZYnX|jsv|j|jW5|dk r||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$r(rrrXresultrHrfr _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrg)r-futrlrUrrrrgsF     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_r`rrhrirmrqrjrgrcrrr3rrds rdcs^eZdZdZdZfddZddZddd Zd d Zd d Z ddZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportzTransport for write pipes.Tcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jdkst|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr%r#rr _loop_writing_maybe_pause_protocolextendrkrrrwriteKs.       z%_ProactorBaseWritePipeTransport.writeNc Csxz|dk r"|jdkr"|jr"WdS||jks0td|_d|_|rH||dkr\|j}d|_|s|jrv|j|jd|j r|j t j |n\|jj|j ||_|js|jdkstt||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk rD}z||W5d}~XYn0tk rr}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(rrr&rtr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrusendrXr;rzrrrWrYrxrPrRrV)r-frlrUrrrrqs<    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerrrrrrrrrcrrr3rr|As & )r|cs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrurvr r$rz _pipe_closedr}r3rrrsz$_ProactorWritePipeTransport.__init__cCsv|r dS|dkst|jr4|jdks0tdS||jksLt||jfd|_|jdk rj|tn|dS)Nrs) Z cancelledrtrrr(r$r%rPBrokenPipeErrorrI)r-r{rrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrcrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rg)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rl_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQrrrrrr ValueErrorr'rrr rr#r9r%rr)r-rladdrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Csz|jrWdS||jkstd|_|r.||jr@|jr\|jr\|jrV|j|j dWdS|j \}}|jdk r|jj |j ||_n|jj j|j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rrrtr#rr(rr*rGpopleftrurr rrRr+error_received ExceptionrVrzrr)r-r{rlrrUrrrrs4    z(_ProactorDatagramTransport._loop_writingc CsVd}z4z|jrWW$dS|j|ks:|jdkr6|js:td|_|dk r|}|jrdd}WWdS|jdk r|||j}}n|\}}|jrWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnNtk r}z|j|W5d}~XYn<tjk r|jsYnX|jdk r8|j|jW5|rP|j||XdSrB)r+Zdatagram_receivedr'r$r(rrrtrrrurvr max_sizeZrecvfromrRrrryrzrg)r-r{rlrresrUrrrrgsD         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrgrcrrr3rrs   !rc@s eZdZdZddZddZdS)_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`rrrrrrrEsrcsBeZdZdZejjZd fdd ZddZ ddZ d d Z Z S) _ProactorSocketTransportz Transport for connected sockets.Ncs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_r`rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrcrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8ru _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rdrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_piperurIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rurv)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)ruZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rur)r-rrlrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)ruZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)ruacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrusendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rhrirrrmZ sock_sendfiler )r-Ztransprrrrmrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rtrrurvrrryrnrorprTrz_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rtrr rSrrrrurrRr:rTr rrIrryrrz)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHru _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrcrrr3rrks\            +r)#r`__all__rrr rarrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrdZWriteTransportr|rrZ TransportrrZ BaseEventLooprrrrrsR           n  PK!{77/__pycache__/format_helpers.cpython-38.opt-2.pycnu[U ifd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   PK!!SS)__pycache__/sslproto.cpython-38.opt-1.pycnu[U ifJj@sddlZddlZz ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d Z d Z d Zd ZGdddeZGdddejejZGdddejZdS)N) base_events) constants) protocols) transports)loggercCs"|r tdt}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslZcreate_default_contextZcheck_hostname) server_sideserver_hostname sslcontextr 5/opt/alt/python38/lib64/python3.8/asyncio/sslproto.py_create_transport_contexts rZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZdddZeddZedd Zed d Z ed d Z dddZ dddZ ddZ dddZdddZdS)_SSLPipeaAn SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). iNcCsH||_||_||_t|_t|_t|_d|_ d|_ d|_ d|_ dS)a The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) _context _server_side_server_hostname _UNWRAPPED_stater Z MemoryBIO _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextr r r r r__init__8s   z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)rrr r rrNsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )rrr r r ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake that is currently in progress.)rrr r r need_ssldata[sz_SSLPipe.need_ssldatacCs |jtkS)zj Whether a security layer is currently in effect. Return False during handshake. )r_WRAPPEDrr r rwrappedasz_SSLPipe.wrappedcCsR|jtkrtd|jj|j|j|j|jd|_ t |_||_ |j ddd\}}|S)aLStart the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completed)r r T)only_handshake) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr feed_ssldatarcallbackssldataappdatar r r do_handshakejs z_SSLPipe.do_handshakecCsB|jtkrtd|jtkr$tdt|_||_|d\}}|S)a1Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. zno security layer presentzshutdown in progressr$)rrr& _SHUTDOWNrr(r)r r rshutdowns  z_SSLPipe.shutdowncCs|j|d\}}dS)zSend a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. r$N)rZ write_eofr()rr+r,r r rfeed_eofs z_SSLPipe.feed_eofFc Cs|jtkr"|r|g}ng}g|fSd|_|r8|j|g}g}z|jtkrz|jt|_|j rl| d|rz||fWS|jtkr|j |j }| ||sqqnJ|jt kr|jd|_t|_|jr|n|jtkr| |j Wnztjtjfk rl}zRt|dd}|tjtjtjfkrP|jtkrN|j rN| ||tjk|_W5d}~XYnX|jjr| |j ||fS)aFeed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). FNerrno)rrrrwriter'rr-r"rreadmax_sizeappendr.Zunwraprr SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLrpending)rdatar%r,r+chunkexc exc_errnor r rr(sZ               z_SSLPipe.feed_ssldatarc Cs|jtkr6|t|kr&||dg}ng}|t|fSg}t|}d|_z(|t|krn||j||d7}Wnhtjk r}zHt |dd}|j dkrtj }|_ |tj tj tjfkr|tj k|_W5d}~XYnX|jjr||j|t|ks |jrBq qB||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. NFr1ZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewrrr2r r6r8reasonr9r1r:r;rr<r5r3)rr=offsetr+Zviewr?r@r r r feed_appdatas4       z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname____doc__r4rpropertyrr r!r#r-r/r0r(rEr r r rr$s         Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||S)z#Get optional transport information.)rM_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSN)rM_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrU)rM _app_protocolrr r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrU)rNrr r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rNrM_start_shutdownrr r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rNResourceWarningr])rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rM _transportr& is_reading)rZtrr r rrbDsz _SSLProtocolTransport.is_readingcCs|jjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rMra pause_readingrr r rrcJsz#_SSLProtocolTransport.pause_readingcCs|jjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rMraresume_readingrr r rrdRsz$_SSLProtocolTransport.resume_readingcCs|jj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rMraset_write_buffer_limits)rZhighZlowr r rreZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjS)z,Return the current size of the write buffer.)rMraget_write_buffer_sizerr r rrfosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSrU)rMra_protocol_pausedrr r rrgssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearrayrB TypeErrortyperFrM_write_appdatarr=r r rr2xs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr rr r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. TN)rM_abortrNrr r raborts z_SSLProtocolTransport.abort)N)NN)rFrGrHrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrTrXrZr[r]warningswarnr`rbrcrdrerfrJrgr2rorqr r r rrKs$     rKc@seZdZdZd,ddZddZd-d d Zd d Zd dZddZ ddZ ddZ ddZ d.ddZ ddZddZddZdd Zd!d"Zd#d$Zd/d&d'Zd(d)Zd*d+ZdS)0 SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r&rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrLrVrK_app_transport_sslpipe_session_established _in_handshake _in_shutdownra_call_connection_made_ssl_handshake_timeout) rrO app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSrU)rYrhrZBufferedProtocol_app_protocol_is_buffer)rrr r rrVs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSrU)r|Z cancelledZ set_exceptionZ set_resultrr?r r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rarrurrr~_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FNT_handshake_timeout_handle) rrL call_soonrYconnection_lostr}rNrar8rcancelrr~rr r rrs    zSSLProtocol.connection_lostcCs|jdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rY pause_writingrr r rrszSSLProtocol.pause_writingcCs|jdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rYresume_writingrr r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)zXCalled when some SSL data is received. The argument is a bytes object. NzSSL error in data receivedz/application protocol failed to receive SSL data)r~r( SystemExitKeyboardInterrupt BaseException _fatal_errorrar2rrZ_feed_data_to_buffered_protorY data_receivedr\)rr=r+r,er>Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rar]rL get_debugrdebugrConnectionResetErrorrrY eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSrU)rwrarTrQr r rrPCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr$)rrrprmrr r rr\Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)rzr5r{rA_process_write_backlogrnr r rrmTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r$r)rLrrrtime_handshake_start_timerrzr5Z call_laterr_check_handshake_timeoutrrrr r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr T)rrrr~r Z getpeercertrrrrhr r7rrLrrrrrrwupdaterrrrYrr}rrrr)rZ handshake_excZsslobjrr?rZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsB|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj r|j q|jd=|j t|8_ q(Wn\ttfk rYnDtk r<}z$|jr ||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rar~rangerArzrEr-rr/ _finalizer2Z_pausedrdr{rrrrr)rir=rDr+r>r?r r rrs:   z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrW) rhOSErrorrLrrrZcall_exception_handlerraZ _force_close)rr?rr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSrU)r~rar]rr r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSrU)rrarqrr r rrps zSSLProtocol._abort)FNTN)N)N)r)rFrGrHrIrrVrrrrrrrrPr\rmrrrrrrrpr r r rrts0 .  &   )+ rt)rxrrr ImportErrorrrrrlogrrrr'r"r.objectrZ_FlowControlMixinZ TransportrKZProtocolrtr r r rs*       yxPK!_P+__pycache__/base_tasks.cpython-38.opt-1.pycnu[U if @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror 7/opt/alt/python38/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #PK!OO(__pycache__/streams.cpython-38.opt-1.pycnu[U if h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS) aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr4/opt/alt/python38/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS) z@Similar to `open_connection` but works with UNIX Domain Sockets.NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs d|_|jrtd|dS)NTz%r pauses writing)r5r4 get_debugrdebugr8rrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jrtd||j}|dk rBd|_|sB|ddS)NFz%r resumes writing)r5r4r:rr;r6done set_resultr8waiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r>r? set_exceptionr8excrArrrconnection_losts z FlowControlMixin.connection_lostcs<|jrtd|jsdS|j}|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6r4 create_futurer@rrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname____doc__r9r=rBrGrJrNrrrrr2s   r2csfeZdZdZdZdfdd ZeddZddZfd d Z d d Z d dZ ddZ ddZ ZS)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rI_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rVr<rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)rYrWr4Zcall_exception_handlerabortr[ra set_transportget_extra_infor]r\rrZr Z iscoroutineZ create_taskrX)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) rafeed_eofrDr^r>r?rSrGrVrZr[)r8rFr'r_rrrG s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)ra feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)rarir])r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r^rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r^r> cancelled exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrRrWr9propertyrarhrGrlrmrNrq __classcell__rrr_rrs   rc@sveZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdddZddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs4||_||_||_||_|j|_|jddSr)r[ _protocol_readerr4rIZ _complete_futr?)r8r(rr'rrrrr9@s  zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )r`rOr[ruappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSrr[r<rrrr(PszStreamWriter.transportcCs|j|dSr)r[writer8rkrrrrTszStreamWriter.writecCs|j|dSr)r[ writelinesrrrrrWszStreamWriter.writelinescCs |jSr)r[ write_eofr<rrrrZszStreamWriter.write_eofcCs |jSr)r[ can_write_eofr<rrrr]szStreamWriter.can_write_eofcCs |jSr)r[closer<rrrr`szStreamWriter.closecCs |jSr)r[ is_closingr<rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rtrNr<rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)r[re)r8namedefaultrrrreiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)ruror[rrrtrJ)r8rFrrrdrainls   zStreamWriter.drain)N)rOrPrQrRr9r~rrr(rrrrrrrrerrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionr[r5r:r extract_stacksys _getframerW)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=rvZpausedrwrx) rrylenrr_DEFAULT_LIMITrrr[r5rzr{r|rrrr~s    zStreamReader.__repr__cCs|jSr)rr<rrrroszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrnrDrErrrrDs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddS)z1Wakeup read*() functions waiting for data or EOF.N)rrnr?r@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dSrr)r8r(rrrrdszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrr[resume_readingr<rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrC)rrr<rrrriszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rrr<rrrat_eofszStreamReader.at_eofcCst|sdS|j|||jdk rp|jspt|jd|jkrpz|jWntk rhd|_YnXd|_dS)NrT) rextendrr[r5rrZ pause_readingrKrrrrrjs   zStreamReader.feed_datacsX|jdk rt|d|jr.d|_|j|j|_z|jIdHW5d|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr5r[rr4rI)r8Z func_namerrr_wait_for_datas   zStreamReader._wait_for_datac sd}t|}z||IdH}Wntjk rN}z|jWYSd}~XYnhtjk r}zH|j||jr|jd|j|=n |j | t |j dW5d}~XYnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilr IncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)r8sepseplenlineerrrreadline s  zStreamReader.readlinercst|}|dkrtd|jdk r(|jd}t|j}|||kr||j||}|dkrZq|d|}||jkr|td||jrt |j}|j t |d| dIdHq,||jkrtd||jd||}|jd||=| t |S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrr rrbytesrrrr)r8Z separatorroffsetZbuflenZisepchunkrrrr(s>         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rrrryr{rrrrr)r8nZblocksblockrkrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrr rrr)r8rZ incompleterkrrrrs&       zStreamReader.readexactlycCs|Srrr<rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rOrPrQrWrr9r~rorDrrdrrirrjrrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rThasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkPPK!Ҕ+__pycache__/coroutines.cpython-38.opt-1.pycnu[U if]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr7/opt/alt/python38/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCs>||_||_ttd|_t|dd|_t|dd|_ dS)Nr__name__ __qualname__) genfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrrrrr__iter__7szCoroWrapper.__iter__cCs |jdSr*rsendr+rrr__next__:szCoroWrapper.__next__cCs |j|Sr*r-)rvaluerrrr.=szCoroWrapper.sendcCs|j|||Sr*)rthrow)rtyper0 tracebackrrrr1@szCoroWrapper.throwcCs |jSr*)rcloser+rrrr4CszCoroWrapper.closecCs|jjSr*)rgi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)rgi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr __await__RszCoroWrapper.__await__cCs|jjSr*)r gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr5r z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) rf_lastijoinr3 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr(msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rrr)r,r/r.r1r4propertyr5r6r7r8r9rBrrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr*) rZisfutureinspectZ isgenerator isinstancerr8AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrPr rr)rrrrr)rMkwdswrQrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrGrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrUrrTrris"    rcCst|pt|ddtkS)z6Return True if func is a decorated coroutine function.r^N)rGrrr^rPrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)z)Return True if obj is a coroutine object.TdFN)r2_iscoroutine_typecacherH_COROUTINE_TYPESlenadd)objrrrrs   rc sht|tfdd}dd}d}t|dr:|jr:|j}nt|drP|jrP|j}||}|sr||rn|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|jpd }d }r$|jdk r$t |js$t |j}|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rJ|j }|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr"z without __name__>z())rZ_format_callbackrhasattrrrr2)rQ coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrIr6)rQrrr is_runnings z%_format_coroutine..is_runningcr_coder7z runningr5cr_framezrz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl co_filenamerrGrYrZ_get_function_sourcef_linenoco_firstlineno) rQrhrjZ coro_coderfZ coro_framefilenamelinenosourcer'rrgrr%sJ         r%) __all__Zcollections.abcrJrZrGrr r3r\rVr:rrrlogr rr]rrobjectr^r CoroutineType GeneratorTyperK Coroutinerasetr`rr%rrrrs2    E8PK!b^^ __pycache__/tasks.cpython-38.pycnu[U if@svdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZedjZdBd d ZdCd dZdDddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejj Z ejj!Z!ejj"Z"dde"dddZ#ddZ$ddddZ%d d!Z&d"d#Z'ddd$d%d&Z(ej)d'd(Z*dEddd)d*Z+ddd+d,Z,ej)d-d.Z-ee-_Gd/d0d0ej.Z/dd1d2d3d4Z0ddd5d6Z1d7d8Z2e 3Z4iZ5d9d:Z6d;d<Z7d=d>Z8d?d@Z9e6Z:e9Z;e7Ze9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|S)z!Return a currently executed task.N)rget_running_loop_current_tasksgetloopr!2/opt/alt/python38/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)z'Return a set of all tasks for the loop.Nrrcs&h|]}t|kr|s|qSr!)r _get_loopdone.0trr!r" <szall_tasks..)rrlist _all_tasks RuntimeErrorr iZtasksr!rr"r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr#csh|]}t|kr|qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat..)rget_event_loopr*r+r,r-r!rr"_all_tasks_compat@s r0cCs4|dk r0z |j}Wntk r&Yn X||dSN)set_nameAttributeError)tasknamer2r!r!r"_set_task_nameXs  r6cseZdZdZdZed%ddZed&ddZdddfd d Zfd d Z d dZ ddZ ddZ ddZ ddZddZddddZdddddZdd Zd'fd!d" Zd#d$ZZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd|dkr t}t|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevelN)warningswarnDeprecationWarningrr/rclsr r!r!r"rtszTask.current_taskcCstjdtddt|S)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"rs zTask.all_tasks)r r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)NrFza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror r5 __class__r!r"rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr!r"rXs  z Task.__del__cCs t|Sr1)rZ_task_repr_inforSr!r!r" _repr_infoszTask._repr_infocCs|jSr1)rMrYr!r!r"get_corosz Task.get_corocCs|jSr1)rIrYr!r!r"get_namesz Task.get_namecCst||_dSr1)rJrI)rSvaluer!r!r"r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr,)rSresultr!r!r" set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr!r!r" set_exceptionszTask.set_exception)limitcCs t||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)rSrcr!r!r" get_stackszTask.get_stack)rcfilecCst|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)rSrcrer!r!r" print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackr%rLcancelrKrYr!r!r"rgs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrgr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr$r,rQrRrOrhadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr!r"Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr1)r_rprR)rSfuturerur!r!r"Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname____doc__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs __classcell__r!r!rUr"rbs&     !Tr)r5cCs t}||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. )rrrr6)rTr5r r4r!r!r"rxs  r)r timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfdd t|D}t|||IdHS) aWait for the Futures and coroutines given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSrr r'frr!r"r)szwait..)risfuturerrErGtyperx ValueErrorrrrrrr:r;r<set_wait)fsr r~rr!rr"rs rcGs|s|ddSr1)r%r`)waiterargsr!r!r"_release_waitersrrc s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nrr7r8rr)rrr:r;r<r r%r__cancel_and_waitrrj TimeoutError create_future call_laterr functoolspartialrrrgremove_done_callback)futr~r rurtimeout_handlecbr!r!r"rsL              rc s|s td|d|dk r.||tt|fdd}|D]}||qLzIdHW5dk r||D]}||qXtt}}|D]"}| r| |q| |q||fS)zVInternal helper for wait(). The fs argument must be a collection of Futures. zSet of Futures is empty.NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrargr%r`rZcounterrrrr!r"_on_completions z_wait.._on_completion) AssertionErrorrrrlenrrrgrrr%add)rr~rr rrr%Zpendingr!rr"rs*     rc sF|}tt|}||z||IdHW5||XdS)z.cs*D]}|dqdSr1)r put_nowaitclearr)rr%todor!r" _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr1)removerrgr)r%rrr!r"r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr1)rrrr_r)r%r!r" _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrrxZqueuesrrr/r:r;r<rrrrranger)rr r~rrrr_r!)rr%r rrr"r7s*       rccs dVdS)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nr!r!r!r!r"__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)z9Coroutine that completes after a given time (in seconds).rNrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrg)Zdelayr_r rwhr!r!r"r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrrr$rrtZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r s    r ccs|EdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitabler!r!r"rsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. Nrcstj|d||_d|_dS)NrF)rBrC _children_cancel_requested)rSchildrenr rUr!r"rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|S)NFT)r%rrgr)rSZretZchildr!r!r"rgs z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"rsrF)r return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd |_ d 7|||<| |n||} |qdt |dS) aReturn a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r%rrarrjrbr_appendrr`)rruZresultsresrZ nfinishedZnfutsouterrr!r"_done_callbacks4    zgather.._done_callbackrrFr)rr/r:r;r<rr`r rr$rFrrrr)r rZcoros_or_futuresrZ arg_to_futargrr!rr"r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd }|S) a.Wait for a future, shielding it from cancellation. The statement res = await shield(something()) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = await shield(something()) except CancelledError: res = None Nrr7r8rcs\r|s|dS|r.n*|}|dk rJ|n|dSr1)rrargrbr`r_)innerrurr!r"_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr1)r%rr)rrr!r"_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r%rr$rrr)rr rr!)rrrr"r Ps     r cs:tstdtjfdd}|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr)rZ _chain_futurer rornrpZset_running_or_notify_cancelrb)rurTrwr r!r"callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr rr!rr"r s    r cCst|dS)z3Register a new task in asyncio as executed by loop.N)r+rr4r!r!r"rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr,r r4rr!r!r"rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr!r!r"rs rcCst|dS)zUnregister a task.N)r+discardrr!r!r"rsr)rrrrr+r)N)N)N)N)Br{__all__Zconcurrent.futuresrrNrrt itertoolstypesr:weakrefrrrrrrcount__next__rHrrr0r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr!r!r!r"s                #H,>  x?$PK!XFY  +__pycache__/exceptions.cpython-38.opt-1.pycnu[U ifa@sldZdZGdddeZGdddeZGdddeZGdd d eZGd d d e Z Gd d d eZ dS)zasyncio exceptions.)CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__r r 7/opt/alt/python38/lib64/python3.8/asyncio/exceptions.pyr src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrr r r r r src@seZdZdZdS)rz+The operation is not allowed in this state.Nrr r r r rsrc@seZdZdZdS)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nrr r r r rsrcs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r r rr __classcell__r r rr rs rcs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) r __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r sPK!s̓*&9&9)__pycache__/sslproto.cpython-38.opt-2.pycnu[U ifJj@sddlZddlZz ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d Z d Z d Zd ZGdddeZGdddejejZGdddejZdS)N) base_events) constants) protocols) transports)loggercCs"|r tdt}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslZcreate_default_contextZcheck_hostname) server_sideserver_hostname sslcontextr 5/opt/alt/python38/lib64/python3.8/asyncio/sslproto.py_create_transport_contexts rZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@szeZdZdZdddZeddZeddZed d Zed d Z dd dZ dddZ ddZ dddZ dddZdS)_SSLPipeiNcCsH||_||_||_t|_t|_t|_d|_ d|_ d|_ d|_ dSNF) _context _server_side_server_hostname _UNWRAPPED_stater Z MemoryBIO _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextr r r r r__init__8s   z_SSLPipe.__init__cCs|jSN)rrr r rrNsz_SSLPipe.contextcCs|jSr )rr!r r r ssl_objectSsz_SSLPipe.ssl_objectcCs|jSr )rr!r r r need_ssldata[sz_SSLPipe.need_ssldatacCs |jtkSr )r_WRAPPEDr!r r rwrappedasz_SSLPipe.wrappedcCsR|jtkrtd|jj|j|j|j|jd|_ t |_||_ |j ddd\}}|S)Nz"handshake in progress or completed)r r T)only_handshake) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr feed_ssldatarcallbackssldataappdatar r r do_handshakejs z_SSLPipe.do_handshakecCsB|jtkrtd|jtkr$tdt|_||_|d\}}|S)Nzno security layer presentzshutdown in progressr&)rrr( _SHUTDOWNrr*r+r r rshutdowns  z_SSLPipe.shutdowncCs|j|d\}}dS)Nr&)rZ write_eofr*)rr-r.r r rfeed_eofs z_SSLPipe.feed_eofFc Cs|jtkr"|r|g}ng}g|fSd|_|r8|j|g}g}z|jtkrz|jt|_|j rl| d|rz||fWS|jtkr|j |j }| ||sqqnJ|jt kr|jd|_t|_|jr|n|jtkr| |j Wnztjtjfk rl}zRt|dd}|tjtjtjfkrP|jtkrN|j rN| ||tjk|_W5d}~XYnX|jjr| |j ||fS)NFerrno)rrrrwriter)rr/r$rreadmax_sizeappendr0Zunwraprr SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLrpending)rdatar'r.r-chunkexc exc_errnor r rr*sZ               z_SSLPipe.feed_ssldatarc Cs|jtkr6|t|kr&||dg}ng}|t|fSg}t|}d|_z(|t|krn||j||d7}Wnhtjk r}zHt |dd}|j dkrtj }|_ |tj tj tjfkr|tj k|_W5d}~XYnX|jjr||j|t|ks |jrBq qB||fS)NFr3ZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewrrr4r r8r:reasonr;r3r<r=rr>r7r5)rr?offsetr-ZviewrArBr r r feed_appdatas4       z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname__r6rpropertyrr"r#r%r/r1r2r*rGr r r rr$s        Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dSr)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||Sr )rN_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSr )rN_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSr )rN _app_protocolr!r r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSr )rOr!r r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdSNT)rOrN_start_shutdownr!r r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rOResourceWarningr^)rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rN _transportr( is_reading)rZtrr r rrcDsz _SSLProtocolTransport.is_readingcCs|jjdSr )rNrb pause_readingr!r r rrdJsz#_SSLProtocolTransport.pause_readingcCs|jjdSr )rNrbresume_readingr!r r rreRsz$_SSLProtocolTransport.resume_readingcCs|jj||dSr )rNrbset_write_buffer_limits)rZhighZlowr r rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjSr )rNrbget_write_buffer_sizer!r r rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSr )rNrb_protocol_pausedr!r r rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)Nz+data: expecting a bytes-like instance, got ) isinstancebytes bytearrayrD TypeErrortyperHrN_write_appdatarr?r r rr4xs z_SSLProtocolTransport.writecCsdSrr r!r r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dSr\)rN_abortrOr!r r raborts z_SSLProtocolTransport.abort)N)NN)rHrIrJrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrUrXrZr[r^warningswarnrarcrdrerfrgrKrhr4rprrr r r rrLs$     rLc@seZdZd+ddZddZd,dd Zd d Zd d ZddZddZ ddZ ddZ d-ddZ ddZ ddZddZddZd d!Zd"d#Zd.d%d&Zd'd(Zd)d*ZdS)/ SSLProtocolFNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r(rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrMrVrL_app_transport_sslpipe_session_established _in_handshake _in_shutdownrb_call_connection_made_ssl_handshake_timeout) rrP app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSr )rYrirZBufferedProtocol_app_protocol_is_buffer)rrr r rrVs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSr )r}Z cancelledZ set_exceptionZ set_resultrrAr r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dSr )rbrrvrrr_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)NFT_handshake_timeout_handle) rrM call_soonrYconnection_lostr~rOrbr:rcancelrrrr r rrs    zSSLProtocol.connection_lostcCs|jdSr )rY pause_writingr!r r rrszSSLProtocol.pause_writingcCs|jdSr )rYresume_writingr!r r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)NzSSL error in data receivedz/application protocol failed to receive SSL data)rr* SystemExitKeyboardInterrupt BaseException _fatal_errorrbr4rrZ_feed_data_to_buffered_protorY data_receivedr])rr?r-r.er@Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl) rbr^rM get_debugrdebugrConnectionResetErrorrrY eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSr )rxrbrUrRr r rrQCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr&)rrrqrnr!r r rr]Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)r{r7r|rC_process_write_backlogror r rrnTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r&r)rMrrrtime_handshake_start_timerr{r7Z call_laterr_check_handshake_timeoutrrr!r r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr"T)rrrrr"Z getpeercertrrrrir r9rrMrrrrrrxupdaterrrrYrr~rrrr)rZ handshake_excZsslobjrrArZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsB|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj r|j q|jd=|j t|8_ q(Wn\ttfk rYnDtk r<}z$|jr ||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rbrrangerCr{rGr/rr1 _finalizer4Z_pausedrer|rrrrr)rir?rFr-r@rAr r rrs:   z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrW) riOSErrorrMrrrZcall_exception_handlerrbZ _force_close)rrArr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSr )rrbr^r!r r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSr )rrbrrr!r r rrqs zSSLProtocol._abort)FNTN)N)N)r)rHrIrJrrVrrrrrrrrQr]rnrrrrrrrqr r r rrus. .  &   )+ ru)ryrsr ImportErrorrrrrlogrrrr)r$r0objectrZ_FlowControlMixinZ TransportrLZProtocolrur r r rs*       yxPK!_P%__pycache__/base_tasks.cpython-38.pycnu[U if @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror 7/opt/alt/python38/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #PK!hGB+__pycache__/subprocess.cpython-38.opt-1.pycnu[U if@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsXeZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__7/opt/alt/python38/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname____doc__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrBr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrGszProcess.send_signalcCs|jdSr:)r terminater7rrrrIszProcess.terminatecCs|jdSr:)rkillr7rrrrJsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrMr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|j}|jrJ|dkr8dnd}td|||IdH}|jr|dkrndnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rrrrKr rMreadr1)rr.r,r;nameoutputrrr _read_streams   zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rQrRrrVrrZgatherrrF)rrPrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrErFrGrIrJrQrRrVrWrrrrrAts  rAc sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellrA) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrYr&rZcs tdSr\r]rr%rrr^sz(create_subprocess_exec..r_)rr`rarbrcZsubprocess_execrA) Zprogramrrrr rargsrerfr,r'rr%rrs( r)__all__ subprocessrarrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr rAZ_DEFAULT_LIMITrrrrrrs.     bV PK!مTT*__pycache__/constants.cpython-38.opt-2.pycnu[U ifx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r 6/opt/alt/python38/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s PK!? "__pycache__/runners.cpython-38.pycnu[U if@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr4/opt/alt/python38/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .PK!x}$$*__pycache__/base_subprocess.cpython-38.pycnu[U if"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j fddZ ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} n|d} td| |j|j|| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolrr r r r r waiterZextrakwargsZprogram __class__ ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc spzj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<jdk st | j j jD]\}}|j |f|qd_Wn\t tfk r Yn`tk rL}z"|dk r<|s<||W5d}~XYn X|dk rl|sl|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper rAssertionError call_soonrconnection_made SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&sB          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrV)r'cbr`r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rcrZpipe_connection_lost _try_finish)r'rJrar.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rcrZpipe_data_received)r'rJr`r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|dk st||jdks$t|j|jrsz6BaseSubprocessTransport._try_finish..T)rrUrallrrArc_call_connection_lostr>r.r.r/rds  z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'rar.r.r/ros z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rcrerfrhrirdro __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r]rJr5rj)r'r]rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rWsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rjr]rerJrqr.r.r/rp sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r]r pause_writingr>r.r.r/rysz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r]rresume_writingr>r.r.r/rzsz'WriteSubprocessPipeProto.resume_writingN) r2rrrsrrWr9rpryrzr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r]rfrJ)r'r`r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rrrsr{r.r.r.r/rTsrT)rrrtrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v PK!//+__pycache__/subprocess.cpython-38.opt-2.pycnu[U if@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsTeZdZfddZddZddZddZd d Zd d Zd dZ ddZ Z S)SubprocessStreamProtocolcsHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__7/opt/alt/python38/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrAr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHSr:)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrFszProcess.send_signalcCs|jdSr:)r terminater7rrrrHszProcess.terminatecCs|jdSr:)rkillr7rrrrIsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrLr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|j}|jrJ|dkr8dnd}td|||IdH}|jr|dkrndnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rrrrJr rLreadr1)rr.r,r;nameoutputrrr _read_streams   zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rPrQrrUrrZgatherrrE)rrOrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrDrErFrHrIrPrQrUrVrrrrr@ts  r@c sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellr@) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrXr&rYcs tdSr[r\rr%rrr]sz(create_subprocess_exec..r^)rr_r`rarbZsubprocess_execr@) Zprogramrrrr rargsrdrer,r'rr%rrs( r)__all__ subprocessr`rrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r@Z_DEFAULT_LIMITrrrrrrs.     bV PK!r '__pycache__/queues.cpython-38.opt-1.pycnu[U if @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N__name__ __module__ __qualname____doc__rr3/opt/alt/python38/lib64/python3.8/asyncio/queues.pyr src@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrsrc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS)*raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer"r#rrrr!6sz Queue._initcCs |jSr%)r&popleftr"rrr_get9sz Queue._getcCs|j|dSr%r&appendr"itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr%)r(ZdoneZ set_result)r"waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr)rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr2r3r4)r5r r7r)rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r&z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr&rlenrr)r"resultrrrr7Os  z Queue._formatcCs t|jS)zNumber of items in the queue.)r=r&r)rrrqsize[sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.r&r)rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr?r)rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rBr create_futurerr,cancelremove ValueError cancelledr1 put_nowait)r"r.Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)rBrr/rrclearr1rr-rrrrHs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| S)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rArrCrr,rDrErFrGr1 get_nowait)r"getterrrrgets    z Queue.getcCs$|r t|}||j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rArr*r1rr-rrrrKs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rrFrr r)rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwaitr)rrrjoins z Queue.join)r)r r r rr$r!r*r/r1r8r9r7r?propertyr#rArBrIrHrMrKrNrPrrrrrs(      rc@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dSr%r@r'rrrr!szPriorityQueue._initcCs||j|dSr%r@)r"r.heappushrrrr/szPriorityQueue._putcCs ||jSr%r@)r"heappoprrrr*szPriorityQueue._getN) r r r rr!heapqrRr/rSr*rrrrrsrc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dSr%r@r'rrrr!szLifoQueue._initcCs|j|dSr%r+r-rrrr/szLifoQueue._putcCs |jSr%)r&popr)rrrr*szLifoQueue._getN)r r r rr!r/r*rrrrrsr) __all__rrTrrr Exceptionrrrrrrrrrs  KPK!FP[[&__pycache__/base_events.cpython-38.pycnu[U if@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%e dZ&dZ'e(Z)ddZ*ddZ+ddZ,d+ddZ-d,ddZ.dd Z/e%e d!rd"d#Z0nd$d#Z0Gd%d&d&ej1Z2Gd'd(d(ej3Z4Gd)d*d*ej5Z6dS)-aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr8/opt/alt/python38/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETr"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs |jdk st|jd7_dSrZ)rAssertionErrorrrqrrr_attach#szServer._attachcCs<|jdkst|jd8_|jdkr8|jdkr8|dS)Nrr)rrr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdS)NT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.r)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)zDSchedule a coroutine object. Return a task object. N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)zRun until stop() is called.) firstiter finalizerFN)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonr)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrr rr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r)c s2|jr|j}ntj}|d|||||||IdHSrB)rr.r$r'r)rfr;r<r=r>r?r)Z getaddr_funcrrrr'2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr)rrrr0<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr1rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr4rfr*r6r7r8rrrr3Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r<minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r6r7r8 blocksizebuf total_sentviewreadrrrr5Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)Nbmodez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r})) rr%r>r$r1rr4r5formatr;rrrr2os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)z$Create, bind and connect one socket.Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr*rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r)r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfd d |D| d IdH\}}}|dkr d d Dt dkrdnJt dt fdd Dr҈dtd d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r)r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrS)rCr,)r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r%css|]}t|VqdSrBr`rarrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrSr Zstaggered_racerrallrHr&r>_create_connection_transportrget_extra_inforr )rfrr;r<rTr=r?r)r*rUrrrVrWinfosr,rRrnrr)rr^rbrfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rKrdrboolrrr) rfr*rrTrrrrrrrnrrrrf%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)aSend a file to transport. Return the total number of bytes which were sent. The method uses high-performance os.sendfile if available. file must be a regular file object opened in binary mode. 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. fallback set to True makes asyncio to manually read and send the file when the platform does not support the sendfile syscall (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support sendfile syscall and fallback is False. zTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr4_sendfile_fallback)rfrnr6r7r8r1rGrWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr:)rfrgr6r7r8rrrrlnszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr<) r<r=r>r\r#r{r?rr@rkwrite) rfrgr6r7r8rArBrCr?rDrErrrrmrs* z BaseEventLoop._sendfile_fallbackrjc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS) zzUpgrade transport to TLS. Return a new transport that *protocol* should start using immediately. Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rTrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r) reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| d d} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st dqڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk rt |trt|dkstd|j||tj|||dIdH}|std|D]:\}}}}}||f}||kr0ddg||<||||<qqfdd|D}|sjtdg}|tk r|rtdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tj tj!d| d r| "|r*| s&|#| |IdH|} Wn^tk rl}z | dk rR| $|%|W5d}~XYn&| dk r| $YnXqq|d |}|&}|'| || |}|j(rrt)d||nt*d||z|IdHWn|$YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rU remote_addrr=r?r)rrrsrtr%css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrr!z2-tuple is expectedrZr[cs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrUrurrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.) stacklevelrIz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))+r>r$r2r%dictr&itemsrKr#rzrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorrrrrd_unsetrrr"r+r&r'Z SO_BROADCASTrLrQrr9rdrrr(r ) rfrrUrur=r?r)rrrsrtr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxrhZfamrRZprorr|rZ local_addressZremote_addressrWrrrnrr}rcreate_datagram_endpoints*                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nr!r/)rAr') rfrr=r>r?r)rr;r<r(rrrrdLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r)rz getaddrinfo(z) returned empty list)rdr$r1r()rfr;r<r=r)rhrrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r)r*rrTrrrsrrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd |D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d dYqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNrXrYposixcygwinr.csg|]}j|dqS))r=r))r)rCr;r=r)r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrcrrz %r is serving).rrkr5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrLr(rOrMrNr>r1rKrrrr()rfrr;r<r=r)r*rrTrrrsrrrZhostsZfsrhZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rTrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS) aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. rcNrXr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rfrrgrr )rfrr*rTrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrr filenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrr rrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrr r&)rfr*rrrr(rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) Nzcmd must be a string universal_newlines must be Falsezshell must be Truerbufsize must be 0text must be Falseencoding must be Noneerrors must be Nonezrun shell command %rT%s: %r) rr3rr%rrrrr()rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr()rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz+A callable object or None is expected, got )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrd t|}d }|| 7}n2|dkrd t|}d }|| 7}nt |}| |d |qnt j d ||ddS)aEDefault exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>rRrr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rJ r)getr> __traceback__rrsortedr& traceback format_listrstriprr9rr) rfr rrRrZ log_linesr|valuetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)aDCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'task' (optional): Task instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrprr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs>t|tjstd|jrdSt|tjr.t|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr _cancelledrrr9rfrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsd                  ;   DoPK!;``/__pycache__/windows_events.cpython-38.opt-1.pycnu[U if@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd ZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZ Gddde!Z"Gdddej#Z$Gdd d ej%Z&Gd!d"d"Z'Gd#d$d$e j(Z)e$Z*Gd%d&d&e j+Z,Gd'd(d(e j+Z-e-Z.dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__;/opt/alt/python38/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rr%r6r0r9r; __classcell__r r rr!r+s   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrDZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrDrKrEr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rFrE _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rOrrHr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rUrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rUrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rUrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s   rCcsFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrcstj||||dd|_dS)Nr)rr_done_callback)rreventrHrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rWr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rWr:rr r!r9s  z_WaitCancelFuture.set_exception) r>r?r@rArr0r;r9rBr r rr!rVs  rVcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrQZ CreateEvent_event _event_fut)rrrGrHproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r\rJ CloseHandler]r[ _unregisterrrrOrMrr r!rOs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[ _wait_cancelrOr]rTr r r!rUs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZs rZc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|S)NF)rhrj)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlergadd)rfirstflagshpiper r r!rjs(     zPipeServer._server_pipe_handlecCs |jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rir0rdrgcloserhclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rArrlrjrmru__del__r r r r!rbs  rbc@seZdZdZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd fdd ZfddZddZd d Zdd d ZZ S)r z2Windows version of proactor event loop using IOCP.Ncs|dkrt}t|dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c s^z||jt W5|jdk rX|jj}|j|dk rR|jsR|j|d|_XdSr7) Z_self_reading_futurerr0r"r[r` call_soonZ_loop_self_readingr run_foreverrrrr r!rz8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)r[ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rgdiscardrmrurrlr[ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorriadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rbry)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr~) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizer~kwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rArrzrrrrBr r rr!r 0s 0r c@seZdZdZd;ddZddZddZd d ZdddZ d?ddZ d@ddZ dAddZddZddZdd Zd!d"Zd#d$ZdBd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2ZdCd3d4Zd5d6Zd7d8Zd9d:Zd S)Drz#Proactor implementation using IOCP.rcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrI) r2_resultsrQCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cachererfrF _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrYr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrLrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrK)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerNr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprQ Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrQrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrQrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrQrrnZ WSASendTorr)rrrrrr|rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrQrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrQrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrI)rrrrrQZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrQZ WSAConnectrr2rr;rZ BindLocalrr1rRerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rNerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrQrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrQrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrQZ ConnectPiper1rRZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrGr4r r r!rs  zIocpProactor.connect_pipecCs|||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rrGrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Src)rrW)rrXZ done_callbackrNr r r!raszIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rKrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrJINFINITEmathceilrQrrnZRegisterWaitWithQueuerr'rVr2rZrr)rrGrZ _is_cancelmsrrHrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrI)rFrprQrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrrLr{r r r!r`szIocpProactor._unregistercCst|}|d|SrI)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrQZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrJr_rr0Zdoner1r9rrLr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rKsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrVr0r1r2rr3time monotonicr debugrKrrJr_) rr'rNrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArrrrrrrrrrrrrrrrrrarrrr`rrKrrurwr r r r!rs8        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2r[rintrDr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr)/rArQrJrrrrrrrerrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrCrVrZobjectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sR         0J4;e`PK!d5yy'__pycache__/base_futures.cpython-38.pycnu[U if @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r)objrr9/opt/alt/python38/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) #helper function for Future.__repr__cSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d |S) r Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r&)__all__r _threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr&rrrr s   PK!Er7r5)rr?offsetr-ZviewrArBr r r feed_appdatas6        z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname____doc__r6rpropertyrr r!r#r/r1r2r(rFr r r rr$s         Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||S)z#Get optional transport information.)rN_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSN)rN_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrV)rN _app_protocolrr r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrV)rOrr r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rOrN_start_shutdownrr r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rOResourceWarningr^)rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rN _transportr& is_reading)rZtrr r rrcDsz _SSLProtocolTransport.is_readingcCs|jjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rNrb pause_readingrr r rrdJsz#_SSLProtocolTransport.pause_readingcCs|jjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rNrbresume_readingrr r rreRsz$_SSLProtocolTransport.resume_readingcCs|jj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rNrbset_write_buffer_limits)rZhighZlowr r rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjS)z,Return the current size of the write buffer.)rNrbget_write_buffer_sizerr r rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSrV)rNrb_protocol_pausedrr r rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearrayrC TypeErrortyperGrN_write_appdatarr?r r rr4xs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr rr r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. TN)rN_abortrOrr r raborts z_SSLProtocolTransport.abort)N)NN)rGrHrIrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrUrYr[r\r^warningswarnrarcrdrerfrgrKrhr4rprrr r r rrLs$     rLc@seZdZdZd,ddZddZd-d d Zd d Zd dZddZ ddZ ddZ ddZ d.ddZ ddZddZddZdd Zd!d"Zd#d$Zd/d&d'Zd(d)Zd*d+ZdS)0 SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r&rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrMrWrL_app_transport_sslpipe_session_established _in_handshake _in_shutdownrb_call_connection_made_ssl_handshake_timeout) rrP app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSrV)rZrirZBufferedProtocol_app_protocol_is_buffer)rrr r rrWs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSrV)r}Z cancelledZ set_exceptionZ set_resultrrAr r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rbrrvrrr_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FNT_handshake_timeout_handle) rrM call_soonrZconnection_lostr~rOrbr:rcancelrrrr r rrs    zSSLProtocol.connection_lostcCs|jdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rZ pause_writingrr r rrszSSLProtocol.pause_writingcCs|jdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rZresume_writingrr r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)zXCalled when some SSL data is received. The argument is a bytes object. NzSSL error in data receivedz/application protocol failed to receive SSL data)rr( SystemExitKeyboardInterrupt BaseException _fatal_errorrbr4rrZ_feed_data_to_buffered_protorZ data_receivedr])rr?r-r.er@Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rbr^rM get_debugrdebugrConnectionResetErrorrrZ eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSrV)rxrbrUrRr r rrQCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr$)rrrqrnrr r rr]Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)r{r7r|r)_process_write_backlogror r rrnTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r$r)rMrrrtime_handshake_start_timerr{r7Z call_laterr_check_handshake_timeoutrrrr r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr T)rrrrr Z getpeercertrrrrir r9rrMrrrrrrxupdaterrrrZrr~rrrr)rZ handshake_excZsslobjrrArZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsP|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj st |jj r|jq|jd=|jt|8_q(Wn^ttfk rYnDtk rJ}z$|jr.||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rbrranger)r{rFr/rr1 _finalizer4r!r*Z_pausedrer|rrrrr)rir?rEr-r@rAr r rrs<    z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrX) riOSErrorrMrrrZcall_exception_handlerrbZ _force_close)rrArr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSrV)rrbr^rr r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSrV)rrbrrrr r rrqs zSSLProtocol._abort)FNTN)N)N)r)rGrHrIrJrrWrrrrrrrrQr]rnrrrrrrrqr r r rrus0 .  &   )+ ru)ryrsr ImportErrorrrrrlogrrrr'r"r0objectrZ_FlowControlMixinZ TransportrLZProtocolrur r r rs*       yxPK!pT0[[/__pycache__/windows_events.cpython-38.opt-2.pycnu[U if@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd lmZd ZdZd ZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGddde Z!Gdddej"Z#Gdddej$Z%Gd d!d!Z&Gd"d#d#e j'Z(e#Z)Gd$d%d%e j*Z+Gd&d'd'e j*Z,e,Z-dS)(N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?csZeZdZddfdd ZfddZddZfd d Zfd d Zfd dZZ S)_OverlappedFutureNloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__;/opt/alt/python38/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname__rr%r6r0r9r; __classcell__r r rr!r+s    rcsjeZdZddfdd ZddZfddZd d Zd d Zfd dZfddZ fddZ Z S)_BaseWaitHandleFutureNrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrCZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrCrJrDr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rErD _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rNrrGr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rTrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rTrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rTrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rrJr%rNrTr0r9r;rAr r rr!rB[s   rBcsBeZdZddfdd ZddZfddZfd d ZZS) _WaitCancelFutureNrcstj||||dd|_dS)Nr)rr_done_callback)rreventrGrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rVr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rVr:rr r!r9s  z_WaitCancelFuture.set_exception)r>r?r@rr0r;r9rAr r rr!rUs rUcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrPZ CreateEvent_event _event_fut)rrrFrGproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r[rI CloseHandler\rZ _unregisterrrrNrLrr r!rNs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrO)rErDrPZUnregisterWaitExr[r1rQrRrr2r3rZ _wait_cancelrNr\rSr r r!rTs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrNrTrAr r rr!rYs rYc@s8eZdZddZddZddZddZd d ZeZd S) PipeServercCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|SNF)rgri)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrIZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPipercZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerfadd)rfirstflagshpiper r r!ris(     zPipeServer._server_pipe_handlecCs |jdkSr7)rcr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rhr0rcrfclosergclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rrlrirmru__del__r r r r!ras   rac@s eZdZdS)_WindowsSelectorEventLoopN)r>r?r@r r r r!rx,srxcsDeZdZd fdd ZfddZddZdd Zd d d ZZS)r Ncs|dkrt}t|dSr7)rrr)rr]rr r!r3szProactorEventLoop.__init__c s^z||jt W5|jdk rX|jj}|j|dk rR|jsR|j|d|_XdSr7) Z_self_reading_futurerr0r"rZr_ call_soonZ_loop_self_readingr run_foreverrrrr r!rz8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)rZ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rfdiscardrmrurrlrZ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorrhadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rary)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr~) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizer~kwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rrzrrrrAr r rr!r 0s  0r c@seZdZd:ddZddZddZdd Zd;d d Zd dZdddZ d?ddZ d@ddZ ddZddZddZd d!Zd"d#ZdAd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1ZdBd2d3Zd4d5Zd6d7Zd8d9Zd S)CrrcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrH) r2_resultsrPCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cacherdrerE _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrXr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrKrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrJ)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerMr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rQrPZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprP Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrPrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrPrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrPrrnZ WSASendTorr)rrrrrr|rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrPrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrPZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrPrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrH)rrrrrPZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrPZ WSAConnectrr2rr;rZ BindLocalrr1rQerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rMerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrPrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrPrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrPZ ConnectPiper1rQZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrFr4r r r!rs  zIocpProactor.connect_pipecCs|||dSrj)_wait_for_handle)rrFrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Srb)rrV)rrWZ done_callbackrMr r r!r`szIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rJrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrIINFINITEmathceilrPrrnZRegisterWaitWithQueuerr'rUr2rYrr)rrFrZ _is_cancelmsrrGrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrH)rErprPrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dSr7)rrrKr{r r r!r_szIocpProactor._unregistercCst|}|d|SrH)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrPZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrIr^rr0Zdoner1r9rrKr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rJsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrUr0r1r2rr3time monotonicr debugrJrrIr^) rr'rMrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rrrrrrrrrrrrrrrrrr`rrrr_rrJrrurwr r r r!rs6        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2rZrintrCr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr).rPrIrrrrrrrdrrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrBrUrYobjectraZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sP         0J4;e`PK!Yw--(__pycache__/futures.cpython-38.opt-2.pycnu[U ifb3@sdZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ej Z ej Z ej Z ejZejdZGdd d ZeZd d Zd d ZddZddZddZddZddddZz ddlZWnek rYn XejZZdS))Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZeZdZdZdZdZdZ dZ ddddZ e j ZddZdd Zed d Zejd d Zd dZddZddZddZddZddZddZddddZddZd d!Zd"d#Zd$d%ZeZ dS)&rNFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)NFT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dSNr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkSr()r/r1rrrr cancelledszFuture.cancelledcCs |jtkSr()r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)NzResult is not ready.F) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)NzException is not set.F)r/r1rr;r<r=r#r$rrrrr!s    zFuture.exceptionr5cCsB|jtkr|jj|||dn |dkr.t}|j||fdSr4)r/r0r r6 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)Ncs g|]\}}|kr||fqSrr).0fr8rBrr sz/Future.remove_done_callback..)rlen)rrBZfiltered_callbacksZ removed_countrrFrremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)N: )r/r0rr=r>r<r2)rr?rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)NrJzPStopIteration interacts badly with generators and cannot be raised into a FutureT) r/r0rr= isinstancetype StopIteration TypeErrorr$r<r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r:_asyncio_future_blockingr-r?rrrr __await__s zFuture.__await__)!r __module__ __qualname__r0r/r>r$r rrQr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r9r:r?r!rCrIrKrPrR__iter__rrrrrs8    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dSr()r9rK)rYr?rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rM concurrentfuturesr;rargs TimeoutErrorr=)r%Z exc_classrrr_convert_future_exc#s      r`cCsR|r||sdS|}|dk r<|t|n|}||dSr()r9r3Zset_running_or_notify_cancelr!rPr`r?rK)r\sourcer!r?rrr_set_concurrent_future_state/srbcCsT|r dS|r|n2|}|dk r>|t|n|}||dSr()r9r3r!rPr`r?rK)radestr!r?rrr_copy_future_state>s rdcststtjjstdts._set_statecs2|r.dkskr"n jdSr()r9r3call_soon_threadsafe) destination) dest_loopra source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r9Z is_closedrg)ra)rfrirhrjrr_call_set_stateos z&_chain_future.._call_set_state)rrLr\r]rrOrZrC)rarhrkrlr)rfrirhrarjr _chain_futureRs   rmr cCs2t|r |S|dkrt}|}t|||Sr()rrr Z create_futurerm)r"r Z new_futurerrrr|s r)__all__Zconcurrent.futuresr\r@Zloggingrrrrr rr0r1r<DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rbrdrmrZ_asyncio ImportErrorZ_CFuturerrrrs8     q  *  PK!")+ + /__pycache__/format_helpers.cpython-38.opt-1.pycnu[U ifd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   PK!@II'__pycache__/events.cpython-38.opt-2.pycnu[U if4f@sxdZddlZddlZddlZddlZddlZddlZddlmZddlm Z GdddZ Gdd d e Z Gd d d Z Gd d d Z GdddZGdddeZdaeZGdddejZeZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Z eZ!eZ"eZ#eZ$zdd*l%mZmZmZmZWne&k rbYnXeZ'eZ(eZ)eZ*dS)+)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpers) exceptionsc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)r) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|dkrt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr&3/opt/alt/python38/lib64/python3.8/asyncio/events.py__init__ s zHandle.__init__cCsl|jjg}|jr|d|jdk r:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r!infoframer&r&r' _repr_info/s    zHandle._repr_infocCs(|jdk r|jS|}dd|S)Nz<{}> )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcs~eZdZddgZdfdd ZfddZdd Zd d Zd d ZddZ ddZ ddZ ddZ fddZ ddZZS)r _scheduled_whenNcs0t|||||jr |jd=||_d|_dS)Nr*F)superr(rrKrJ)r!whenr"r#r$r%r,r&r'r(hs zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rLr2rinsertrK)r!r0posrNr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrKr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rKr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rK__eq__rUr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rTrUr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rXrUr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrKrrrNotImplementedrUr&r&r'rYs     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)rYr^)r!rVZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrLr:r9rNr&r'r:s zTimerHandle.cancelcCs|jSr;rTr9r&r&r'rMszTimerHandle.when)N)r-rGrHrIr(r2rSrWrZr[r\rYr_r:rM __classcell__r&r&rNr'rcs  rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)rcCstdSr;NotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdSr;rbr9r&r&r'get_loopszAbstractServer.get_loopcCstdSr;rbr9r&r&r' is_servingszAbstractServer.is_servingcstdSr;rbr9r&r&r' start_servingszAbstractServer.start_servingcstdSr;rbr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdSr;rbr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rdri)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrdrerfrgrhrirjrkr&r&r&r'rsrc @sReZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddddZdd Zd!d"Zd#d$Zd%d%d%d%d&d'd(Zdtd)d*Zdudd%d%d%ddddddd+ d,d-Zdvejejdd.ddddd/d0 d1d2Zdwd/d3d4d5Zd6ddd7d8d9Zdxddddd:d;d<Zdydd.ddd/d=d>d?Zdzd%d%d%ddddd@dAdBZdCdDZ dEdFZ!e"j#e"j#e"j#dGdHdIZ$e"j#e"j#e"j#dGdJdKZ%dLdMZ&dNdOZ'dPdQZ(dRdSZ)dTdUZ*dVdWZ+dXdYZ,dZd[Z-d\d]Z.d{dd3d^d_Z/d`daZ0dbdcZ1dddeZ2dfdgZ3dhdiZ4djdkZ5dldmZ6dndoZ7dpdqZ8drdsZ9dS)|rcCstdSr;rbr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdSr;rb)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdSr;rbr9r&r&r'stopszAbstractEventLoop.stopcCstdSr;rbr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdSr;rbr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdSr;rbr9r&r&r'rds zAbstractEventLoop.closecstdSr;rbr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdSr;rb)r!r=r&r&r'r`sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rb)r!Zdelayr"r#r&r&r'rrszAbstractEventLoop.call_latercGstdSr;rb)r!rMr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rbr9r&r&r'time szAbstractEventLoop.timecCstdSr;rbr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rb)r!cororxr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rbrsr&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rb)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rb)r!r|r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rb)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rb)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rb)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrrgc stdSr;rb) r!rrrrrrrrrrrrgr&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdSr;rb)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdSr;rb)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rb)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrrgcstdSr;rb)r!rrrrrrrgr&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdSr;rb) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdSr;rbr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdSr;rbrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rb)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rb)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rbr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rbr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rbrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rbrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rb)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rb)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rb)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rb)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rb)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rb)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rb)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rb)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rb)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rbr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rbr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rb)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rbr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rbrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rbr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rb)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN):r-rGrHrlrmrnrorprdrqr`rtrrrurvrwrzr{r~rrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s4eZdZddZddZddZddZd d Zd S) rcCstdSr;rbr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdSr;rbr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdSr;rbr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdSr;rbr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdSr;rb)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN)r-rGrHrr r r r r&r&r&r'r<s  rc@sBeZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)Nz,There is no current event loop in thread %r.) rrrr] threadingZcurrent_threadZ _MainThreadr r RuntimeErrorrxr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dSr7)rrrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|Sr;) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrrlocalrr(rr r r&r&r&r'r^s  rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdSr;) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dSr;)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttSr;)rrr&r&r&r'rsrcCs|adSr;)r)Zpolicyr&r&r'rsrcCst}|dk r|StSr;)rrr)Z current_loopr&r&r'rs rcCst|dSr;)rr rr&r&r'r sr cCs tSr;)rr r&r&r&r'r sr cCs tSr;)rr r&r&r&r'r sr cCs t|Sr;)rr )rr&r&r'r sr )rr rr)+__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sV   J@*q"9    PK!L^^&__pycache__/tasks.cpython-38.opt-1.pycnu[U if@svdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZedjZdBd d ZdCd dZdDddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejj Z ejj!Z!ejj"Z"dde"dddZ#ddZ$ddddZ%d d!Z&d"d#Z'ddd$d%d&Z(ej)d'd(Z*dEddd)d*Z+ddd+d,Z,ej)d-d.Z-ee-_Gd/d0d0ej.Z/dd1d2d3d4Z0ddd5d6Z1d7d8Z2e 3Z4iZ5d9d:Z6d;d<Z7d=d>Z8d?d@Z9e6Z:e9Z;e7Ze9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|S)z!Return a currently executed task.N)rget_running_loop_current_tasksgetloopr!2/opt/alt/python38/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)z'Return a set of all tasks for the loop.Nrrcs&h|]}t|kr|s|qSr!)r _get_loopdone.0trr!r" <szall_tasks..)rrlist _all_tasks RuntimeErrorr iZtasksr!rr"r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr#csh|]}t|kr|qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat..)rget_event_loopr*r+r,r-r!rr"_all_tasks_compat@s r0cCs4|dk r0z |j}Wntk r&Yn X||dSN)set_nameAttributeError)tasknamer2r!r!r"_set_task_nameXs  r6cseZdZdZdZed%ddZed&ddZdddfd d Zfd d Z d dZ ddZ ddZ ddZ ddZddZddddZdddddZdd Zd'fd!d" Zd#d$ZZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd|dkr t}t|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevelN)warningswarnDeprecationWarningrr/rclsr r!r!r"rtszTask.current_taskcCstjdtddt|S)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"rs zTask.all_tasks)r r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)NrFza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror r5 __class__r!r"rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr!r"rXs  z Task.__del__cCs t|Sr1)rZ_task_repr_inforSr!r!r" _repr_infoszTask._repr_infocCs|jSr1)rMrYr!r!r"get_corosz Task.get_corocCs|jSr1)rIrYr!r!r"get_namesz Task.get_namecCst||_dSr1)rJrI)rSvaluer!r!r"r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr,)rSresultr!r!r" set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr!r!r" set_exceptionszTask.set_exception)limitcCs t||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)rSrcr!r!r" get_stackszTask.get_stack)rcfilecCst|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)rSrcrer!r!r" print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackr%rLcancelrKrYr!r!r"rgs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrgr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr$r,rQrRrOrhadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr!r"Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr1)r_rprR)rSfuturerur!r!r"Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname____doc__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs __classcell__r!r!rUr"rbs&     !Tr)r5cCs t}||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. )rrrr6)rTr5r r4r!r!r"rxs  r)r timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfdd t|D}t|||IdHS) aWait for the Futures and coroutines given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSrr r'frr!r"r)szwait..)risfuturerrErGtyperx ValueErrorrrrrrr:r;r<set_wait)fsr r~rr!rr"rs rcGs|s|ddSr1)r%r`)waiterargsr!r!r"_release_waitersrrc s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nrr7r8rr)rrr:r;r<r r%r__cancel_and_waitrrj TimeoutError create_future call_laterr functoolspartialrrrgremove_done_callback)futr~r rurtimeout_handlecbr!r!r"rsL              rc s|d|dk r"||tt|fdd}|D]}||q@zIdHW5dk rp|D]}||qtXtt}}|D]"}|r| |q| |q||fS)zVInternal helper for wait(). The fs argument must be a collection of Futures. NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrargr%r`rZcounterrrrr!r"_on_completions z_wait.._on_completion) rrrlenrrrgrrr%add)rr~rr rrr%Zpendingr!rr"rs(    rc sF|}tt|}||z||IdHW5||XdS)z.cs*D]}|dqdSr1)r put_nowaitclearr)rr%todor!r" _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr1)removerrgr)r%rrr!r"r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr1)rrrr_r)r%r!r" _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrrxZqueuesrrr/r:r;r<rrrrranger)rr r~rrrr_r!)rr%r rrr"r7s*       rccs dVdS)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nr!r!r!r!r"__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)z9Coroutine that completes after a given time (in seconds).rNrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrg)Zdelayr_r rwhr!r!r"r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrrr$rrtZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r s    r ccs|EdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitabler!r!r"rsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. Nrcstj|d||_d|_dS)NrF)rBrC _children_cancel_requested)rSchildrenr rUr!r"rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|S)NFT)r%rrgr)rSZretZchildr!r!r"rgs z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"rsrF)r return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd |_ d 7|||<| |n||} |qdt |dS) aReturn a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r%rrarrjrbr_appendrr`)rruZresultsresrZ nfinishedZnfutsouterrr!r"_done_callbacks4    zgather.._done_callbackrrFr)rr/r:r;r<rr`r rr$rFrrrr)r rZcoros_or_futuresrZ arg_to_futargrr!rr"r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd }|S) a.Wait for a future, shielding it from cancellation. The statement res = await shield(something()) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = await shield(something()) except CancelledError: res = None Nrr7r8rcs\r|s|dS|r.n*|}|dk rJ|n|dSr1)rrargrbr`r_)innerrurr!r"_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr1)r%rr)rrr!r"_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r%rr$rrr)rr rr!)rrrr"r Ps     r cs:tstdtjfdd}|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr)rZ _chain_futurer rornrpZset_running_or_notify_cancelrb)rurTrwr r!r"callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr rr!rr"r s    r cCst|dS)z3Register a new task in asyncio as executed by loop.N)r+rr4r!r!r"rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr,r r4rr!r!r"rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr!r!r"rs rcCst|dS)zUnregister a task.N)r+discardrr!r!r"rsr)rrrrr+r)N)N)N)N)Br{__all__Zconcurrent.futuresrrNrrt itertoolstypesr:weakrefrrrrrrcount__next__rHrrr0r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr!r!r!r"s                #H,>  x?$PK!_\$$0__pycache__/base_subprocess.cpython-38.opt-2.pycnu[U if"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j fddZ ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} n|d} td| |j|j|| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolrr r r r r waiterZextrakwargsZprogram __class__ ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc s`zj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<|j j j D]\}}|j|f|qd_ WnZt t fk rYn`tk r<}z"|dk r,|s,||W5d}~XYn X|dk r\|s\|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&s@          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrU)r'cbr_r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rbrZpipe_connection_lost _try_finish)r'rJr`r.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rbrZpipe_data_received)r'rJr_r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCsp|jrtd||||_|jjdkr2||j_||jj | |j D]}| sN| |qNd|_ dS)Nz%r exited with return code %r)rr!rr8rr returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/_process_exiteds    z'BaseSubprocessTransport._process_exitedcs0|jdk r|jS|j}|j||IdHSr:)rrZ create_futurerr3)r'r*r.r.r/_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jDr:d|_||jddS)Ncss|]}|dk o|jVqdSr:) disconnected).0pr.r.r/ sz6BaseSubprocessTransport._try_finish..T)rallrrArrb_call_connection_lostr>r.r.r/rcs z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'r`r.r.r/rns z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rir\rdrJrpr.r.r/ro sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r\r pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r\rresume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN) r2rqrrrrVr9rorxryr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r\rerJ)r'r_r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrsrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v PK!::,__pycache__/unix_events.cpython-38.opt-1.pycnu[U ifۿ@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe jdkredddZGdddejZGdddej Z!Gdddej"ej#Z$Gdddej%Z&GdddZ'ddZ(Gd d!d!e'Z)Gd"d#d#e)Z*Gd$d%d%e)Z+Gd&d'd'e'Z,Gd(d)d)e'Z-Gd*d+d+ej.Z/eZ0e/Z1dS),z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python38/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZdZd)fdd ZfddZddZd d Zd d Zd dZ ddZ d*ddZ d+ddZ d,ddZ ddZd-dddddddZd.dddddddd Zd!d"Zd#d$Zd%d&Zd'd(ZZS)/_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncst|i|_dSN)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fr5r6Nr3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |r|dkr6tdn |dk r&td|dk r6td|dk r|dk rNtdt|}ttjtjd}z |d|||IdHWq|YqXn@|dkrtd|j tjks|j tjkrtd||d|j |||||d IdH\}}||fS) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rs) r<osfspathsocketAF_UNIX SOCK_STREAM setblockingZ sock_connectr%familytypeZ_create_connection_transport) rprotocol_factorypathrprqrrrs transportrUrrrcreate_unix_connectionsR      z-_UnixSelectorEventLoop.create_unix_connectiondT)rqbacklogrprs start_servingc st|trtd|dk r&|s&td|dk rH|dk r@tdt|}ttjtj}|ddkrz t t |j rt |WnBt k rYn0tk r}ztd||W5d}~XYnXz||Wnltk r0} z8|| jtjkrd|d} ttj| dnW5d} ~ XYn|YnXn<|dkrZtd |jtjksv|jtjkrtd ||d t||g||||} |r| tjd|d IdH| S) Nz*ssl argument must be an SSLContext or Nonertrur)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)loop)rOboolr7r<rwrxryrzr{statS_ISSOCKst_moderemoveFileNotFoundErrorr=r errorZbindr%rBZ EADDRINUSEr}r~r|rZServerZ_start_servingr sleep) rrrrqrrprsrerrrFmsgZserverrrrcreate_unix_serversn           z)_UnixSelectorEventLoop.create_unix_serverc sz tjWn,tk r6}ztdW5d}~XYnXz |}Wn2ttjfk rv}ztdW5d}~XYnXzt|j }Wn,t k r}ztdW5d}~XYnX|r|n|} | sdS| } | | d||||| d| IdHS)Nzos.sendfile() is not availableznot a regular filer) rwsendfileAttributeErrorrSendfileNotAvailableErrorr;ioUnsupportedOperationfstatst_sizer=r]_sock_sendfile_native_impl) rrqfileoffsetcountrFr;rZfsize blocksizefutrrr_sock_sendfile_nativeJs2    z,_UnixSelectorEventLoop._sock_sendfile_nativec Cs,|} |dk r|||r4||||dS|rd||}|dkrd||||||dSzt| |||} WnDttfk r|dkr| ||| | |j || |||||| Ynbt k rj} z|dk r| j t jkrt| tk rtdt j} | | _| } |dkrBtd} |||||| n|||||| W5d} ~ XYnttfk rYntk r} z|||||| W5d} ~ XYnjX| dkr||||||nD|| 7}|| 7}|dkr | ||| | |j || |||||| dS)Nrzsocket is not connectedzos.sendfile call failed)r; remove_writer cancelled_sock_sendfile_update_fileposZ set_resultrwrBlockingIOErrorInterruptedError_sock_add_cancellation_callbackZ add_writerrr=rBZENOTCONNr~ConnectionError __cause__rrZ set_exceptionrarbrc)rrZ registered_fdrqr;rrr total_sentfdZsentrFnew_excrrrrras               z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt||tjdSNr)rwlseekSEEK_SET)rr;rrrrrrsz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcsfdd}||dS)Ncs&|r"}|dkr"|dS)Nr3)rr;r)rrrrqrrcbszB_UnixSelectorEventLoop._sock_add_cancellation_callback..cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname____doc__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sH -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrwrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rwreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrwrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc Cs4t|trt|}|sdS|js&|jrN|jtjkr|}d}td|Yn.X|dkrLdSt|}|jrlt d||z|j |\}}Wn.t k r|jrtjd|ddYnX|||f|dS)N8Unknown child process pid %d, will report returncode 255r$process %s exited with returncode %s'Child watcher got an unexpected pid: %rTr) rwwaitpidWNOHANGChildProcessErrorr rr$rrrr&poprJ)rr'rnr#rorDrErrrr(s4    zSafeChildWatcher._do_waitpid) rrrrr%rrr_rr)r(rrrr!rrs rcsTeZdZdZfddZfddZddZdd Zd d Zd d Z ddZ Z S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs$tt|_i|_d|_dSr)rr threadingZLock_lock_zombies_forksrr!rrrs  zFastChildWatcher.__init__cs"|j|jtdSr)r&r-r;rr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r:r<rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r:r<r;r?r-r r)rrrrZcollateral_victimsrrrrs  zFastChildWatcher.__exit__c Gsf|jFz|j|}Wn.tk rF||f|j|<YW5QRdSXW5QRX|||f|dSr)r:r;r8rJr&)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr.r/rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr3z8Caught subprocess termination from unknown pid: %d -> %d)rwr5r6r7r$r:r&r8rJr<r;rrr rr)rrnr#rorDrErrrr)<s@    z FastChildWatcher._do_waitpid_all) rrrrrr%rrr_rr)rrrr!rrs  rc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cCsi|_d|_dSr)r&_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r=rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r&r-r=r9 getsignalr+r,r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrrszMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr&r()rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr.r/rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..N)r(rFvaluesr)rthreadsrLrrrrGsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrr?rrrrszThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rHrJrrrrM sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rFrNr"r,)rrrOrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErI) rrAr9ZThreadr(nextrErFstart)rrnrDrErrLrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCszt|d\}}Wn(tk r<|}d}td|Yn Xt|}|r\td|||rttd||n|j |||f||j |dS)Nrr1r2r3rB) rwr5r7r rr$rrrCrmrFr8)rrr'rDrErnr#rorrrr("s& z ThreadedChildWatcher._do_waitpidN)rrrrrr\r%rGrrr*r+rr_rrr(rrrrrs  rcsHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr:rUrrOr9current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprUrOr9rVrWrrr!rrrZMs   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. N)rUrYrrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|j||_dS)z$Set the watcher for child processes.N)rUr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrYrZr[r[rrrr!rrT=s   rT)2rrBrrDrwrr9ryrr r&r9r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr$r%rrrrZBaseDefaultEventLoopPolicyrTrrrrrrs`             NO5Ji}Y3PK!q_I,__pycache__/unix_events.cpython-38.opt-2.pycnu[U ifۿ@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZdZe jdkredddZGdddejZGdddejZ Gdddej!ej"Z#Gdddej$Z%GdddZ&ddZ'Gdd d e&Z(Gd!d"d"e(Z)Gd#d$d$e(Z*Gd%d&d&e&Z+Gd'd(d(e&Z,Gd)d*d*ej-Z.eZ/e.Z0dS)+N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdSN)signumframerr8/opt/alt/python38/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZd(fdd ZfddZddZdd Zd d Zd d ZddZ d)ddZ d*ddZ d+ddZ ddZ d,dddddddZd-ddddddddZd d!Zd"d#Zd$d%Zd&d'ZZS)._UnixSelectorEventLoopNcst|i|_dSr)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)Nz3coroutines cannot be used with add_signal_handler()Fset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dSr)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)NFr5r6r3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)Nzsig must be an int, not zinvalid signal number ) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |r|dkr6tdn |dk r&td|dk r6td|dk r|dk rNtdt|}ttjtjd}z |d|||IdHWq|YqXn@|dkrtd|j tjks|j tjkrtd||d|j |||||d IdH\}}||fS) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rs) r<osfspathsocketAF_UNIX SOCK_STREAM setblockingZ sock_connectr%familytypeZ_create_connection_transport) rprotocol_factorypathrprqrrrs transportrUrrrcreate_unix_connectionsR      z-_UnixSelectorEventLoop.create_unix_connectiondT)rqbacklogrprs start_servingc st|trtd|dk r&|s&td|dk rH|dk r@tdt|}ttjtj}|ddkrz t t |j rt |WnBt k rYn0tk r}ztd||W5d}~XYnXz||Wnltk r0} z8|| jtjkrd|d} ttj| dnW5d} ~ XYn|YnXn<|dkrZtd |jtjksv|jtjkrtd ||d t||g||||} |r| tjd|d IdH| S) Nz*ssl argument must be an SSLContext or Nonertrur)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)loop)rOboolr7r<rwrxryrzr{statS_ISSOCKst_moderemoveFileNotFoundErrorr=r errorZbindr%rBZ EADDRINUSEr}r~r|rZServerZ_start_servingr sleep) rrrrqrrprsrerrrFmsgZserverrrrcreate_unix_serversn           z)_UnixSelectorEventLoop.create_unix_serverc sz tjWn,tk r6}ztdW5d}~XYnXz |}Wn2ttjfk rv}ztdW5d}~XYnXzt|j }Wn,t k r}ztdW5d}~XYnX|r|n|} | sdS| } | | d||||| d| IdHS)Nzos.sendfile() is not availableznot a regular filer) rwsendfileAttributeErrorrSendfileNotAvailableErrorr;ioUnsupportedOperationfstatst_sizer=r]_sock_sendfile_native_impl) rrqfileoffsetcountrFr;rZfsize blocksizefutrrr_sock_sendfile_nativeJs2    z,_UnixSelectorEventLoop._sock_sendfile_nativec Cs,|} |dk r|||r4||||dS|rd||}|dkrd||||||dSzt| |||} WnDttfk r|dkr| ||| | |j || |||||| Ynbt k rj} z|dk r| j t jkrt| tk rtdt j} | | _| } |dkrBtd} |||||| n|||||| W5d} ~ XYnttfk rYntk r} z|||||| W5d} ~ XYnjX| dkr||||||nD|| 7}|| 7}|dkr | ||| | |j || |||||| dS)Nrzsocket is not connectedzos.sendfile call failed)r; remove_writer cancelled_sock_sendfile_update_fileposZ set_resultrwrBlockingIOErrorInterruptedError_sock_add_cancellation_callbackZ add_writerrr=rBZENOTCONNr~ConnectionError __cause__rrZ set_exceptionrarbrc)rrZ registered_fdrqr;rrr total_sentfdZsentrFnew_excrrrrras               z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt||tjdSNr)rwlseekSEEK_SET)rr;rrrrrrsz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcsfdd}||dS)Ncs&|r"}|dkr"|dS)Nr3)rr;r)rrrrqrrcbszB_UnixSelectorEventLoop._sock_add_cancellation_callback..cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sF -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrwrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rwreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrwrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc Cs4t|trt|}|sdS|js&|jrN|jtjkr|}d}td|Yn.X|dkrLdSt|}|jrlt d||z|j |\}}Wn.t k r|jrtjd|ddYnX|||f|dS)N8Unknown child process pid %d, will report returncode 255r$process %s exited with returncode %s'Child watcher got an unexpected pid: %rTr) rwwaitpidWNOHANGChildProcessErrorr rr#rrrr%poprJ)rr&rnr"rorDrErrrr's4    zSafeChildWatcher._do_waitpid) rrrr%rrr_rr(r'rrrr!rrs rcsPeZdZfddZfddZddZddZd d Zd d Zd dZ Z S)rcs$tt|_i|_d|_dSr)rr threadingZLock_lock_zombies_forksrr!rrrs  zFastChildWatcher.__init__cs"|j|jtdSr)r%r-r:rr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r9r;rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r9r;r:r?r-r r)rrrrZcollateral_victimsrrrrs  zFastChildWatcher.__exit__c Gsf|jFz|j|}Wn.tk rF||f|j|<YW5QRdSXW5QRX|||f|dSr)r9r:r7rJr%)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr-r.rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr2z8Caught subprocess termination from unknown pid: %d -> %d)rwr4r5r6r#r9r%r7rJr;r:rrr rr)rrnr"rorDrErrrr(<s@    z FastChildWatcher._do_waitpid_all) rrrrr%rrr_rr(rrrr!rrs  rc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)rcCsi|_d|_dSr)r%_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r<rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r%r-r<r9 getsignalr*r+r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrrszMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr%r')rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr-r.rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..)r(rEvaluesr)rthreadsrKrrrrFsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrr>rrrrszThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rGrIrrrrL sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rErMr"r,)rrrNrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErH) rr@r8ZThreadr'nextrDrEstart)rrnrDrErrKrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCszt|d\}}Wn(tk r<|}d}td|Yn Xt|}|r\td|||rttd||n|j |||f||j |dS)Nrr0r1r2rA) rwr4r6r rr#rrrBrmrEr7)rrr&rDrErnr"rorrrr'"s& z ThreadedChildWatcher._do_waitpidN)rrrrr\r%rFrrr*r+rr_rrr'rrrrrs  rcsDeZdZeZfddZddZfddZddZd d Z Z S) _UnixDefaultEventLoopPolicycstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr9rTrrOr8current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dSr)rset_event_looprTrOr8rUrVrrr!rrrYMs   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jSr)rTrXrrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|j||_dSr)rTr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrZ _loop_factoryrrXrYr[rZrrrr!rrS=s    rS)1rBrrCrwrr9ryrr r&r8r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr#r$rrrrZBaseDefaultEventLoopPolicyrSrrrrrrs^             NO5Ji}Y3PK!lw$w$0__pycache__/base_subprocess.cpython-38.opt-1.pycnu[U if"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j fddZ ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} n|d} td| |j|j|| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolrr r r r r waiterZextrakwargsZprogram __class__ ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc s`zj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<|j j j D]\}}|j|f|qd_ WnZt t fk rYn`tk r<}z"|dk r,|s,||W5d}~XYn X|dk r\|s\|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&s@          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrU)r'cbr_r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rbrZpipe_connection_lost _try_finish)r'rJr`r.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rbrZpipe_data_received)r'rJr_r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCsp|jrtd||||_|jjdkr2||j_||jj | |j D]}| sN| |qNd|_ dS)Nz%r exited with return code %r)rr!rr8rr returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/_process_exiteds    z'BaseSubprocessTransport._process_exitedcs0|jdk r|jS|j}|j||IdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr3)r'r*r.r.r/_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jDr:d|_||jddS)Ncss|]}|dk o|jVqdSr:) disconnected).0pr.r.r/ sz6BaseSubprocessTransport._try_finish..T)rallrrArrb_call_connection_lostr>r.r.r/rcs z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'r`r.r.r/rns z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rir\rdrJrpr.r.r/ro sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r\r pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r\rresume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN) r2rqrrrrVr9rorxryr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r\rerJ)r'r_r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrsrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v PK!)cAA&__pycache__/tasks.cpython-38.opt-2.pycnu[U if@srdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZedjZdAd d ZdBd d ZdCddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejjZejj Z ejj!Z!dde!dddZ"ddZ#ddddZ$dd Z%d!d"Z&ddd#d$d%Z'ej(d&d'Z)dDddd(d)Z*ddd*d+Z+ej(d,d-Z,ee,_Gd.d/d/ej-Z.dd0d1d2d3Z/ddd4d5Z0d6d7Z1e 2Z3iZ4d8d9Z5d:d;Z6dd?Z8e5Z9e8Z:e6Z;e7Ze6Z?e7Z@dS)E)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|SN)rget_running_loop_current_tasksgetloopr"2/opt/alt/python38/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrcs&h|]}t|kr|s|qSr")r _get_loopdone.0tr r"r# <szall_tasks..)rrlist _all_tasks RuntimeErrorr!iZtasksr"r r#r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr$csh|]}t|kr|qSr")rr%r'r r"r#r*Usz$_all_tasks_compat..)rget_event_loopr+r,r-r.r"r r#_all_tasks_compat@s r1cCs4|dk r0z |j}Wntk r&Yn X||dSr)set_nameAttributeError)tasknamer2r"r"r#_set_task_nameXs  r6cseZdZdZed$ddZed%ddZdddfdd Zfd d Zd d Z ddZ ddZ ddZ ddZ ddZddddZdddddZddZd&fd d! Zd"d#ZZS)'rTNcCs(tjdtdd|dkr t}t|S)NzVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevel)warningswarnDeprecationWarningrr0rclsr!r"r"r#rtszTask.current_taskcCstjdtddt|S)NzPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r1r=r"r"r#rs zTask.all_tasks)r!r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)Nr Fza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror!r5 __class__r"r#rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr"r#rXs  z Task.__del__cCs t|Sr)rZ_task_repr_inforSr"r"r# _repr_infoszTask._repr_infocCs|jSr)rMrYr"r"r#get_corosz Task.get_corocCs|jSr)rIrYr"r"r#get_namesz Task.get_namecCst||_dSr)rJrI)rSvaluer"r"r#r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr-)rSresultr"r"r# set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr"r"r# set_exceptionszTask.set_exception)limitcCs t||Sr)rZ_task_get_stack)rSrcr"r"r# get_stackszTask.get_stack)rcfilecCst|||Sr)rZ_task_print_stack)rSrcrer"r"r# print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dSNFT)Z_log_tracebackr&rLcancelrKrYr"r"r#rhs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r&rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrhr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr%r-rQrRrOriadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr"r#Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr)r_rqrR)rSfuturervr"r"r#Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrhrRrt __classcell__r"r"rUr#rbs$    !Tr)r5cCs t}||}t|||Sr)rrrr6)rTr5r!r4r"r"r#rxs  r)r!timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfddt|D}t|||IdHS) Nzexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: [The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSr r r(fr r"r#r*szwait..)risfuturerrErGtypery ValueErrorrrrrrr:r;r<set_wait)fsr!r~rr"r r#rs rcGs|s|ddSr)r&r`)waiterargsr"r"r#_release_waitersrr c s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)Nrr7r8rr )rrr:r;r<r r&r__cancel_and_waitrrk TimeoutError create_future call_laterr functoolspartialrsrhremove_done_callback)futr~r!rvrtimeout_handlecbr"r"r#rsL              rc s|d|dk r"||tt|fdd}|D]}||q@zIdHW5dk rp|D]}||qtXtt}}|D]"}|r| |q| |q||fS)NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrarhr&r`rZcounterrrrr"r#_on_completions z_wait.._on_completion) rrrlenrsrhrrr&add)rr~rr!rrr&Zpendingr"rr#rs(    rc sF|}tt|}||z||IdHW5||XdSr)rrrrrsrrh)rr!rrr"r"r#r&s  r)r!r~c#st|st|r(tdt|jddlm}|ddkrPt nt j dt ddfdd t|Ddfd d }fd d fdd}D]}|qr|dk r҈||ttD] }|VqdS)Nz#expect an iterable of futures, not r)Queuer rr7r8csh|]}t|dqSrrrr r"r#r*Uszas_completed..cs*D]}|dqdSr)r put_nowaitclearr)rr&todor"r# _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr)removerrhr)r&rrr"r#r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr)rrrr_r)r&r"r# _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrryZqueuesrrr0r:r;r<rrsrranger)rr!r~rrrr_r")rr&r!rrr#r7s*       rccs dVdSrr"r"r"r"r#__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)Nrrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrh)Zdelayr_r!rxhr"r"r#r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)Nr?zRThe future belongs to a different loop than the one specified as the loop argumentr z:An asyncio.Future, a coroutine or an awaitable is required)rrErr0rrDrrr%rruZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer!r4r"r"r#r s    r ccs|EdHSr) __await__)Z awaitabler"r"r#rsrcs*eZdZddfdd ZddZZS)_GatheringFutureNr cstj|d||_d|_dS)Nr F)rBrC _children_cancel_requested)rSchildrenr!rUr"r#rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|Srg)r&rrhr)rSZretZchildr"r"r#rhs z_GatheringFuture.cancel)ryrzr{rCrhr}r"r"rUr#rsrF)r!return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd|_ d 7|||<| |n||} |qdt |dS) Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r&rrarrkrbr_appendrr`)rrvZresultsresrZ nfinishedZnfutsouterrr"r#_done_callbacks4    zgather.._done_callbackrr Fr)rr0r:r;r<rr`r rr%rFrsrr)r!rZcoros_or_futuresrZ arg_to_futargrr"rr#r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd}|S) Nrr7r8r cs\r|s|dS|r.n*|}|dk rJ|n|dSr)rrarhrbr`r_)innerrvrr"r#_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr)r&rr)rrr"r#_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r&rr%rrs)rr!rr")rrrr#r Ps     r cs:tstdtjfdd}|S)NzA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr )rZ _chain_futurer rprorqZset_running_or_notify_cancelrb)rvrTrxr!r"r#callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr!rr"rr#r s    r cCst|dSr)r,rr4r"r"r#rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr-r!r4rr"r"r#rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr"r"r#rs rcCst|dSr)r,discardrr"r"r#rsr)rrrrr,r)N)N)N)N)A__all__Zconcurrent.futuresrrNrru itertoolstypesr:weakrefrrrrrrcount__next__rHrrr1r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr,rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr"r"r"r#s                #H,>  x?$PK!c1mm!__pycache__/events.cpython-38.pycnu[U if4f@s|dZdZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z GdddZ Gd d d e Z Gd d d Z Gd ddZGdddZGdddeZdaeZGdddejZeZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Z d)d*Z!eZ"eZ#eZ$eZ%zdd+l&mZmZmZmZWne'k rfYnXeZ(eZ)eZ*eZ+dS),z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpers) exceptionsc@sFeZdZdZdZdddZddZdd Zd d Zd d Z ddZ dS)rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|dkrt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr&3/opt/alt/python38/lib64/python3.8/asyncio/events.py__init__ s zHandle.__init__cCsl|jjg}|jr|d|jdk r:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r!infoframer&r&r' _repr_info/s    zHandle._repr_infocCs(|jdk r|jS|}dd|S)Nz<{}> )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname____doc__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcseZdZdZddgZdfdd ZfddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ fddZddZZS)rz7Object returned by timed callback registration methods. _scheduled_whenNcs<|dk s tt|||||jr,|jd=||_d|_dS)Nr*F)AssertionErrorsuperr(rrLrK)r!whenr"r#r$r%r,r&r'r(hs  zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rNr2rinsertrL)r!r0posrPr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrLr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rLr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rL__eq__rWr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rVrWr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rZrWr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrLrrrNotImplementedrWr&r&r'r[s     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)r[r`)r!rXZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrNr:r9rPr&r'r:s zTimerHandle.cancelcCs|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). rVr9r&r&r'rOszTimerHandle.when)N)r-rGrHrIrJr(r2rUrYr\r]r^r[rar:rO __classcell__r&r&rPr'rcs  rc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rz,Abstract server returned by create_server().cCstdS)z5Stop serving. This leaves existing connections open.NNotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdS)z4Get the event loop the Server object is attached to.Nrdr9r&r&r'get_loopszAbstractServer.get_loopcCstdS)z3Return True if the server is accepting connections.Nrdr9r&r&r' is_servingszAbstractServer.is_servingcstdS)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. Nrdr9r&r&r' start_servingszAbstractServer.start_servingcstdS)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. Nrdr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdS)z*Coroutine to wait until service is closed.Nrdr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rfrk)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrIrfrgrhrirjrkrlrmr&r&r&r'rsrc @sVeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddddZd d!Zd"d#Zd$d%Zd&d&d&d&d'd(d)Zdud*d+Zdvdd&d&d&ddddddd, d-d.Zdwejejdd/ddddd0d1 d2d3Zdxd0d4d5d6Zd7ddd8d9d:Zdyddddd;dd?d@Zd{d&d&d&dddddAdBdCZ dDdEZ!dFdGZ"e#j$e#j$e#j$dHdIdJZ%e#j$e#j$e#j$dHdKdLZ&dMdNZ'dOdPZ(dQdRZ)dSdTZ*dUdVZ+dWdXZ,dYdZZ-d[d\Z.d]d^Z/d|dd4d_d`Z0dadbZ1dcddZ2dedfZ3dgdhZ4didjZ5dkdlZ6dmdnZ7dodpZ8dqdrZ9dsdtZ:dS)}rzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.Nrdr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. Nrd)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. Nrdr9r&r&r'stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.Nrdr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.Nrdr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. Nrdr9r&r&r'rfs zAbstractEventLoop.closecstdS)z,Shutdown all active asynchronous generators.Nrdr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.Nrd)r!r=r&r&r'rbsz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rd)r!Zdelayr"r#r&r&r'rtszAbstractEventLoop.call_latercGstdSr;rd)r!rOr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rdr9r&r&r'time szAbstractEventLoop.timecCstdSr;rdr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rd)r!cororzr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rdrur&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rd)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rd)r!r~r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rd)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rd)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rd)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrric stdS)adA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrd) r!rrrrrrrrrrrrir&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdS)zRSend a file through a transport. Return an amount of sent bytes. Nrd)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdS)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. Nrd)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rd)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrricstdS)aA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrd)r!rrrrrrrir&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. Nrd) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.Nrdr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.Nrdrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rd)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rd)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rdr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rdr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rdrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rdrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rd)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rd)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rd)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rd)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rd)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rd)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rd)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rd)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rd)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rdr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rdr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rd)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rdr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rdrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rdr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rd)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrnrorprqrrrfrsrbrvrtrwrxryr|r}rrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.Nrdr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.Nrdr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.Nrdr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.Nrdr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.Nrd)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN) r-rGrHrIrr r r r r&r&r&r'r<s  rc@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nz,There is no current event loop in thread %r.) rrrr_ threadingZcurrent_threadZ _MainThreadr r RuntimeErrorrzr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|tst||j_dS)zSet the event loop.TN)rrr_rrMrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrIrrlocalrr(rr r r&r&r&r'r^s rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr&r&r&r'rsrcCs|dkst|tst|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r_rrMr)Zpolicyr&r&r'rsrcCst}|dk r|StS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr&r&r'rs rcCst|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rr&r&r'r sr cCs tS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r&r&r&r'r sr cCs tS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r&r&r&r'r sr cCs t|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr&r&r'r sr )rr rr),rI__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sX   J@*q"9    PK!+W++(__pycache__/futures.cpython-38.opt-1.pycnu[U ifb3@sdZdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ej Z ej Z ejZejZejdZGd d d ZeZd d Zd dZddZddZddZddZddddZz ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZd d Zed d Zejd d ZddZddZddZddZddZddZddZddddZdd Zd!d"Zd#d$Zd%d&Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r/r1rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r/r1rr:r;r<r#r$rrrrr!s    zFuture.exceptionr4cCsB|jtkr|jj|||dn |dkr.t}|j||fdS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. r4N)r/r0r r5 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs g|]\}}|kr||fqSrr).0fr7rArr sz/Future.remove_done_callback..N)rlen)rrAZfiltered_callbacksZ removed_countrrErremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r/r0rr<r=r;r2)rr>rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN) r/r0rr< isinstancetype StopIteration TypeErrorr$r;r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r9_asyncio_future_blockingr-r>rrrr __await__s zFuture.__await__)"r __module__ __qualname____doc__r0r/r=r$r rrPr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r8r9r>r!rBrHrJrOrQ__iter__rrrrrs:    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rL concurrentfuturesr:rargs TimeoutErrorr<)r%Z exc_classrrr_convert_future_exc#s      r`cCsR|r||sdS|}|dk r<|t|n|}||dS)z8Copy state from a future to a concurrent.futures.Future.N)r8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\sourcer!r>rrr_set_concurrent_future_state/srbcCsT|r dS|r|n2|}|dk r>|t|n|}||dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r8r3r!rOr`r>rJ)radestr!r>rrr_copy_future_state>s rdcststtjjstdts._set_statecs2|r.dkskr"n jdSr()r8r3call_soon_threadsafe) destination) dest_loopra source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r8Z is_closedrg)ra)rfrirhrjrr_call_set_stateos z&_chain_future.._call_set_state)rrKr\r]rrNrZrB)rarhrkrlr)rfrirhrarjr _chain_futureRs   rmr cCs2t|r |S|dkrt}|}t|||S)z&Wrap concurrent.futures.Future object.N)rrr Z create_futurerm)r"r Z new_futurerrrr|s r)rT__all__Zconcurrent.futuresr\r?Zloggingrrrrr rr0r1r;DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rbrdrmrZ_asyncio ImportErrorZ_CFuturerrrrs:     q  *  PK!E2!2!!__pycache__/trsock.cpython-38.pycnu[U if@s"ddlZddlZGdddZdS)Nc@seZdZdZdZejdddZddZedd Z ed d Z ed d Z ddZ ddZ ddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(dHdIZ)dJdKZ*dLdMZ+dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d\S)]TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _sock)sockcCs ||_dSNr)selfrr3/opt/alt/python38/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rsb   r)rr rrrrr sPK!Tt22.__pycache__/windows_utils.cpython-38.opt-1.pycnu[U if@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr:/opt/alt/python38/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname____doc__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc sxd}}}d} } } |tkr@tddd\} } t| tj}n|}|tkrhtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d|Wn0| | | fD]}|dk rt |qւYn>X| dk r t | |_ | dk rt | |_| dk r2t | |_W5|tkrJt||tkr^t||tkrrt|XdS)N)FTT)rr)TFr r)stdinstdoutstderr)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr7r8r9)rargsr7r8r9kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsN              zPopen.__init__)NNN)r#r1r2r3r __classcell__rrrArr}sr)r3sysplatform ImportErrorr itertoolsr:r subprocessr r5__all__ZBUFSIZErr<countrrrrrrrrs$ 1,PK!O5&5&&__pycache__/locks.cpython-38.opt-2.pycnu[U if|C@sdZddlZddlZddlZddlmZddlmZddlmZddlmZGdd d Z Gd d d Z Gd d d e Z GdddZ Gddde Z Gddde ZGdddeZdS))LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s$eZdZddZddZddZdS)_ContextManagercCs ||_dSN)_lock)selflockr2/opt/alt/python38/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r%r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadrr )r"r#r$!_ContextManagerMixin__acquire_ctx __await__rrrrr(Ys z_ContextManagerMixin.__await__cs|IdHdSr )r%rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner&r Z _is_coroutiner'r(r)r-rrrrr1s rcsJeZdZddddZfddZddZd d Zd d Zd dZZ S)rNloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.rr )_waiters_lockedrget_event_loop_loopr"r#r$rr1rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r5r4lenrresZextra __class__rrrAs  z Lock.__repr__cCs|jSr )r5rrrrr:sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r5r4all collectionsdequer7 create_futureappendremover CancelledError_wake_up_firstrfutrrrr%s&    z Lock.acquirecCs"|jrd|_|ntddS)NFzLock is not acquired.)r5rRrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddSNT)r4nextiter StopIterationdone set_resultrSrrrrRszLock._wake_up_first) rrrrrAr:r%rrR __classcell__rrrErrjs 6  rcsJeZdZddddZfddZddZd d Zd d Zd dZZ S)rNr0cCs>t|_d|_|dkr$t|_n||_tjdt dddSr2) rLrMr4_valuerr6r7r"r#r$r8rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr;r<rr=r>r?)r@rAr\r4rBrCrErrrA s  zEvent.__repr__cCs|jSr r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdSrU)r\r4rYrZrSrrrr]s  z Event.setcCs d|_dS)NFr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdSrU)r\r7rNr4rOrPrSrrrwait(s   z Event.wait) rrrrrAr_r]r`rar[rrrErrs    rcsNeZdZdddddZfddZddZd d Zdd d ZddZZ S)rNr0cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr3rr r0z"loop argument must agree with lock)rr6r7r"r#r$r ValueErrorrr:r%rrLrMr4)rrr1rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr9)r@rAr:r4rBrCrErrrA[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)Nzcannot wait on un-acquired lockFT) r:rrr%r rQr7rNr4rOrP)rrGrTrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|Sr )ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)Nz!cannot notify on un-acquired lockrrF)r:rr4rYrZ)rnidxrTrrrnotifys  zCondition.notifycCs|t|jdSr )rgrBr4rrrr notify_allszCondition.notify_all)N)r) rrrrrArardrgrhr[rrrErr;s   % rcsLeZdZdddddZfddZdd Zd d Zd d ZddZZ S)rrNr0cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r3rr ) rbr\rLrMr4rr6r7r"r#r$rvaluer1rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr:zunlocked, value:r;r<rr=r>r?)r@rAr:r\r4rBrCrErrrAs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r4popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)Nrr^rrrrr:szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)NrrT)r\r7rNr4rOZcancelrGrlrSrrrr%s    zSemaphore.acquirecCs|jd7_|dS)Nr)r\rlrrrrrszSemaphore.release)r) rrrrrArlr:r%rr[rrrErrs  rcs0eZdZdddfdd ZfddZZS) rrNr0cs.|rtjdtdd||_tj||ddS)Nr3rr r0)r"r#r$ _bound_valuer@rrirErrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbr@rrrErrrs zBoundedSemaphore.release)r)rrrrrr[rrrErrs r)__all__rLr.r"rr r r r rrrrrrrrrrs    "9DzNPK!|  %__pycache__/coroutines.cpython-38.pycnu[U if]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr7/opt/alt/python38/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCsZt|st|st|||_||_tt d|_ t |dd|_ t |dd|_ dS)Nr__name__ __qualname__)inspect isgeneratorrAssertionErrorgenfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r! coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrr!rrr__iter__7szCoroWrapper.__iter__cCs |jdSr-rsendr.rrr__next__:szCoroWrapper.__next__cCs |j|Sr-r0)r!valuerrrr1=szCoroWrapper.sendcCs|j|||Sr-)rthrow)r!typer3 tracebackrrrr4@szCoroWrapper.throwcCs |jSr-)rcloser.rrrr7CszCoroWrapper.closecCs|jjSr-)rgi_framer.rrrr8FszCoroWrapper.gi_framecCs|jjSr-)r gi_runningr.rrrr9JszCoroWrapper.gi_runningcCs|jjSr-)rgi_coder.rrrr:NszCoroWrapper.gi_codecCs|Sr-rr.rrr __await__RszCoroWrapper.__await__cCs|jjSr-)r gi_yieldfromr.rrrr<UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr8r#z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) r f_lastijoinr6 format_listrZDEBUG_STACK_DEPTHrstripr error)r!rr+msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rr"r,r/r2r1r4r7propertyr8r9r:r;r<rErrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr-) rZisfuturerr isinstancerr;AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrRr#rr)rrr rr)rOkwdswrSrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrWrrVrris"    rcCst|pt|ddtkS)z6Return True if func is a decorated coroutine function.r`N)rrr r`rRrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)z)Return True if obj is a coroutine object.TdFN)r5_iscoroutine_typecacherJ_COROUTINE_TYPESlenadd)objrrrrs   rc stt|s tt|tfdd}dd}d}t|drF|jrF|j}nt|dr\|jr\|j}||}|s~||rz|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|j pd }d }r0|j dk r0t |j s0t |j }|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rV|j}|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr%z without __name__>z())rZ_format_callbackrhasattrrrr5)rS coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrKr9)rSrrr is_runnings z%_format_coroutine..is_runningcr_coder:z runningr8cr_framezrz done, defined at r$z running, defined at z running at )rrrJrrgrmr:r8rn co_filenamerrr[rZ_get_function_sourcef_linenoco_firstlineno) rSrjrlZ coro_coderhZ coro_framefilenamelinenosourcer*rrirr(sL          r() __all__Zcollections.abcrLr\rrr r6r^rXr=rrrlogr rr_rrobjectr`r CoroutineType GeneratorTyperM Coroutinercsetrbrr(rrrrs2    E8PK!Zy y )__pycache__/__main__.cpython-38.opt-1.pycnu[U if3 @sXddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrTed eZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez e Wn8e!k rJtr@t"s@t#d aYqYnXqTqdS)N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__5/opt/alt/python38/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__zcpython.run_stdinasyncio>r$__file__ __package__ __builtins__ __loader____spec__FT)$r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$auditZnew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsH 6       PK!v* * *__pycache__/protocols.cpython-38.opt-2.pycnu[U if@s^dZGdddZGdddeZGdddeZGdddeZGd d d eZd d Zd S)) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s0eZdZdZddZddZddZdd Zd S) rcCsdSNr)selfZ transportrr6/opt/alt/python38/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdSrrrexcrrr connection_lostszBaseProtocol.connection_lostcCsdSrrrrrr pause_writing%szBaseProtocol.pause_writingcCsdSrrrrrr resume_writing;szBaseProtocol.resume_writingN)__name__ __module__ __qualname__ __slots__r r rrrrrr r s  rc@s eZdZdZddZddZdS)rrcCsdSrr)rdatarrr data_received^szProtocol.data_receivedcCsdSrrrrrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrr rBsrc@s(eZdZdZddZddZddZdS) rrcCsdSrr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdSrr)rnbytesrrr buffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrrrrr rszBufferedProtocol.eof_receivedN)rrrrrrrrrrr rms rc@s eZdZdZddZddZdS)rrcCsdSrr)rrZaddrrrr datagram_receivedsz"DatagramProtocol.datagram_receivedcCsdSrrr rrr error_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrr rsrc@s(eZdZdZddZddZddZdS) rrcCsdSrr)rfdrrrr pipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdSrr)rrr rrr pipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdSrrrrrr process_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!rrrr rsrcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr _feed_data_to_buffered_protos     r%N)__all__rrrrrr%rrrr s 9+9PK!#__pycache__/__init__.cpython-38.pycnu[U if@sdZddlZddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddl mZejejejejejejeje je je je je jejZejdkrddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N)*)_all_tasks_compatZwin32)__doc__sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r 5/opt/alt/python38/lib64/python3.8/asyncio/__init__.pysZ       PK!r !__pycache__/queues.cpython-38.pycnu[U if @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N__name__ __module__ __qualname____doc__rr3/opt/alt/python38/lib64/python3.8/asyncio/queues.pyr src@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrsrc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS)*raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer"r#rrrr!6sz Queue._initcCs |jSr%)r&popleftr"rrr_get9sz Queue._getcCs|j|dSr%r&appendr"itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr%)r(ZdoneZ set_result)r"waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr)rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr2r3r4)r5r r7r)rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r&z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr&rlenrr)r"resultrrrr7Os  z Queue._formatcCs t|jS)zNumber of items in the queue.)r=r&r)rrrqsize[sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.r&r)rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr?r)rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rBr create_futurerr,cancelremove ValueError cancelledr1 put_nowait)r"r.Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)rBrr/rrclearr1rr-rrrrHs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| S)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rArrCrr,rDrErFrGr1 get_nowait)r"getterrrrgets    z Queue.getcCs$|r t|}||j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rArr*r1rr-rrrrKs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rrFrr r)rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwaitr)rrrjoins z Queue.join)r)r r r rr$r!r*r/r1r8r9r7r?propertyr#rArBrIrHrMrKrNrPrrrrrs(      rc@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dSr%r@r'rrrr!szPriorityQueue._initcCs||j|dSr%r@)r"r.heappushrrrr/szPriorityQueue._putcCs ||jSr%r@)r"heappoprrrr*szPriorityQueue._getN) r r r rr!heapqrRr/rSr*rrrrrsrc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dSr%r@r'rrrr!szLifoQueue._initcCs|j|dSr%r+r-rrrr/szLifoQueue._putcCs |jSr%)r&popr)rrrr*szLifoQueue._getN)r r r rr!r/r*rrrrrsr) __all__rrTrrr Exceptionrrrrrrrrrs  KPK!Zy y )__pycache__/__main__.cpython-38.opt-2.pycnu[U if3 @sXddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrTed eZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez e Wn8e!k rJtr@t"s@t#d aYqYnXqTqdS)N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__5/opt/alt/python38/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__zcpython.run_stdinasyncio>r$__file__ __package__ __builtins__ __loader____spec__FT)$r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$auditZnew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsH 6       PK!D+__pycache__/coroutines.cpython-38.opt-2.pycnu[U if]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr7/opt/alt/python38/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCs>||_||_ttd|_t|dd|_t|dd|_ dS)Nr__name__ __qualname__) genfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrrrrr__iter__7szCoroWrapper.__iter__cCs |jdSr*rsendr+rrr__next__:szCoroWrapper.__next__cCs |j|Sr*r-)rvaluerrrr.=szCoroWrapper.sendcCs|j|||Sr*)rthrow)rtyper0 tracebackrrrr1@szCoroWrapper.throwcCs |jSr*)rcloser+rrrr4CszCoroWrapper.closecCs|jjSr*)rgi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)rgi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr __await__RszCoroWrapper.__await__cCs|jjSr*)r gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr5r z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) rf_lastijoinr3 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr(msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rrr)r,r/r.r1r4propertyr5r6r7r8r9rBrrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)NzN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr*) rZisfutureinspectZ isgenerator isinstancerr8AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrPr rr)rrrrr)rMkwdswrQrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrGrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrUrrTrris"    rcCst|pt|ddtkS)Nr^)rGrrr^rPrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)NTdF)r2_iscoroutine_typecacherH_COROUTINE_TYPESlenadd)objrrrrs   rc sht|tfdd}dd}d}t|dr:|jr:|j}nt|drP|jrP|j}||}|sr||rn|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|jpd }d }r$|jdk r$t |js$t |j}|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rJ|j }|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr"z without __name__>z())rZ_format_callbackrhasattrrrr2)rQ coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrIr6)rQrrr is_runnings z%_format_coroutine..is_runningcr_coder7z runningr5cr_framezrz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl co_filenamerrGrYrZ_get_function_sourcef_linenoco_firstlineno) rQrhrjZ coro_coderfZ coro_framefilenamelinenosourcer'rrgrr%sJ         r%) __all__Zcollections.abcrJrZrGrr r3r\rVr:rrrlogr rr]rrobjectr^r CoroutineType GeneratorTyperK Coroutinerasetr`rr%rrrrs2    E8PK!Zd d format_helpers.pynu[import functools import inspect import reprlib import sys import traceback from . import constants def _get_function_source(func): func = inspect.unwrap(func) if inspect.isfunction(func): code = func.__code__ return (code.co_filename, code.co_firstlineno) if isinstance(func, functools.partial): return _get_function_source(func.func) if isinstance(func, functools.partialmethod): return _get_function_source(func.func) return None def _format_callback_source(func, args): func_repr = _format_callback(func, args, None) source = _get_function_source(func) if source: func_repr += f' at {source[0]}:{source[1]}' return func_repr def _format_args_and_kwargs(args, kwargs): """Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). """ # use reprlib to limit the length of the output items = [] if args: items.extend(reprlib.repr(arg) for arg in args) if kwargs: items.extend(f'{k}={reprlib.repr(v)}' for k, v in kwargs.items()) return '({})'.format(', '.join(items)) def _format_callback(func, args, kwargs, suffix=''): if isinstance(func, functools.partial): suffix = _format_args_and_kwargs(args, kwargs) + suffix return _format_callback(func.func, func.args, func.keywords, suffix) if hasattr(func, '__qualname__') and func.__qualname__: func_repr = func.__qualname__ elif hasattr(func, '__name__') and func.__name__: func_repr = func.__name__ else: func_repr = repr(func) func_repr += _format_args_and_kwargs(args, kwargs) if suffix: func_repr += suffix return func_repr def extract_stack(f=None, limit=None): """Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. """ if f is None: f = sys._getframe().f_back if limit is None: # Limit the amount of work to a reasonable amount, as extract_stack() # can be called for each coroutine and future in debug mode. limit = constants.DEBUG_STACK_DEPTH stack = traceback.StackSummary.extract(traceback.walk_stack(f), limit=limit, lookup_lines=False) stack.reverse() return stack PK!7ƺ unix_events.pynu["""Selector event loop for Unix with signal handling.""" import errno import os import signal import socket import stat import subprocess import sys import threading import warnings from . import base_events from . import base_subprocess from . import compat from . import constants from . import coroutines from . import events from . import futures from . import selector_events from . import selectors from . import transports from .coroutines import coroutine from .log import logger __all__ = ['SelectorEventLoop', 'AbstractChildWatcher', 'SafeChildWatcher', 'FastChildWatcher', 'DefaultEventLoopPolicy', ] if sys.platform == 'win32': # pragma: no cover raise ImportError('Signals are not really supported on Windows') def _sighandler_noop(signum, frame): """Dummy signal handler.""" pass try: _fspath = os.fspath except AttributeError: # Python 3.5 or earlier _fspath = lambda path: path class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Unix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. """ def __init__(self, selector=None): super().__init__(selector) self._signal_handlers = {} def _socketpair(self): return socket.socketpair() def close(self): super().close() for sig in list(self._signal_handlers): self.remove_signal_handler(sig) def _process_self_data(self, data): for signum in data: if not signum: # ignore null bytes written by _write_to_self() continue self._handle_signal(signum) def add_signal_handler(self, sig, callback, *args): """Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError("coroutines cannot be used " "with add_signal_handler()") self._check_signal(sig) self._check_closed() try: # set_wakeup_fd() raises ValueError if this is not the # main thread. By calling it early we ensure that an # event loop running in another thread cannot add a signal # handler. signal.set_wakeup_fd(self._csock.fileno()) except (ValueError, OSError) as exc: raise RuntimeError(str(exc)) handle = events.Handle(callback, args, self) self._signal_handlers[sig] = handle try: # Register a dummy signal handler to ask Python to write the signal # number in the wakup file descriptor. _process_self_data() will # read signal numbers from this file descriptor to handle signals. signal.signal(sig, _sighandler_noop) # Set SA_RESTART to limit EINTR occurrences. signal.siginterrupt(sig, False) except OSError as exc: del self._signal_handlers[sig] if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as nexc: logger.info('set_wakeup_fd(-1) failed: %s', nexc) if exc.errno == errno.EINVAL: raise RuntimeError('sig {} cannot be caught'.format(sig)) else: raise def _handle_signal(self, sig): """Internal helper that is the actual signal handler.""" handle = self._signal_handlers.get(sig) if handle is None: return # Assume it's some race condition. if handle._cancelled: self.remove_signal_handler(sig) # Remove it properly. else: self._add_callback_signalsafe(handle) def remove_signal_handler(self, sig): """Remove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. """ self._check_signal(sig) try: del self._signal_handlers[sig] except KeyError: return False if sig == signal.SIGINT: handler = signal.default_int_handler else: handler = signal.SIG_DFL try: signal.signal(sig, handler) except OSError as exc: if exc.errno == errno.EINVAL: raise RuntimeError('sig {} cannot be caught'.format(sig)) else: raise if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as exc: logger.info('set_wakeup_fd(-1) failed: %s', exc) return True def _check_signal(self, sig): """Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if not isinstance(sig, int): raise TypeError('sig must be an int, not {!r}'.format(sig)) if not (1 <= sig < signal.NSIG): raise ValueError( 'sig {} out of range(1, {})'.format(sig, signal.NSIG)) def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixReadPipeTransport(self, pipe, protocol, waiter, extra) def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixWritePipeTransport(self, pipe, protocol, waiter, extra) @coroutine def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): with events.get_child_watcher() as watcher: waiter = self.create_future() transp = _UnixSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) watcher.add_child_handler(transp.get_pid(), self._child_watcher_callback, transp) try: yield from waiter except Exception as exc: # Workaround CPython bug #23353: using yield/yield-from in an # except block of a generator doesn't clear properly # sys.exc_info() err = exc else: err = None if err is not None: transp.close() yield from transp._wait() raise err return transp def _child_watcher_callback(self, pid, returncode, transp): self.call_soon_threadsafe(transp._process_exited, returncode) @coroutine def create_unix_connection(self, protocol_factory, path, *, ssl=None, sock=None, server_hostname=None): assert server_hostname is None or isinstance(server_hostname, str) if ssl: if server_hostname is None: raise ValueError( 'you have to pass server_hostname when using ssl') else: if server_hostname is not None: raise ValueError('server_hostname is only meaningful with ssl') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) try: sock.setblocking(False) yield from self.sock_connect(sock, path) except: sock.close() raise else: if sock is None: raise ValueError('no path and sock were specified') if (sock.family != socket.AF_UNIX or not base_events._is_stream_socket(sock)): raise ValueError( 'A UNIX Domain Stream Socket was expected, got {!r}' .format(sock)) sock.setblocking(False) transport, protocol = yield from self._create_connection_transport( sock, protocol_factory, ssl, server_hostname) return transport, protocol @coroutine def create_unix_server(self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None): if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') path = _fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # Check for abstract socket. `str` and `bytes` paths are supported. if path[0] not in (0, '\x00'): try: if stat.S_ISSOCK(os.stat(path).st_mode): os.remove(path) except FileNotFoundError: pass except OSError as err: # Directory may have permissions only to create socket. logger.error('Unable to check or remove stale UNIX socket %r: %r', path, err) try: sock.bind(path) except OSError as exc: sock.close() if exc.errno == errno.EADDRINUSE: # Let's improve the error message by adding # with what exact address it occurs. msg = 'Address {!r} is already in use'.format(path) raise OSError(errno.EADDRINUSE, msg) from None else: raise except: sock.close() raise else: if sock is None: raise ValueError( 'path was not specified, and no sock specified') if (sock.family != socket.AF_UNIX or not base_events._is_stream_socket(sock)): raise ValueError( 'A UNIX Domain Stream Socket was expected, got {!r}' .format(sock)) server = base_events.Server(self, [sock]) sock.listen(backlog) sock.setblocking(False) self._start_serving(protocol_factory, sock, ssl, server) return server if hasattr(os, 'set_blocking'): def _set_nonblocking(fd): os.set_blocking(fd, False) else: import fcntl def _set_nonblocking(fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) class _UnixReadPipeTransport(transports.ReadTransport): max_size = 256 * 1024 # max bytes we read in one event loop iteration def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra) self._extra['pipe'] = pipe self._loop = loop self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._closing = False mode = os.fstat(self._fileno).st_mode if not (stat.S_ISFIFO(mode) or stat.S_ISSOCK(mode) or stat.S_ISCHR(mode)): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is for pipes/sockets only.") _set_nonblocking(self._fileno) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append('fd=%s' % self._fileno) selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_READ) if polling: info.append('polling') else: info.append('idle') elif self._pipe is not None: info.append('open') else: info.append('closed') return '<%s>' % ' '.join(info) def _read_ready(self): try: data = os.read(self._fileno, self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') else: if data: self._protocol.data_received(data) else: if self._loop.get_debug(): logger.info("%r was closed by peer", self) self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._protocol.eof_received) self._loop.call_soon(self._call_connection_lost, None) def pause_reading(self): self._loop._remove_reader(self._fileno) def resume_reading(self): self._loop._add_reader(self._fileno, self._read_ready) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if not self._closing: self._close(None) # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if self._pipe is not None: warnings.warn("unclosed transport %r" % self, ResourceWarning) self._pipe.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc): self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None class _UnixWritePipeTransport(transports._FlowControlMixin, transports.WriteTransport): def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra, loop) self._extra['pipe'] = pipe self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._buffer = bytearray() self._conn_lost = 0 self._closing = False # Set when close() or write_eof() called. mode = os.fstat(self._fileno).st_mode is_char = stat.S_ISCHR(mode) is_fifo = stat.S_ISFIFO(mode) is_socket = stat.S_ISSOCK(mode) if not (is_char or is_fifo or is_socket): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is only for " "pipes, sockets and character devices") _set_nonblocking(self._fileno) self._loop.call_soon(self._protocol.connection_made, self) # On AIX, the reader trick (to be notified when the read end of the # socket is closed) only works for sockets. On other platforms it # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.) if is_socket or (is_fifo and not sys.platform.startswith("aix")): # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append('fd=%s' % self._fileno) selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_WRITE) if polling: info.append('polling') else: info.append('idle') bufsize = self.get_write_buffer_size() info.append('bufsize=%s' % bufsize) elif self._pipe is not None: info.append('open') else: info.append('closed') return '<%s>' % ' '.join(info) def get_write_buffer_size(self): return len(self._buffer) def _read_ready(self): # Pipe was closed by peer. if self._loop.get_debug(): logger.info("%r was closed by peer", self) if self._buffer: self._close(BrokenPipeError()) else: self._close() def write(self, data): assert isinstance(data, (bytes, bytearray, memoryview)), repr(data) if isinstance(data, bytearray): data = memoryview(data) if not data: return if self._conn_lost or self._closing: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('pipe closed by peer or ' 'os.write(pipe, data) raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: n = os.write(self._fileno, data) except (BlockingIOError, InterruptedError): n = 0 except Exception as exc: self._conn_lost += 1 self._fatal_error(exc, 'Fatal write error on pipe transport') return if n == len(data): return elif n > 0: data = memoryview(data)[n:] self._loop._add_writer(self._fileno, self._write_ready) self._buffer += data self._maybe_pause_protocol() def _write_ready(self): assert self._buffer, 'Data should not be empty' try: n = os.write(self._fileno, self._buffer) except (BlockingIOError, InterruptedError): pass except Exception as exc: self._buffer.clear() self._conn_lost += 1 # Remove writer here, _fatal_error() doesn't it # because _buffer is empty. self._loop._remove_writer(self._fileno) self._fatal_error(exc, 'Fatal write error on pipe transport') else: if n == len(self._buffer): self._buffer.clear() self._loop._remove_writer(self._fileno) self._maybe_resume_protocol() # May append to buffer. if self._closing: self._loop._remove_reader(self._fileno) self._call_connection_lost(None) return elif n > 0: del self._buffer[:n] def can_write_eof(self): return True def write_eof(self): if self._closing: return assert self._pipe self._closing = True if not self._buffer: self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, None) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._pipe is not None and not self._closing: # write_eof is all what we needed to close the write pipe self.write_eof() # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if self._pipe is not None: warnings.warn("unclosed transport %r" % self, ResourceWarning) self._pipe.close() def abort(self): self._close(None) def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if isinstance(exc, base_events._FATAL_ERROR_IGNORE): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc=None): self._closing = True if self._buffer: self._loop._remove_writer(self._fileno) self._buffer.clear() self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None if hasattr(os, 'set_inheritable'): # Python 3.4 and newer _set_inheritable = os.set_inheritable else: import fcntl def _set_inheritable(fd, inheritable): cloexec_flag = getattr(fcntl, 'FD_CLOEXEC', 1) old = fcntl.fcntl(fd, fcntl.F_GETFD) if not inheritable: fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag) else: fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag) class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): stdin_w = None if stdin == subprocess.PIPE: # Use a socket pair for stdin, since not all platforms # support selecting read events on the write end of a # socket (which we use in order to detect closing of the # other end). Notably this is needed on AIX, and works # just fine on other platforms. stdin, stdin_w = self._loop._socketpair() # Mark the write end of the stdin pipe as non-inheritable, # needed by close_fds=False on Python 3.3 and older # (Python 3.4 implements the PEP 446, socketpair returns # non-inheritable sockets) _set_inheritable(stdin_w.fileno(), False) self._proc = subprocess.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, universal_newlines=False, bufsize=bufsize, **kwargs) if stdin_w is not None: stdin.close() self._proc.stdin = open(stdin_w.detach(), 'wb', buffering=bufsize) class AbstractChildWatcher: """Abstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. """ def add_child_handler(self, pid, callback, *args): """Register a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. """ raise NotImplementedError() def remove_child_handler(self, pid): """Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.""" raise NotImplementedError() def attach_loop(self, loop): """Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. """ raise NotImplementedError() def close(self): """Close the watcher. This must be called to make sure that any underlying resource is freed. """ raise NotImplementedError() def __enter__(self): """Enter the watcher's context and allow starting new processes This function must return self""" raise NotImplementedError() def __exit__(self, a, b, c): """Exit the watcher's context""" raise NotImplementedError() class BaseChildWatcher(AbstractChildWatcher): def __init__(self): self._loop = None self._callbacks = {} def close(self): self.attach_loop(None) def _do_waitpid(self, expected_pid): raise NotImplementedError() def _do_waitpid_all(self): raise NotImplementedError() def attach_loop(self, loop): assert loop is None or isinstance(loop, events.AbstractEventLoop) if self._loop is not None and loop is None and self._callbacks: warnings.warn( 'A loop is being detached ' 'from a child watcher with pending handlers', RuntimeWarning) if self._loop is not None: self._loop.remove_signal_handler(signal.SIGCHLD) self._loop = loop if loop is not None: loop.add_signal_handler(signal.SIGCHLD, self._sig_chld) # Prevent a race condition in case a child terminated # during the switch. self._do_waitpid_all() def _sig_chld(self): try: self._do_waitpid_all() except Exception as exc: # self._loop should always be available here # as '_sig_chld' is added as a signal handler # in 'attach_loop' self._loop.call_exception_handler({ 'message': 'Unknown exception in SIGCHLD handler', 'exception': exc, }) def _compute_returncode(self, status): if os.WIFSIGNALED(status): # The child process died because of a signal. return -os.WTERMSIG(status) elif os.WIFEXITED(status): # The child process exited (e.g sys.exit()). return os.WEXITSTATUS(status) else: # The child exited, but we don't understand its status. # This shouldn't happen, but if it does, let's just # return that status; perhaps that helps debug it. return status class SafeChildWatcher(BaseChildWatcher): """'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) """ def close(self): self._callbacks.clear() super().close() def __enter__(self): return self def __exit__(self, a, b, c): pass def add_child_handler(self, pid, callback, *args): if self._loop is None: raise RuntimeError( "Cannot add child handler, " "the child watcher does not have a loop attached") self._callbacks[pid] = (callback, args) # Prevent a race condition in case the child is already terminated. self._do_waitpid(pid) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): for pid in list(self._callbacks): self._do_waitpid(pid) def _do_waitpid(self, expected_pid): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, os.WNOHANG) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) else: if pid == 0: # The child process is still alive. return returncode = self._compute_returncode(status) if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) try: callback, args = self._callbacks.pop(pid) except KeyError: # pragma: no cover # May happen if .remove_child_handler() is called # after os.waitpid() returns. if self._loop.get_debug(): logger.warning("Child watcher got an unexpected pid: %r", pid, exc_info=True) else: callback(pid, returncode, *args) class FastChildWatcher(BaseChildWatcher): """'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). """ def __init__(self): super().__init__() self._lock = threading.Lock() self._zombies = {} self._forks = 0 def close(self): self._callbacks.clear() self._zombies.clear() super().close() def __enter__(self): with self._lock: self._forks += 1 return self def __exit__(self, a, b, c): with self._lock: self._forks -= 1 if self._forks or not self._zombies: return collateral_victims = str(self._zombies) self._zombies.clear() logger.warning( "Caught subprocesses termination from unknown pids: %s", collateral_victims) def add_child_handler(self, pid, callback, *args): assert self._forks, "Must use the context manager" if self._loop is None: raise RuntimeError( "Cannot add child handler, " "the child watcher does not have a loop attached") with self._lock: try: returncode = self._zombies.pop(pid) except KeyError: # The child is running. self._callbacks[pid] = callback, args return # The child is dead already. We can fire the callback. callback(pid, returncode, *args) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): # Because of signal coalescing, we must keep calling waitpid() as # long as we're able to reap a child. while True: try: pid, status = os.waitpid(-1, os.WNOHANG) except ChildProcessError: # No more child processes exist. return else: if pid == 0: # A child process is still alive. return returncode = self._compute_returncode(status) with self._lock: try: callback, args = self._callbacks.pop(pid) except KeyError: # unknown child if self._forks: # It may not be registered yet. self._zombies[pid] = returncode if self._loop.get_debug(): logger.debug('unknown process %s exited ' 'with returncode %s', pid, returncode) continue callback = None else: if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', pid, returncode) if callback is None: logger.warning( "Caught subprocess termination from unknown pid: " "%d -> %d", pid, returncode) else: callback(pid, returncode, *args) class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): """UNIX event loop policy with a watcher for child processes.""" _loop_factory = _UnixSelectorEventLoop def __init__(self): super().__init__() self._watcher = None def _init_watcher(self): with events._lock: if self._watcher is None: # pragma: no branch self._watcher = SafeChildWatcher() if isinstance(threading.current_thread(), threading._MainThread): self._watcher.attach_loop(self._local._loop) def set_event_loop(self, loop): """Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. """ super().set_event_loop(loop) if self._watcher is not None and \ isinstance(threading.current_thread(), threading._MainThread): self._watcher.attach_loop(loop) def get_child_watcher(self): """Get the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. """ if self._watcher is None: self._init_watcher() return self._watcher def set_child_watcher(self, watcher): """Set the watcher for child processes.""" assert watcher is None or isinstance(watcher, AbstractChildWatcher) if self._watcher is not None: self._watcher.close() self._watcher = watcher SelectorEventLoop = _UnixSelectorEventLoop DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy PK!&/Ҡ protocols.pynu["""Abstract Protocol class.""" __all__ = ['BaseProtocol', 'Protocol', 'DatagramProtocol', 'SubprocessProtocol'] class BaseProtocol: """Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe """ def connection_made(self, transport): """Called when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. """ def connection_lost(self, exc): """Called when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ def pause_writing(self): """Called when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). """ def resume_writing(self): """Called when the transport's buffer drains below the low-water mark. See pause_writing() for details. """ class Protocol(BaseProtocol): """Interface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() """ def data_received(self, data): """Called when some data is received. The argument is a bytes object. """ def eof_received(self): """Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ class DatagramProtocol(BaseProtocol): """Interface for datagram protocol.""" def datagram_received(self, data, addr): """Called when some datagram is received.""" def error_received(self, exc): """Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) """ class SubprocessProtocol(BaseProtocol): """Interface for protocol for subprocess calls.""" def pipe_data_received(self, fd, data): """Called when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. """ def pipe_connection_lost(self, fd, exc): """Called when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. """ def process_exited(self): """Called when subprocess has exited.""" PK!,%.l.lwindows_events.pynu["""Selector and proactor event loops for Windows.""" import _winapi import errno import math import socket import struct import weakref from . import events from . import base_subprocess from . import futures from . import proactor_events from . import selector_events from . import tasks from . import windows_utils from . import _overlapped from .coroutines import coroutine from .log import logger __all__ = ['SelectorEventLoop', 'ProactorEventLoop', 'IocpProactor', 'DefaultEventLoopPolicy', ] NULL = 0 INFINITE = 0xffffffff ERROR_CONNECTION_REFUSED = 1225 ERROR_CONNECTION_ABORTED = 1236 # Initial delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_INIT_DELAY = 0.001 # Maximum delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_MAX_DELAY = 0.100 class _OverlappedFuture(futures.Future): """Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. """ def __init__(self, ov, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] self._ov = ov def _repr_info(self): info = super()._repr_info() if self._ov is not None: state = 'pending' if self._ov.pending else 'completed' info.insert(1, 'overlapped=<%s, %#x>' % (state, self._ov.address)) return info def _cancel_overlapped(self): if self._ov is None: return try: self._ov.cancel() except OSError as exc: context = { 'message': 'Cancelling an overlapped future failed', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self._ov = None def cancel(self): self._cancel_overlapped() return super().cancel() def set_exception(self, exception): super().set_exception(exception) self._cancel_overlapped() def set_result(self, result): super().set_result(result) self._ov = None class _BaseWaitHandleFuture(futures.Future): """Subclass of Future which represents a wait handle.""" def __init__(self, ov, handle, wait_handle, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] # Keep a reference to the Overlapped object to keep it alive until the # wait is unregistered self._ov = ov self._handle = handle self._wait_handle = wait_handle # Should we call UnregisterWaitEx() if the wait completes # or is cancelled? self._registered = True def _poll(self): # non-blocking wait: use a timeout of 0 millisecond return (_winapi.WaitForSingleObject(self._handle, 0) == _winapi.WAIT_OBJECT_0) def _repr_info(self): info = super()._repr_info() info.append('handle=%#x' % self._handle) if self._handle is not None: state = 'signaled' if self._poll() else 'waiting' info.append(state) if self._wait_handle is not None: info.append('wait_handle=%#x' % self._wait_handle) return info def _unregister_wait_cb(self, fut): # The wait was unregistered: it's not safe to destroy the Overlapped # object self._ov = None def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWait(wait_handle) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING means that the unregister is pending self._unregister_wait_cb(None) def cancel(self): self._unregister_wait() return super().cancel() def set_exception(self, exception): self._unregister_wait() super().set_exception(exception) def set_result(self, result): self._unregister_wait() super().set_result(result) class _WaitCancelFuture(_BaseWaitHandleFuture): """Subclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. """ def __init__(self, ov, event, wait_handle, *, loop=None): super().__init__(ov, event, wait_handle, loop=loop) self._done_callback = None def cancel(self): raise RuntimeError("_WaitCancelFuture must not be cancelled") def _schedule_callbacks(self): super(_WaitCancelFuture, self)._schedule_callbacks() if self._done_callback is not None: self._done_callback(self) class _WaitHandleFuture(_BaseWaitHandleFuture): def __init__(self, ov, handle, wait_handle, proactor, *, loop=None): super().__init__(ov, handle, wait_handle, loop=loop) self._proactor = proactor self._unregister_proactor = True self._event = _overlapped.CreateEvent(None, True, False, None) self._event_fut = None def _unregister_wait_cb(self, fut): if self._event is not None: _winapi.CloseHandle(self._event) self._event = None self._event_fut = None # If the wait was cancelled, the wait may never be signalled, so # it's required to unregister it. Otherwise, IocpProactor.close() will # wait forever for an event which will never come. # # If the IocpProactor already received the event, it's safe to call # _unregister() because we kept a reference to the Overlapped object # which is used as a unique key. self._proactor._unregister(self._ov) self._proactor = None super()._unregister_wait_cb(fut) def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWaitEx(wait_handle, self._event) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING is not an error, the wait was unregistered self._event_fut = self._proactor._wait_cancel(self._event, self._unregister_wait_cb) class PipeServer(object): """Class representing a pipe server. This is much like a bound, listening socket. """ def __init__(self, address): self._address = address self._free_instances = weakref.WeakSet() # initialize the pipe attribute before calling _server_pipe_handle() # because this function can raise an exception and the destructor calls # the close() method self._pipe = None self._accept_pipe_future = None self._pipe = self._server_pipe_handle(True) def _get_unconnected_pipe(self): # Create new instance and return previous one. This ensures # that (until the server is closed) there is always at least # one pipe handle for address. Therefore if a client attempt # to connect it will not fail with FileNotFoundError. tmp, self._pipe = self._pipe, self._server_pipe_handle(False) return tmp def _server_pipe_handle(self, first): # Return a wrapper for a new pipe handle. if self.closed(): return None flags = _winapi.PIPE_ACCESS_DUPLEX | _winapi.FILE_FLAG_OVERLAPPED if first: flags |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE h = _winapi.CreateNamedPipe( self._address, flags, _winapi.PIPE_TYPE_MESSAGE | _winapi.PIPE_READMODE_MESSAGE | _winapi.PIPE_WAIT, _winapi.PIPE_UNLIMITED_INSTANCES, windows_utils.BUFSIZE, windows_utils.BUFSIZE, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) pipe = windows_utils.PipeHandle(h) self._free_instances.add(pipe) return pipe def closed(self): return (self._address is None) def close(self): if self._accept_pipe_future is not None: self._accept_pipe_future.cancel() self._accept_pipe_future = None # Close all instances which have not been connected to by a client. if self._address is not None: for pipe in self._free_instances: pipe.close() self._pipe = None self._address = None self._free_instances.clear() __del__ = close class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Windows version of selector event loop.""" def _socketpair(self): return windows_utils.socketpair() class ProactorEventLoop(proactor_events.BaseProactorEventLoop): """Windows version of proactor event loop using IOCP.""" def __init__(self, proactor=None): if proactor is None: proactor = IocpProactor() super().__init__(proactor) def _socketpair(self): return windows_utils.socketpair() @coroutine def create_pipe_connection(self, protocol_factory, address): f = self._proactor.connect_pipe(address) pipe = yield from f protocol = protocol_factory() trans = self._make_duplex_pipe_transport(pipe, protocol, extra={'addr': address}) return trans, protocol @coroutine def start_serving_pipe(self, protocol_factory, address): server = PipeServer(address) def loop_accept_pipe(f=None): pipe = None try: if f: pipe = f.result() server._free_instances.discard(pipe) if server.closed(): # A client connected before the server was closed: # drop the client (close the pipe) and exit pipe.close() return protocol = protocol_factory() self._make_duplex_pipe_transport( pipe, protocol, extra={'addr': address}) pipe = server._get_unconnected_pipe() if pipe is None: return f = self._proactor.accept_pipe(pipe) except OSError as exc: if pipe and pipe.fileno() != -1: self.call_exception_handler({ 'message': 'Pipe accept failed', 'exception': exc, 'pipe': pipe, }) pipe.close() elif self._debug: logger.warning("Accept pipe failed on pipe %r", pipe, exc_info=True) except futures.CancelledError: if pipe: pipe.close() else: server._accept_pipe_future = f f.add_done_callback(loop_accept_pipe) self.call_soon(loop_accept_pipe) return [server] @coroutine def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): waiter = self.create_future() transp = _WindowsSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) try: yield from waiter except Exception as exc: # Workaround CPython bug #23353: using yield/yield-from in an # except block of a generator doesn't clear properly sys.exc_info() err = exc else: err = None if err is not None: transp.close() yield from transp._wait() raise err return transp class IocpProactor: """Proactor implementation using IOCP.""" def __init__(self, concurrency=0xffffffff): self._loop = None self._results = [] self._iocp = _overlapped.CreateIoCompletionPort( _overlapped.INVALID_HANDLE_VALUE, NULL, 0, concurrency) self._cache = {} self._registered = weakref.WeakSet() self._unregistered = [] self._stopped_serving = weakref.WeakSet() def __repr__(self): return ('<%s overlapped#=%s result#=%s>' % (self.__class__.__name__, len(self._cache), len(self._results))) def set_loop(self, loop): self._loop = loop def select(self, timeout=None): if not self._results: self._poll(timeout) tmp = self._results self._results = [] return tmp def _result(self, value): fut = self._loop.create_future() fut.set_result(value) return fut def recv(self, conn, nbytes, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: if isinstance(conn, socket.socket): ov.WSARecv(conn.fileno(), nbytes, flags) else: ov.ReadFile(conn.fileno(), nbytes) except BrokenPipeError: return self._result(b'') def finish_recv(trans, key, ov): try: return ov.getresult() except OSError as exc: if exc.winerror == _overlapped.ERROR_NETNAME_DELETED: raise ConnectionResetError(*exc.args) else: raise return self._register(ov, conn, finish_recv) def send(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) if isinstance(conn, socket.socket): ov.WSASend(conn.fileno(), buf, flags) else: ov.WriteFile(conn.fileno(), buf) def finish_send(trans, key, ov): try: return ov.getresult() except OSError as exc: if exc.winerror == _overlapped.ERROR_NETNAME_DELETED: raise ConnectionResetError(*exc.args) else: raise return self._register(ov, conn, finish_send) def accept(self, listener): self._register_with_iocp(listener) conn = self._get_accept_socket(listener.family) ov = _overlapped.Overlapped(NULL) ov.AcceptEx(listener.fileno(), conn.fileno()) def finish_accept(trans, key, ov): ov.getresult() # Use SO_UPDATE_ACCEPT_CONTEXT so getsockname() etc work. buf = struct.pack('@P', listener.fileno()) conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_ACCEPT_CONTEXT, buf) conn.settimeout(listener.gettimeout()) return conn, conn.getpeername() @coroutine def accept_coro(future, conn): # Coroutine closing the accept socket if the future is cancelled try: yield from future except futures.CancelledError: conn.close() raise future = self._register(ov, listener, finish_accept) coro = accept_coro(future, conn) tasks.ensure_future(coro, loop=self._loop) return future def connect(self, conn, address): self._register_with_iocp(conn) # The socket needs to be locally bound before we call ConnectEx(). try: _overlapped.BindLocal(conn.fileno(), conn.family) except OSError as e: if e.winerror != errno.WSAEINVAL: raise # Probably already locally bound; check using getsockname(). if conn.getsockname()[1] == 0: raise ov = _overlapped.Overlapped(NULL) ov.ConnectEx(conn.fileno(), address) def finish_connect(trans, key, ov): ov.getresult() # Use SO_UPDATE_CONNECT_CONTEXT so getsockname() etc work. conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_CONNECT_CONTEXT, 0) return conn return self._register(ov, conn, finish_connect) def accept_pipe(self, pipe): self._register_with_iocp(pipe) ov = _overlapped.Overlapped(NULL) connected = ov.ConnectNamedPipe(pipe.fileno()) if connected: # ConnectNamePipe() failed with ERROR_PIPE_CONNECTED which means # that the pipe is connected. There is no need to wait for the # completion of the connection. return self._result(pipe) def finish_accept_pipe(trans, key, ov): ov.getresult() return pipe return self._register(ov, pipe, finish_accept_pipe) @coroutine def connect_pipe(self, address): delay = CONNECT_PIPE_INIT_DELAY while True: # Unfortunately there is no way to do an overlapped connect to a pipe. # Call CreateFile() in a loop until it doesn't fail with # ERROR_PIPE_BUSY try: handle = _overlapped.ConnectPipe(address) break except OSError as exc: if exc.winerror != _overlapped.ERROR_PIPE_BUSY: raise # ConnectPipe() failed with ERROR_PIPE_BUSY: retry later delay = min(delay * 2, CONNECT_PIPE_MAX_DELAY) yield from tasks.sleep(delay, loop=self._loop) return windows_utils.PipeHandle(handle) def wait_for_handle(self, handle, timeout=None): """Wait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). """ return self._wait_for_handle(handle, timeout, False) def _wait_cancel(self, event, done_callback): fut = self._wait_for_handle(event, None, True) # add_done_callback() cannot be used because the wait may only complete # in IocpProactor.close(), while the event loop is not running. fut._done_callback = done_callback return fut def _wait_for_handle(self, handle, timeout, _is_cancel): if timeout is None: ms = _winapi.INFINITE else: # RegisterWaitForSingleObject() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) # We only create ov so we can use ov.address as a key for the cache. ov = _overlapped.Overlapped(NULL) wait_handle = _overlapped.RegisterWaitWithQueue( handle, self._iocp, ov.address, ms) if _is_cancel: f = _WaitCancelFuture(ov, handle, wait_handle, loop=self._loop) else: f = _WaitHandleFuture(ov, handle, wait_handle, self, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] def finish_wait_for_handle(trans, key, ov): # Note that this second wait means that we should only use # this with handles types where a successful wait has no # effect. So events or processes are all right, but locks # or semaphores are not. Also note if the handle is # signalled and then quickly reset, then we may return # False even though we have not timed out. return f._poll() self._cache[ov.address] = (f, ov, 0, finish_wait_for_handle) return f def _register_with_iocp(self, obj): # To get notifications of finished ops on this objects sent to the # completion port, were must register the handle. if obj not in self._registered: self._registered.add(obj) _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0) # XXX We could also use SetFileCompletionNotificationModes() # to avoid sending notifications to completion port of ops # that succeed immediately. def _register(self, ov, obj, callback): # Return a future which will be set with the result of the # operation when it completes. The future's value is actually # the value returned by callback(). f = _OverlappedFuture(ov, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] if not ov.pending: # The operation has completed, so no need to postpone the # work. We cannot take this short cut if we need the # NumberOfBytes, CompletionKey values returned by # PostQueuedCompletionStatus(). try: value = callback(None, None, ov) except OSError as e: f.set_exception(e) else: f.set_result(value) # Even if GetOverlappedResult() was called, we have to wait for the # notification of the completion in GetQueuedCompletionStatus(). # Register the overlapped operation to keep a reference to the # OVERLAPPED object, otherwise the memory is freed and Windows may # read uninitialized memory. # Register the overlapped operation for later. Note that # we only store obj to prevent it from being garbage # collected too early. self._cache[ov.address] = (f, ov, obj, callback) return f def _unregister(self, ov): """Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). """ self._unregistered.append(ov) def _get_accept_socket(self, family): s = socket.socket(family) s.settimeout(0) return s def _poll(self, timeout=None): if timeout is None: ms = INFINITE elif timeout < 0: raise ValueError("negative timeout") else: # GetQueuedCompletionStatus() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) if ms >= INFINITE: raise ValueError("timeout too big") while True: status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms) if status is None: break ms = 0 err, transferred, key, address = status try: f, ov, obj, callback = self._cache.pop(address) except KeyError: if self._loop.get_debug(): self._loop.call_exception_handler({ 'message': ('GetQueuedCompletionStatus() returned an ' 'unexpected event'), 'status': ('err=%s transferred=%s key=%#x address=%#x' % (err, transferred, key, address)), }) # key is either zero, or it is used to return a pipe # handle which should be closed to avoid a leak. if key not in (0, _overlapped.INVALID_HANDLE_VALUE): _winapi.CloseHandle(key) continue if obj in self._stopped_serving: f.cancel() # Don't call the callback if _register() already read the result or # if the overlapped has been cancelled elif not f.done(): try: value = callback(transferred, key, ov) except OSError as e: f.set_exception(e) self._results.append(f) else: f.set_result(value) self._results.append(f) # Remove unregisted futures for ov in self._unregistered: self._cache.pop(ov.address, None) self._unregistered.clear() def _stop_serving(self, obj): # obj is a socket or pipe handle. It will be closed in # BaseProactorEventLoop._stop_serving() which will make any # pending operations fail quickly. self._stopped_serving.add(obj) def close(self): # Cancel remaining registered operations. for address, (fut, ov, obj, callback) in list(self._cache.items()): if fut.cancelled(): # Nothing to do with cancelled futures pass elif isinstance(fut, _WaitCancelFuture): # _WaitCancelFuture must not be cancelled pass else: try: fut.cancel() except OSError as exc: if self._loop is not None: context = { 'message': 'Cancelling a future failed', 'exception': exc, 'future': fut, } if fut._source_traceback: context['source_traceback'] = fut._source_traceback self._loop.call_exception_handler(context) while self._cache: if not self._poll(1): logger.debug('taking long time to close proactor') self._results = [] if self._iocp is not None: _winapi.CloseHandle(self._iocp) self._iocp = None def __del__(self): self.close() class _WindowsSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): self._proc = windows_utils.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) def callback(f): returncode = self._proc.poll() self._process_exited(returncode) f = self._loop._proactor.wait_for_handle(int(self._proc._handle)) f.add_done_callback(callback) SelectorEventLoop = _WindowsSelectorEventLoop class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): _loop_factory = SelectorEventLoop DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy PK!󺦣selector_events.pynu["""Event loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. """ __all__ = ['BaseSelectorEventLoop'] import collections import errno import functools import socket import warnings import weakref try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import compat from . import constants from . import events from . import futures from . import selectors from . import transports from . import sslproto from .coroutines import coroutine from .log import logger def _test_selector_event(selector, fd, event): # Test if the selector is monitoring 'event' events # for the file descriptor 'fd'. try: key = selector.get_key(fd) except KeyError: return False else: return bool(key.events & event) if hasattr(socket, 'TCP_NODELAY'): def _set_nodelay(sock): if (sock.family in {socket.AF_INET, socket.AF_INET6} and sock.type == socket.SOCK_STREAM and sock.proto == socket.IPPROTO_TCP): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) else: def _set_nodelay(sock): pass class BaseSelectorEventLoop(base_events.BaseEventLoop): """Selector event loop. See events.EventLoop for API specification. """ def __init__(self, selector=None): super().__init__() if selector is None: selector = selectors.DefaultSelector() logger.debug('Using selector: %s', selector.__class__.__name__) self._selector = selector self._make_self_pipe() self._transports = weakref.WeakValueDictionary() def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): return _SelectorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None): if not sslproto._is_sslproto_available(): return self._make_legacy_ssl_transport( rawsock, protocol, sslcontext, waiter, server_side=server_side, server_hostname=server_hostname, extra=extra, server=server) ssl_protocol = sslproto.SSLProtocol(self, protocol, sslcontext, waiter, server_side, server_hostname) _SelectorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_legacy_ssl_transport(self, rawsock, protocol, sslcontext, waiter, *, server_side=False, server_hostname=None, extra=None, server=None): # Use the legacy API: SSL_write, SSL_read, etc. The legacy API is used # on Python 3.4 and older, when ssl.MemoryBIO is not available. return _SelectorSslTransport( self, rawsock, protocol, sslcontext, waiter, server_side, server_hostname, extra, server) def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): return _SelectorDatagramTransport(self, sock, protocol, address, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return self._close_self_pipe() super().close() if self._selector is not None: self._selector.close() self._selector = None def _socketpair(self): raise NotImplementedError def _close_self_pipe(self): self._remove_reader(self._ssock.fileno()) self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = self._socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 self._add_reader(self._ssock.fileno(), self._read_from_self) def _process_self_data(self, data): pass def _read_from_self(self): while True: try: data = self._ssock.recv(4096) if not data: break self._process_self_data(data) except InterruptedError: continue except BlockingIOError: break def _write_to_self(self): # This may be called from a different thread, possibly after # _close_self_pipe() has been called or even while it is # running. Guard for self._csock being None or closed. When # a socket is closed, send() raises OSError (with errno set to # EBADF, but let's not rely on the exact error code). csock = self._csock if csock is not None: try: csock.send(b'\0') except OSError: if self._debug: logger.debug("Fail to write a null byte into the " "self-pipe socket", exc_info=True) def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100): self._add_reader(sock.fileno(), self._accept_connection, protocol_factory, sock, sslcontext, server, backlog) def _accept_connection(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100): # This method is only called once for each event loop tick where the # listening socket has triggered an EVENT_READ. There may be multiple # connections waiting for an .accept() so it is called in a loop. # See https://bugs.python.org/issue27906 for more details. for _ in range(backlog): try: conn, addr = sock.accept() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) conn.setblocking(False) except (BlockingIOError, InterruptedError, ConnectionAbortedError): # Early exit because the socket accept buffer is empty. return None except OSError as exc: # There's nowhere to send the error, so just log it. if exc.errno in (errno.EMFILE, errno.ENFILE, errno.ENOBUFS, errno.ENOMEM): # Some platforms (e.g. Linux keep reporting the FD as # ready, so we remove the read handler temporarily. # We'll try again in a while. self.call_exception_handler({ 'message': 'socket.accept() out of system resource', 'exception': exc, 'socket': sock, }) self._remove_reader(sock.fileno()) self.call_later(constants.ACCEPT_RETRY_DELAY, self._start_serving, protocol_factory, sock, sslcontext, server, backlog) else: raise # The event loop will catch, log and ignore it. else: extra = {'peername': addr} accept = self._accept_connection2(protocol_factory, conn, extra, sslcontext, server) self.create_task(accept) @coroutine def _accept_connection2(self, protocol_factory, conn, extra, sslcontext=None, server=None): protocol = None transport = None try: protocol = protocol_factory() waiter = self.create_future() if sslcontext: transport = self._make_ssl_transport( conn, protocol, sslcontext, waiter=waiter, server_side=True, extra=extra, server=server) else: transport = self._make_socket_transport( conn, protocol, waiter=waiter, extra=extra, server=server) try: yield from waiter except: transport.close() raise # It's now up to the protocol to handle the connection. except Exception as exc: if self._debug: context = { 'message': ('Error on transport creation ' 'for incoming connection'), 'exception': exc, } if protocol is not None: context['protocol'] = protocol if transport is not None: context['transport'] = transport self.call_exception_handler(context) def _ensure_fd_no_transport(self, fd): try: transport = self._transports[fd] except KeyError: pass else: if not transport.is_closing(): raise RuntimeError( 'File descriptor {!r} is used by transport {!r}'.format( fd, transport)) def _add_reader(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_READ, (handle, None)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_READ, (handle, writer)) if reader is not None: reader.cancel() def _remove_reader(self, fd): if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data mask &= ~selectors.EVENT_READ if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (None, writer)) if reader is not None: reader.cancel() return True else: return False def _add_writer(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_WRITE, (None, handle)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_WRITE, (reader, handle)) if writer is not None: writer.cancel() def _remove_writer(self, fd): """Remove a writer callback.""" if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data # Remove both writer and connector. mask &= ~selectors.EVENT_WRITE if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (reader, None)) if writer is not None: writer.cancel() return True else: return False def add_reader(self, fd, callback, *args): """Add a reader callback.""" self._ensure_fd_no_transport(fd) return self._add_reader(fd, callback, *args) def remove_reader(self, fd): """Remove a reader callback.""" self._ensure_fd_no_transport(fd) return self._remove_reader(fd) def add_writer(self, fd, callback, *args): """Add a writer callback..""" self._ensure_fd_no_transport(fd) return self._add_writer(fd, callback, *args) def remove_writer(self, fd): """Remove a writer callback.""" self._ensure_fd_no_transport(fd) return self._remove_writer(fd) def sock_recv(self, sock, n): """Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. This method is a coroutine. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_recv(fut, False, sock, n) return fut def _sock_recv(self, fut, registered, sock, n): # _sock_recv() can add itself as an I/O callback if the operation can't # be done immediately. Don't use it directly, call sock_recv(). fd = sock.fileno() if registered: # Remove the callback early. It should be rare that the # selector says the fd is ready but the call still returns # EAGAIN, and I am willing to take a hit in that case in # order to simplify the common case. self.remove_reader(fd) if fut.cancelled(): return try: data = sock.recv(n) except (BlockingIOError, InterruptedError): self.add_reader(fd, self._sock_recv, fut, True, sock, n) except Exception as exc: fut.set_exception(exc) else: fut.set_result(data) def sock_sendall(self, sock, data): """Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. This method is a coroutine. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() if data: self._sock_sendall(fut, False, sock, data) else: fut.set_result(None) return fut def _sock_sendall(self, fut, registered, sock, data): fd = sock.fileno() if registered: self.remove_writer(fd) if fut.cancelled(): return try: n = sock.send(data) except (BlockingIOError, InterruptedError): n = 0 except Exception as exc: fut.set_exception(exc) return if n == len(data): fut.set_result(None) else: if n: data = data[n:] self.add_writer(fd, self._sock_sendall, fut, True, sock, data) @coroutine def sock_connect(self, sock, address): """Connect to a remote socket at address. This method is a coroutine. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX: resolved = base_events._ensure_resolved( address, family=sock.family, proto=sock.proto, loop=self) if not resolved.done(): yield from resolved _, _, _, _, address = resolved.result()[0] fut = self.create_future() self._sock_connect(fut, sock, address) return (yield from fut) def _sock_connect(self, fut, sock, address): fd = sock.fileno() try: sock.connect(address) except (BlockingIOError, InterruptedError): # Issue #23618: When the C function connect() fails with EINTR, the # connection runs in background. We have to wait until the socket # becomes writable to be notified when the connection succeed or # fails. fut.add_done_callback( functools.partial(self._sock_connect_done, fd)) self.add_writer(fd, self._sock_connect_cb, fut, sock, address) except Exception as exc: fut.set_exception(exc) else: fut.set_result(None) def _sock_connect_done(self, fd, fut): self.remove_writer(fd) def _sock_connect_cb(self, fut, sock, address): if fut.cancelled(): return try: err = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) if err != 0: # Jump to any except clause below. raise OSError(err, 'Connect call failed %s' % (address,)) except (BlockingIOError, InterruptedError): # socket is still registered, the callback will be retried later pass except Exception as exc: fut.set_exception(exc) else: fut.set_result(None) def sock_accept(self, sock): """Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. This method is a coroutine. """ if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_accept(fut, False, sock) return fut def _sock_accept(self, fut, registered, sock): fd = sock.fileno() if registered: self.remove_reader(fd) if fut.cancelled(): return try: conn, address = sock.accept() conn.setblocking(False) except (BlockingIOError, InterruptedError): self.add_reader(fd, self._sock_accept, fut, True, sock) except Exception as exc: fut.set_exception(exc) else: fut.set_result((conn, address)) def _process_events(self, event_list): for key, mask in event_list: fileobj, (reader, writer) = key.fileobj, key.data if mask & selectors.EVENT_READ and reader is not None: if reader._cancelled: self._remove_reader(fileobj) else: self._add_callback(reader) if mask & selectors.EVENT_WRITE and writer is not None: if writer._cancelled: self._remove_writer(fileobj) else: self._add_callback(writer) def _stop_serving(self, sock): self._remove_reader(sock.fileno()) sock.close() class _SelectorTransport(transports._FlowControlMixin, transports.Transport): max_size = 256 * 1024 # Buffer size passed to recv(). _buffer_factory = bytearray # Constructs initial value for self._buffer. # Attribute used in the destructor: it must be set even if the constructor # is not called (see _SelectorSslTransport which may start by raising an # exception) _sock = None def __init__(self, loop, sock, protocol, extra=None, server=None): super().__init__(extra, loop) self._extra['socket'] = sock self._extra['sockname'] = sock.getsockname() if 'peername' not in self._extra: try: self._extra['peername'] = sock.getpeername() except socket.error: self._extra['peername'] = None self._sock = sock self._sock_fd = sock.fileno() self._protocol = protocol self._protocol_connected = True self._server = server self._buffer = self._buffer_factory() self._conn_lost = 0 # Set when call to connection_lost scheduled. self._closing = False # Set when close() called. if self._server is not None: self._server._attach() loop._transports[self._sock_fd] = self def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') info.append('fd=%s' % self._sock_fd) # test if the transport was closed if self._loop is not None and not self._loop.is_closed(): polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_READ) if polling: info.append('read=polling') else: info.append('read=idle') polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_WRITE) if polling: state = 'polling' else: state = 'idle' bufsize = self.get_write_buffer_size() info.append('write=<%s, bufsize=%s>' % (state, bufsize)) return '<%s>' % ' '.join(info) def abort(self): self._force_close(None) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._closing: return self._closing = True self._loop._remove_reader(self._sock_fd) if not self._buffer: self._conn_lost += 1 self._loop._remove_writer(self._sock_fd) self._loop.call_soon(self._call_connection_lost, None) # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if self._sock is not None: warnings.warn("unclosed transport %r" % self, ResourceWarning) self._sock.close() def _fatal_error(self, exc, message='Fatal error on transport'): # Should be called from exception handler only. if isinstance(exc, base_events._FATAL_ERROR_IGNORE): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._force_close(exc) def _force_close(self, exc): if self._conn_lost: return if self._buffer: self._buffer.clear() self._loop._remove_writer(self._sock_fd) if not self._closing: self._closing = True self._loop._remove_reader(self._sock_fd) self._conn_lost += 1 self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: if self._protocol_connected: self._protocol.connection_lost(exc) finally: self._sock.close() self._sock = None self._protocol = None self._loop = None server = self._server if server is not None: server._detach() self._server = None def get_write_buffer_size(self): return len(self._buffer) class _SelectorSocketTransport(_SelectorTransport): def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(loop, sock, protocol, extra, server) self._eof = False self._paused = False # Disable the Nagle algorithm -- small writes will be # sent without waiting for the TCP ACK. This generally # decreases the latency (in some cases significantly.) _set_nodelay(self._sock) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def pause_reading(self): if self._closing: raise RuntimeError('Cannot pause_reading() when closing') if self._paused: raise RuntimeError('Already paused') self._paused = True self._loop._remove_reader(self._sock_fd) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if not self._paused: raise RuntimeError('Not paused') self._paused = False if self._closing: return self._loop._add_reader(self._sock_fd, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def _read_ready(self): if self._conn_lost: return try: data = self._sock.recv(self.max_size) except (BlockingIOError, InterruptedError): pass except Exception as exc: self._fatal_error(exc, 'Fatal read error on socket transport') else: if data: self._protocol.data_received(data) else: if self._loop.get_debug(): logger.debug("%r received EOF", self) keep_open = self._protocol.eof_received() if keep_open: # We're keeping the connection open so the # protocol can write more, but we still can't # receive more, so remove the reader callback. self._loop._remove_reader(self._sock_fd) else: self.close() def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be a bytes-like object, ' 'not %r' % type(data).__name__) if self._eof: raise RuntimeError('Cannot call write() after write_eof()') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Optimization: try to send now. try: n = self._sock.send(data) except (BlockingIOError, InterruptedError): pass except Exception as exc: self._fatal_error(exc, 'Fatal write error on socket transport') return else: data = data[n:] if not data: return # Not all was written; register write handler. self._loop._add_writer(self._sock_fd, self._write_ready) # Add it to the buffer. self._buffer.extend(data) self._maybe_pause_protocol() def _write_ready(self): assert self._buffer, 'Data should not be empty' if self._conn_lost: return try: n = self._sock.send(self._buffer) except (BlockingIOError, InterruptedError): pass except Exception as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on socket transport') else: if n: del self._buffer[:n] self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._closing: self._call_connection_lost(None) elif self._eof: self._sock.shutdown(socket.SHUT_WR) def write_eof(self): if self._eof: return self._eof = True if not self._buffer: self._sock.shutdown(socket.SHUT_WR) def can_write_eof(self): return True class _SelectorSslTransport(_SelectorTransport): _buffer_factory = bytearray def __init__(self, loop, rawsock, protocol, sslcontext, waiter=None, server_side=False, server_hostname=None, extra=None, server=None): if ssl is None: raise RuntimeError('stdlib ssl module not available') if not sslcontext: sslcontext = sslproto._create_transport_context(server_side, server_hostname) wrap_kwargs = { 'server_side': server_side, 'do_handshake_on_connect': False, } if server_hostname and not server_side: wrap_kwargs['server_hostname'] = server_hostname sslsock = sslcontext.wrap_socket(rawsock, **wrap_kwargs) super().__init__(loop, sslsock, protocol, extra, server) # the protocol connection is only made after the SSL handshake self._protocol_connected = False self._server_hostname = server_hostname self._waiter = waiter self._sslcontext = sslcontext self._paused = False # SSL-specific extra info. (peercert is set later) self._extra.update(sslcontext=sslcontext) if self._loop.get_debug(): logger.debug("%r starts SSL handshake", self) start_time = self._loop.time() else: start_time = None self._on_handshake(start_time) def _wakeup_waiter(self, exc=None): if self._waiter is None: return if not self._waiter.cancelled(): if exc is not None: self._waiter.set_exception(exc) else: self._waiter.set_result(None) self._waiter = None def _on_handshake(self, start_time): try: self._sock.do_handshake() except ssl.SSLWantReadError: self._loop._add_reader(self._sock_fd, self._on_handshake, start_time) return except ssl.SSLWantWriteError: self._loop._add_writer(self._sock_fd, self._on_handshake, start_time) return except BaseException as exc: if self._loop.get_debug(): logger.warning("%r: SSL handshake failed", self, exc_info=True) self._loop._remove_reader(self._sock_fd) self._loop._remove_writer(self._sock_fd) self._sock.close() self._wakeup_waiter(exc) if isinstance(exc, Exception): return else: raise self._loop._remove_reader(self._sock_fd) self._loop._remove_writer(self._sock_fd) peercert = self._sock.getpeercert() if not hasattr(self._sslcontext, 'check_hostname'): # Verify hostname if requested, Python 3.4+ uses check_hostname # and checks the hostname in do_handshake() if (self._server_hostname and self._sslcontext.verify_mode != ssl.CERT_NONE): try: ssl.match_hostname(peercert, self._server_hostname) except Exception as exc: if self._loop.get_debug(): logger.warning("%r: SSL handshake failed " "on matching the hostname", self, exc_info=True) self._sock.close() self._wakeup_waiter(exc) return # Add extra info that becomes available after handshake. self._extra.update(peercert=peercert, cipher=self._sock.cipher(), compression=self._sock.compression(), ssl_object=self._sock, ) self._read_wants_write = False self._write_wants_read = False self._loop._add_reader(self._sock_fd, self._read_ready) self._protocol_connected = True self._loop.call_soon(self._protocol.connection_made, self) # only wake up the waiter when connection_made() has been called self._loop.call_soon(self._wakeup_waiter) if self._loop.get_debug(): dt = self._loop.time() - start_time logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3) def pause_reading(self): # XXX This is a bit icky, given the comment at the top of # _read_ready(). Is it possible to evoke a deadlock? I don't # know, although it doesn't look like it; write() will still # accept more data for the buffer and eventually the app will # call resume_reading() again, and things will flow again. if self._closing: raise RuntimeError('Cannot pause_reading() when closing') if self._paused: raise RuntimeError('Already paused') self._paused = True self._loop._remove_reader(self._sock_fd) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if not self._paused: raise RuntimeError('Not paused') self._paused = False if self._closing: return self._loop._add_reader(self._sock_fd, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def _read_ready(self): if self._conn_lost: return if self._write_wants_read: self._write_wants_read = False self._write_ready() if self._buffer: self._loop._add_writer(self._sock_fd, self._write_ready) try: data = self._sock.recv(self.max_size) except (BlockingIOError, InterruptedError, ssl.SSLWantReadError): pass except ssl.SSLWantWriteError: self._read_wants_write = True self._loop._remove_reader(self._sock_fd) self._loop._add_writer(self._sock_fd, self._write_ready) except Exception as exc: self._fatal_error(exc, 'Fatal read error on SSL transport') else: if data: self._protocol.data_received(data) else: try: if self._loop.get_debug(): logger.debug("%r received EOF", self) keep_open = self._protocol.eof_received() if keep_open: logger.warning('returning true from eof_received() ' 'has no effect when using ssl') finally: self.close() def _write_ready(self): if self._conn_lost: return if self._read_wants_write: self._read_wants_write = False self._read_ready() if not (self._paused or self._closing): self._loop._add_reader(self._sock_fd, self._read_ready) if self._buffer: try: n = self._sock.send(self._buffer) except (BlockingIOError, InterruptedError, ssl.SSLWantWriteError): n = 0 except ssl.SSLWantReadError: n = 0 self._loop._remove_writer(self._sock_fd) self._write_wants_read = True except Exception as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on SSL transport') return if n: del self._buffer[:n] self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._closing: self._call_connection_lost(None) def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be a bytes-like object, ' 'not %r' % type(data).__name__) if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: self._loop._add_writer(self._sock_fd, self._write_ready) # Add it to the buffer. self._buffer.extend(data) self._maybe_pause_protocol() def can_write_eof(self): return False class _SelectorDatagramTransport(_SelectorTransport): _buffer_factory = collections.deque def __init__(self, loop, sock, protocol, address=None, waiter=None, extra=None): super().__init__(loop, sock, protocol, extra) self._address = address self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def get_write_buffer_size(self): return sum(len(data) for data, _ in self._buffer) def _read_ready(self): if self._conn_lost: return try: data, addr = self._sock.recvfrom(self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._protocol.error_received(exc) except Exception as exc: self._fatal_error(exc, 'Fatal read error on datagram transport') else: self._protocol.datagram_received(data, addr) def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be a bytes-like object, ' 'not %r' % type(data).__name__) if not data: return if self._address and addr not in (None, self._address): raise ValueError('Invalid address: must be None or %s' % (self._address,)) if self._conn_lost and self._address: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: if self._address: self._sock.send(data) else: self._sock.sendto(data, addr) return except (BlockingIOError, InterruptedError): self._loop._add_writer(self._sock_fd, self._sendto_ready) except OSError as exc: self._protocol.error_received(exc) return except Exception as exc: self._fatal_error(exc, 'Fatal write error on datagram transport') return # Ensure that what we buffer is immutable. self._buffer.append((bytes(data), addr)) self._maybe_pause_protocol() def _sendto_ready(self): while self._buffer: data, addr = self._buffer.popleft() try: if self._address: self._sock.send(data) else: self._sock.sendto(data, addr) except (BlockingIOError, InterruptedError): self._buffer.appendleft((data, addr)) # Try again later. break except OSError as exc: self._protocol.error_received(exc) return except Exception as exc: self._fatal_error(exc, 'Fatal write error on datagram transport') return self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._closing: self._call_connection_lost(None) PK!z/%: runners.pynu[__all__ = 'run', from . import coroutines from . import events from . import tasks def run(main, *, debug=None): """Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) """ if events._get_running_loop() is not None: raise RuntimeError( "asyncio.run() cannot be called from a running event loop") if not coroutines.iscoroutine(main): raise ValueError("a coroutine was expected, got {!r}".format(main)) loop = events.new_event_loop() try: events.set_event_loop(loop) if debug is not None: loop.set_debug(debug) return loop.run_until_complete(main) finally: try: _cancel_all_tasks(loop) loop.run_until_complete(loop.shutdown_asyncgens()) finally: events.set_event_loop(None) loop.close() def _cancel_all_tasks(loop): to_cancel = tasks.all_tasks(loop) if not to_cancel: return for task in to_cancel: task.cancel() loop.run_until_complete( tasks.gather(*to_cancel, loop=loop, return_exceptions=True)) for task in to_cancel: if task.cancelled(): continue if task.exception() is not None: loop.call_exception_handler({ 'message': 'unhandled exception during asyncio.run() shutdown', 'exception': task.exception(), 'task': task, }) PK!7tњ::locks.pynu["""Synchronization primitives.""" __all__ = ['Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore'] import collections from . import compat from . import events from . import futures from .coroutines import coroutine class _ContextManager: """Context manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: """ def __init__(self, lock): self._lock = lock def __enter__(self): # We have no use for the "as ..." clause in the with # statement for locks. return None def __exit__(self, *args): try: self._lock.release() finally: self._lock = None # Crudely prevent reuse. class _ContextManagerMixin: def __enter__(self): raise RuntimeError( '"yield from" should be used as context manager expression') def __exit__(self, *args): # This must exist because __enter__ exists, even though that # always raises; that's how the with-statement works. pass @coroutine def __iter__(self): # This is not a coroutine. It is meant to enable the idiom: # # with (yield from lock): # # # as an alternative to: # # yield from lock.acquire() # try: # # finally: # lock.release() yield from self.acquire() return _ContextManager(self) if compat.PY35: def __await__(self): # To make "with await lock" work. yield from self.acquire() return _ContextManager(self) @coroutine def __aenter__(self): yield from self.acquire() # We have no use for the "as ..." clause in the with # statement for locks. return None @coroutine def __aexit__(self, exc_type, exc, tb): self.release() class Lock(_ContextManagerMixin): """Primitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... """ def __init__(self, *, loop=None): self._waiters = collections.deque() self._locked = False if loop is not None: self._loop = loop else: self._loop = events.get_event_loop() def __repr__(self): res = super().__repr__() extra = 'locked' if self._locked else 'unlocked' if self._waiters: extra = '{},waiters:{}'.format(extra, len(self._waiters)) return '<{} [{}]>'.format(res[1:-1], extra) def locked(self): """Return True if lock is acquired.""" return self._locked @coroutine def acquire(self): """Acquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. """ if not self._locked and all(w.cancelled() for w in self._waiters): self._locked = True return True fut = self._loop.create_future() self._waiters.append(fut) try: yield from fut self._locked = True return True except futures.CancelledError: if not self._locked: self._wake_up_first() raise finally: self._waiters.remove(fut) def release(self): """Release a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. """ if self._locked: self._locked = False self._wake_up_first() else: raise RuntimeError('Lock is not acquired.') def _wake_up_first(self): """Wake up the first waiter who isn't cancelled.""" for fut in self._waiters: if not fut.done(): fut.set_result(True) break class Event: """Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. """ def __init__(self, *, loop=None): self._waiters = collections.deque() self._value = False if loop is not None: self._loop = loop else: self._loop = events.get_event_loop() def __repr__(self): res = super().__repr__() extra = 'set' if self._value else 'unset' if self._waiters: extra = '{},waiters:{}'.format(extra, len(self._waiters)) return '<{} [{}]>'.format(res[1:-1], extra) def is_set(self): """Return True if and only if the internal flag is true.""" return self._value def set(self): """Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): fut.set_result(True) def clear(self): """Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.""" self._value = False @coroutine def wait(self): """Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. """ if self._value: return True fut = self._loop.create_future() self._waiters.append(fut) try: yield from fut return True finally: self._waiters.remove(fut) class Condition(_ContextManagerMixin): """Asynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. """ def __init__(self, lock=None, *, loop=None): if loop is not None: self._loop = loop else: self._loop = events.get_event_loop() if lock is None: lock = Lock(loop=self._loop) elif lock._loop is not self._loop: raise ValueError("loop argument must agree with lock") self._lock = lock # Export the lock's locked(), acquire() and release() methods. self.locked = lock.locked self.acquire = lock.acquire self.release = lock.release self._waiters = collections.deque() def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else 'unlocked' if self._waiters: extra = '{},waiters:{}'.format(extra, len(self._waiters)) return '<{} [{}]>'.format(res[1:-1], extra) @coroutine def wait(self): """Wait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. """ if not self.locked(): raise RuntimeError('cannot wait on un-acquired lock') self.release() try: fut = self._loop.create_future() self._waiters.append(fut) try: yield from fut return True finally: self._waiters.remove(fut) finally: # Must reacquire lock even if wait is cancelled while True: try: yield from self.acquire() break except futures.CancelledError: pass @coroutine def wait_for(self, predicate): """Wait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. """ result = predicate() while not result: yield from self.wait() result = predicate() return result def notify(self, n=1): """By default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. """ if not self.locked(): raise RuntimeError('cannot notify on un-acquired lock') idx = 0 for fut in self._waiters: if idx >= n: break if not fut.done(): idx += 1 fut.set_result(False) def notify_all(self): """Wake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. """ self.notify(len(self._waiters)) class Semaphore(_ContextManagerMixin): """A Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. """ def __init__(self, value=1, *, loop=None): if value < 0: raise ValueError("Semaphore initial value must be >= 0") self._value = value self._waiters = collections.deque() if loop is not None: self._loop = loop else: self._loop = events.get_event_loop() def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else 'unlocked,value:{}'.format( self._value) if self._waiters: extra = '{},waiters:{}'.format(extra, len(self._waiters)) return '<{} [{}]>'.format(res[1:-1], extra) def _wake_up_next(self): while self._waiters: waiter = self._waiters.popleft() if not waiter.done(): waiter.set_result(None) return def locked(self): """Returns True if semaphore can not be acquired immediately.""" return self._value == 0 @coroutine def acquire(self): """Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. """ while self._value <= 0: fut = self._loop.create_future() self._waiters.append(fut) try: yield from fut except: # See the similar code in Queue.get. fut.cancel() if self._value > 0 and not fut.cancelled(): self._wake_up_next() raise self._value -= 1 return True def release(self): """Release a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. """ self._value += 1 self._wake_up_next() class BoundedSemaphore(Semaphore): """A bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. """ def __init__(self, value=1, *, loop=None): self._bound_value = value super().__init__(value, loop=loop) def release(self): if self._value >= self._bound_value: raise ValueError('BoundedSemaphore released too many times') super().release() PK!~S1ggtasks.pynu["""Support for tasks, coroutines and the scheduler.""" __all__ = ['Task', 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED', 'wait', 'wait_for', 'as_completed', 'sleep', 'async', 'gather', 'shield', 'ensure_future', 'run_coroutine_threadsafe', ] import concurrent.futures import functools import inspect import linecache import traceback import warnings import weakref from . import compat from . import coroutines from . import events from . import futures from .coroutines import coroutine class Task(futures.Future): """A coroutine wrapped in a Future.""" # An important invariant maintained while a Task not done: # # - Either _fut_waiter is None, and _step() is scheduled; # - or _fut_waiter is some Future, and _step() is *not* scheduled. # # The only transition from the latter to the former is through # _wakeup(). When _fut_waiter is not None, one of its callbacks # must be _wakeup(). # Weak set containing all tasks alive. _all_tasks = weakref.WeakSet() # Dictionary containing tasks that are currently active in # all running event loops. {EventLoop: Task} _current_tasks = {} # If False, don't log a message if the task is destroyed whereas its # status is still pending _log_destroy_pending = True @classmethod def current_task(cls, loop=None): """Return the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. """ if loop is None: loop = events.get_event_loop() return cls._current_tasks.get(loop) @classmethod def all_tasks(cls, loop=None): """Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. """ if loop is None: loop = events.get_event_loop() return {t for t in cls._all_tasks if t._loop is loop} def __init__(self, coro, *, loop=None): assert coroutines.iscoroutine(coro), repr(coro) super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] self._coro = coro self._fut_waiter = None self._must_cancel = False self._loop.call_soon(self._step) self.__class__._all_tasks.add(self) # On Python 3.3 or older, objects with a destructor that are part of a # reference cycle are never destroyed. That's not the case any more on # Python 3.4 thanks to the PEP 442. if compat.PY34: def __del__(self): if self._state == futures._PENDING and self._log_destroy_pending: context = { 'task': self, 'message': 'Task was destroyed but it is pending!', } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) futures.Future.__del__(self) def _repr_info(self): info = super()._repr_info() if self._must_cancel: # replace status info[0] = 'cancelling' coro = coroutines._format_coroutine(self._coro) info.insert(1, 'coro=<%s>' % coro) if self._fut_waiter is not None: info.insert(2, 'wait_for=%r' % self._fut_waiter) return info def get_stack(self, *, limit=None): """Return the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. """ frames = [] try: # 'async def' coroutines f = self._coro.cr_frame except AttributeError: f = self._coro.gi_frame if f is not None: while f is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(f) f = f.f_back frames.reverse() elif self._exception is not None: tb = self._exception.__traceback__ while tb is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(tb.tb_frame) tb = tb.tb_next return frames def print_stack(self, *, limit=None, file=None): """Print the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. """ extracted_list = [] checked = set() for f in self.get_stack(limit=limit): lineno = f.f_lineno co = f.f_code filename = co.co_filename name = co.co_name if filename not in checked: checked.add(filename) linecache.checkcache(filename) line = linecache.getline(filename, lineno, f.f_globals) extracted_list.append((filename, lineno, name, line)) exc = self._exception if not extracted_list: print('No stack for %r' % self, file=file) elif exc is not None: print('Traceback for %r (most recent call last):' % self, file=file) else: print('Stack for %r (most recent call last):' % self, file=file) traceback.print_list(extracted_list, file=file) if exc is not None: for line in traceback.format_exception_only(exc.__class__, exc): print(line, file=file, end='') def cancel(self): """Request that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). """ self._log_traceback = False if self.done(): return False if self._fut_waiter is not None: if self._fut_waiter.cancel(): # Leave self._fut_waiter; it may be a Task that # catches and ignores the cancellation so we may have # to cancel it again later. return True # It must be the case that self._step is already scheduled. self._must_cancel = True return True def _step(self, exc=None): assert not self.done(), \ '_step(): already done: {!r}, {!r}'.format(self, exc) if self._must_cancel: if not isinstance(exc, futures.CancelledError): exc = futures.CancelledError() self._must_cancel = False coro = self._coro self._fut_waiter = None self.__class__._current_tasks[self._loop] = self # Call either coro.throw(exc) or coro.send(None). try: if exc is None: # We use the `send` method directly, because coroutines # don't have `__iter__` and `__next__` methods. result = coro.send(None) else: result = coro.throw(exc) except StopIteration as exc: if self._must_cancel: # Task is cancelled right before coro stops. self._must_cancel = False self.set_exception(futures.CancelledError()) else: self.set_result(exc.value) except futures.CancelledError: super().cancel() # I.e., Future.cancel(self). except Exception as exc: self.set_exception(exc) except BaseException as exc: self.set_exception(exc) raise else: blocking = getattr(result, '_asyncio_future_blocking', None) if blocking is not None: # Yielded Future must come from Future.__iter__(). if result._loop is not self._loop: self._loop.call_soon( self._step, RuntimeError( 'Task {!r} got Future {!r} attached to a ' 'different loop'.format(self, result))) elif blocking: if result is self: self._loop.call_soon( self._step, RuntimeError( 'Task cannot await on itself: {!r}'.format( self))) else: result._asyncio_future_blocking = False result.add_done_callback(self._wakeup) self._fut_waiter = result if self._must_cancel: if self._fut_waiter.cancel(): self._must_cancel = False else: self._loop.call_soon( self._step, RuntimeError( 'yield was used instead of yield from ' 'in task {!r} with {!r}'.format(self, result))) elif result is None: # Bare yield relinquishes control for one event loop iteration. self._loop.call_soon(self._step) elif inspect.isgenerator(result): # Yielding a generator is just wrong. self._loop.call_soon( self._step, RuntimeError( 'yield was used instead of yield from for ' 'generator in task {!r} with {}'.format( self, result))) else: # Yielding something else is an error. self._loop.call_soon( self._step, RuntimeError( 'Task got bad yield: {!r}'.format(result))) finally: self.__class__._current_tasks.pop(self._loop) self = None # Needed to break cycles when an exception occurs. def _wakeup(self, future): try: future.result() except Exception as exc: # This may also be a cancellation. self._step(exc) else: # Don't pass the value of `future.result()` explicitly, # as `Future.__iter__` and `Future.__await__` don't need it. # If we call `_step(value, None)` instead of `_step()`, # Python eval loop would use `.send(value)` method call, # instead of `__next__()`, which is slower for futures # that return non-generator iterators from their `__iter__`. self._step() self = None # Needed to break cycles when an exception occurs. # wait() and as_completed() similar to those in PEP 3148. FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION ALL_COMPLETED = concurrent.futures.ALL_COMPLETED @coroutine def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED): """Wait for the Futures and coroutines given by fs to complete. The sequence futures must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = yield from asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError("expect a list of futures, not %s" % type(fs).__name__) if not fs: raise ValueError('Set of coroutines/Futures is empty.') if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): raise ValueError('Invalid return_when value: {}'.format(return_when)) if loop is None: loop = events.get_event_loop() fs = {ensure_future(f, loop=loop) for f in set(fs)} return (yield from _wait(fs, timeout, return_when, loop)) def _release_waiter(waiter, *args): if not waiter.done(): waiter.set_result(None) @coroutine def wait_for(fut, timeout, *, loop=None): """Wait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. """ if loop is None: loop = events.get_event_loop() if timeout is None: return (yield from fut) waiter = loop.create_future() timeout_handle = loop.call_later(timeout, _release_waiter, waiter) cb = functools.partial(_release_waiter, waiter) fut = ensure_future(fut, loop=loop) fut.add_done_callback(cb) try: # wait until the future completes or the timeout try: yield from waiter except futures.CancelledError: fut.remove_done_callback(cb) fut.cancel() raise if fut.done(): return fut.result() else: fut.remove_done_callback(cb) fut.cancel() raise futures.TimeoutError() finally: timeout_handle.cancel() @coroutine def _wait(fs, timeout, return_when, loop): """Internal helper for wait() and wait_for(). The fs argument must be a collection of Futures. """ assert fs, 'Set of Futures is empty.' waiter = loop.create_future() timeout_handle = None if timeout is not None: timeout_handle = loop.call_later(timeout, _release_waiter, waiter) counter = len(fs) def _on_completion(f): nonlocal counter counter -= 1 if (counter <= 0 or return_when == FIRST_COMPLETED or return_when == FIRST_EXCEPTION and (not f.cancelled() and f.exception() is not None)): if timeout_handle is not None: timeout_handle.cancel() if not waiter.done(): waiter.set_result(None) for f in fs: f.add_done_callback(_on_completion) try: yield from waiter finally: if timeout_handle is not None: timeout_handle.cancel() done, pending = set(), set() for f in fs: f.remove_done_callback(_on_completion) if f.done(): done.add(f) else: pending.add(f) return done, pending # This is *not* a @coroutine! It is just an iterator (yielding Futures). def as_completed(fs, *, loop=None, timeout=None): """Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError("expect a list of futures, not %s" % type(fs).__name__) loop = loop if loop is not None else events.get_event_loop() todo = {ensure_future(f, loop=loop) for f in set(fs)} from .queues import Queue # Import here to avoid circular import problem. done = Queue(loop=loop) timeout_handle = None def _on_timeout(): for f in todo: f.remove_done_callback(_on_completion) done.put_nowait(None) # Queue a dummy value for _wait_for_one(). todo.clear() # Can't do todo.remove(f) in the loop. def _on_completion(f): if not todo: return # _on_timeout() was here first. todo.remove(f) done.put_nowait(f) if not todo and timeout_handle is not None: timeout_handle.cancel() @coroutine def _wait_for_one(): f = yield from done.get() if f is None: # Dummy value from _on_timeout(). raise futures.TimeoutError return f.result() # May raise f.exception(). for f in todo: f.add_done_callback(_on_completion) if todo and timeout is not None: timeout_handle = loop.call_later(timeout, _on_timeout) for _ in range(len(todo)): yield _wait_for_one() @coroutine def sleep(delay, result=None, *, loop=None): """Coroutine that completes after a given time (in seconds).""" if delay == 0: yield return result if loop is None: loop = events.get_event_loop() future = loop.create_future() h = future._loop.call_later(delay, futures._set_result_unless_cancelled, future, result) try: return (yield from future) finally: h.cancel() def async_(coro_or_future, *, loop=None): """Wrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. """ warnings.warn("asyncio.async() function is deprecated, use ensure_future()", DeprecationWarning, stacklevel=2) return ensure_future(coro_or_future, loop=loop) # Silence DeprecationWarning: globals()['async'] = async_ async_.__name__ = 'async' del async_ def ensure_future(coro_or_future, *, loop=None): """Wrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. """ if futures.isfuture(coro_or_future): if loop is not None and loop is not coro_or_future._loop: raise ValueError('loop argument must agree with Future') return coro_or_future elif coroutines.iscoroutine(coro_or_future): if loop is None: loop = events.get_event_loop() task = loop.create_task(coro_or_future) if task._source_traceback: del task._source_traceback[-1] return task elif compat.PY35 and inspect.isawaitable(coro_or_future): return ensure_future(_wrap_awaitable(coro_or_future), loop=loop) else: raise TypeError('An asyncio.Future, a coroutine or an awaitable is ' 'required') @coroutine def _wrap_awaitable(awaitable): """Helper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). """ return (yield from awaitable.__await__()) class _GatheringFuture(futures.Future): """Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. """ def __init__(self, children, *, loop=None): super().__init__(loop=loop) self._children = children def cancel(self): if self.done(): return False ret = False for child in self._children: if child.cancel(): ret = True return ret def gather(*coros_or_futures, loop=None, return_exceptions=False): """Return a future aggregating results from the given coroutines or futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) """ if not coros_or_futures: if loop is None: loop = events.get_event_loop() outer = loop.create_future() outer.set_result([]) return outer arg_to_fut = {} for arg in set(coros_or_futures): if not futures.isfuture(arg): fut = ensure_future(arg, loop=loop) if loop is None: loop = fut._loop # The caller cannot control this future, the "destroy pending task" # warning should not be emitted. fut._log_destroy_pending = False else: fut = arg if loop is None: loop = fut._loop elif fut._loop is not loop: raise ValueError("futures are tied to different event loops") arg_to_fut[arg] = fut children = [arg_to_fut[arg] for arg in coros_or_futures] nchildren = len(children) outer = _GatheringFuture(children, loop=loop) nfinished = 0 results = [None] * nchildren def _done_callback(i, fut): nonlocal nfinished if outer.done(): if not fut.cancelled(): # Mark exception retrieved. fut.exception() return if fut.cancelled(): res = futures.CancelledError() if not return_exceptions: outer.set_exception(res) return elif fut._exception is not None: res = fut.exception() # Mark exception retrieved. if not return_exceptions: outer.set_exception(res) return else: res = fut._result results[i] = res nfinished += 1 if nfinished == nchildren: outer.set_result(results) for i, fut in enumerate(children): fut.add_done_callback(functools.partial(_done_callback, i)) return outer def shield(arg, *, loop=None): """Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None """ inner = ensure_future(arg, loop=loop) if inner.done(): # Shortcut. return inner loop = inner._loop outer = loop.create_future() def _done_callback(inner): if outer.cancelled(): if not inner.cancelled(): # Mark inner's result as retrieved. inner.exception() return if inner.cancelled(): outer.cancel() else: exc = inner.exception() if exc is not None: outer.set_exception(exc) else: outer.set_result(inner.result()) inner.add_done_callback(_done_callback) return outer def run_coroutine_threadsafe(coro, loop): """Submit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. """ if not coroutines.iscoroutine(coro): raise TypeError('A coroutine object is required') future = concurrent.futures.Future() def callback(): try: futures._chain_future(ensure_future(coro, loop=loop), future) except Exception as exc: if future.set_running_or_notify_cancel(): future.set_exception(exc) raise loop.call_soon_threadsafe(callback) return future PK!2 constants.pynu["""Constants.""" # After the connection is lost, log warnings after this many write()s. LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 # Seconds to wait before retrying accept(). ACCEPT_RETRY_DELAY = 1 PK!?^^ streams.pynu["""Stream-related things.""" __all__ = ['StreamReader', 'StreamWriter', 'StreamReaderProtocol', 'open_connection', 'start_server', 'IncompleteReadError', 'LimitOverrunError', ] import socket if hasattr(socket, 'AF_UNIX'): __all__.extend(['open_unix_connection', 'start_unix_server']) from . import coroutines from . import compat from . import events from . import protocols from .coroutines import coroutine from .log import logger _DEFAULT_LIMIT = 2 ** 16 class IncompleteReadError(EOFError): """ Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) """ def __init__(self, partial, expected): super().__init__("%d bytes read on a total of %r expected bytes" % (len(partial), expected)) self.partial = partial self.expected = expected class LimitOverrunError(Exception): """Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. """ def __init__(self, message, consumed): super().__init__(message) self.consumed = consumed @coroutine def open_connection(host=None, port=None, *, loop=None, limit=_DEFAULT_LIMIT, **kwds): """A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) """ if loop is None: loop = events.get_event_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = yield from loop.create_connection( lambda: protocol, host, port, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer @coroutine def start_server(client_connected_cb, host=None, port=None, *, loop=None, limit=_DEFAULT_LIMIT, **kwds): """Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. """ if loop is None: loop = events.get_event_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return (yield from loop.create_server(factory, host, port, **kwds)) if hasattr(socket, 'AF_UNIX'): # UNIX Domain Sockets are supported on this platform @coroutine def open_unix_connection(path=None, *, loop=None, limit=_DEFAULT_LIMIT, **kwds): """Similar to `open_connection` but works with UNIX Domain Sockets.""" if loop is None: loop = events.get_event_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = yield from loop.create_unix_connection( lambda: protocol, path, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer @coroutine def start_unix_server(client_connected_cb, path=None, *, loop=None, limit=_DEFAULT_LIMIT, **kwds): """Similar to `start_server` but works with UNIX Domain Sockets.""" if loop is None: loop = events.get_event_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return (yield from loop.create_unix_server(factory, path, **kwds)) class FlowControlMixin(protocols.Protocol): """Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. """ def __init__(self, loop=None): if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._paused = False self._drain_waiter = None self._connection_lost = False def pause_writing(self): assert not self._paused self._paused = True if self._loop.get_debug(): logger.debug("%r pauses writing", self) def resume_writing(self): assert self._paused self._paused = False if self._loop.get_debug(): logger.debug("%r resumes writing", self) waiter = self._drain_waiter if waiter is not None: self._drain_waiter = None if not waiter.done(): waiter.set_result(None) def connection_lost(self, exc): self._connection_lost = True # Wake up the writer if currently paused. if not self._paused: return waiter = self._drain_waiter if waiter is None: return self._drain_waiter = None if waiter.done(): return if exc is None: waiter.set_result(None) else: waiter.set_exception(exc) @coroutine def _drain_helper(self): if self._connection_lost: raise ConnectionResetError('Connection lost') if not self._paused: return waiter = self._drain_waiter assert waiter is None or waiter.cancelled() waiter = self._loop.create_future() self._drain_waiter = waiter yield from waiter class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): """Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) """ def __init__(self, stream_reader, client_connected_cb=None, loop=None): super().__init__(loop=loop) self._stream_reader = stream_reader self._stream_writer = None self._client_connected_cb = client_connected_cb self._over_ssl = False def connection_made(self, transport): self._stream_reader.set_transport(transport) self._over_ssl = transport.get_extra_info('sslcontext') is not None if self._client_connected_cb is not None: self._stream_writer = StreamWriter(transport, self, self._stream_reader, self._loop) res = self._client_connected_cb(self._stream_reader, self._stream_writer) if coroutines.iscoroutine(res): self._loop.create_task(res) def connection_lost(self, exc): if self._stream_reader is not None: if exc is None: self._stream_reader.feed_eof() else: self._stream_reader.set_exception(exc) super().connection_lost(exc) self._stream_reader = None self._stream_writer = None def data_received(self, data): self._stream_reader.feed_data(data) def eof_received(self): self._stream_reader.feed_eof() if self._over_ssl: # Prevent a warning in SSLProtocol.eof_received: # "returning true from eof_received() # has no effect when using ssl" return False return True class StreamWriter: """Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. """ def __init__(self, transport, protocol, reader, loop): self._transport = transport self._protocol = protocol # drain() expects that the reader has an exception() method assert reader is None or isinstance(reader, StreamReader) self._reader = reader self._loop = loop def __repr__(self): info = [self.__class__.__name__, 'transport=%r' % self._transport] if self._reader is not None: info.append('reader=%r' % self._reader) return '<%s>' % ' '.join(info) @property def transport(self): return self._transport def write(self, data): self._transport.write(data) def writelines(self, data): self._transport.writelines(data) def write_eof(self): return self._transport.write_eof() def can_write_eof(self): return self._transport.can_write_eof() def close(self): return self._transport.close() def get_extra_info(self, name, default=None): return self._transport.get_extra_info(name, default) @coroutine def drain(self): """Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() """ if self._reader is not None: exc = self._reader.exception() if exc is not None: raise exc if self._transport is not None: if self._transport.is_closing(): # Yield to the event loop so connection_lost() may be # called. Without this, _drain_helper() would return # immediately, and code that calls # write(...); yield from drain() # in a loop would never call connection_lost(), so it # would not see an error when the socket is closed. yield yield from self._protocol._drain_helper() class StreamReader: def __init__(self, limit=_DEFAULT_LIMIT, loop=None): # The line length limit is a security feature; # it also doubles as half the buffer limit. if limit <= 0: raise ValueError('Limit cannot be <= 0') self._limit = limit if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._buffer = bytearray() self._eof = False # Whether we're done. self._waiter = None # A future used by _wait_for_data() self._exception = None self._transport = None self._paused = False def __repr__(self): info = ['StreamReader'] if self._buffer: info.append('%d bytes' % len(self._buffer)) if self._eof: info.append('eof') if self._limit != _DEFAULT_LIMIT: info.append('l=%d' % self._limit) if self._waiter: info.append('w=%r' % self._waiter) if self._exception: info.append('e=%r' % self._exception) if self._transport: info.append('t=%r' % self._transport) if self._paused: info.append('paused') return '<%s>' % ' '.join(info) def exception(self): return self._exception def set_exception(self, exc): self._exception = exc waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_exception(exc) def _wakeup_waiter(self): """Wakeup read*() functions waiting for data or EOF.""" waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_result(None) def set_transport(self, transport): assert self._transport is None, 'Transport already set' self._transport = transport def _maybe_resume_transport(self): if self._paused and len(self._buffer) <= self._limit: self._paused = False self._transport.resume_reading() def feed_eof(self): self._eof = True self._wakeup_waiter() def at_eof(self): """Return True if the buffer is empty and 'feed_eof' was called.""" return self._eof and not self._buffer def feed_data(self, data): assert not self._eof, 'feed_data after feed_eof' if not data: return self._buffer.extend(data) self._wakeup_waiter() if (self._transport is not None and not self._paused and len(self._buffer) > 2 * self._limit): try: self._transport.pause_reading() except NotImplementedError: # The transport can't be paused. # We'll just have to buffer all data. # Forget the transport so we don't keep trying. self._transport = None else: self._paused = True @coroutine def _wait_for_data(self, func_name): """Wait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. """ # StreamReader uses a future to link the protocol feed_data() method # to a read coroutine. Running two read coroutines at the same time # would have an unexpected behaviour. It would not possible to know # which coroutine would get the next data. if self._waiter is not None: raise RuntimeError('%s() called while another coroutine is ' 'already waiting for incoming data' % func_name) assert not self._eof, '_wait_for_data after EOF' # Waiting for data while paused will make deadlock, so prevent it. # This is essential for readexactly(n) for case when n > self._limit. if self._paused: self._paused = False self._transport.resume_reading() self._waiter = self._loop.create_future() try: yield from self._waiter finally: self._waiter = None @coroutine def readline(self): """Read chunk of data from the stream until newline (b'\n') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. """ sep = b'\n' seplen = len(sep) try: line = yield from self.readuntil(sep) except IncompleteReadError as e: return e.partial except LimitOverrunError as e: if self._buffer.startswith(sep, e.consumed): del self._buffer[:e.consumed + seplen] else: self._buffer.clear() self._maybe_resume_transport() raise ValueError(e.args[0]) return line @coroutine def readuntil(self, separator=b'\n'): """Read data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. """ seplen = len(separator) if seplen == 0: raise ValueError('Separator should be at least one-byte string') if self._exception is not None: raise self._exception # Consume whole buffer except last bytes, which length is # one less than seplen. Let's check corner cases with # separator='SEPARATOR': # * we have received almost complete separator (without last # byte). i.e buffer='some textSEPARATO'. In this case we # can safely consume len(separator) - 1 bytes. # * last byte of buffer is first byte of separator, i.e. # buffer='abcdefghijklmnopqrS'. We may safely consume # everything except that last byte, but this require to # analyze bytes of buffer that match partial separator. # This is slow and/or require FSM. For this case our # implementation is not optimal, since require rescanning # of data that is known to not belong to separator. In # real world, separator will not be so long to notice # performance problems. Even when reading MIME-encoded # messages :) # `offset` is the number of bytes from the beginning of the buffer # where there is no occurrence of `separator`. offset = 0 # Loop until we find `separator` in the buffer, exceed the buffer size, # or an EOF has happened. while True: buflen = len(self._buffer) # Check if we now have enough data in the buffer for `separator` to # fit. if buflen - offset >= seplen: isep = self._buffer.find(separator, offset) if isep != -1: # `separator` is in the buffer. `isep` will be used later # to retrieve the data. break # see upper comment for explanation. offset = buflen + 1 - seplen if offset > self._limit: raise LimitOverrunError( 'Separator is not found, and chunk exceed the limit', offset) # Complete message (with full separator) may be present in buffer # even when EOF flag is set. This may happen when the last chunk # adds data which makes separator be found. That's why we check for # EOF *ater* inspecting the buffer. if self._eof: chunk = bytes(self._buffer) self._buffer.clear() raise IncompleteReadError(chunk, None) # _wait_for_data() will resume reading if stream was paused. yield from self._wait_for_data('readuntil') if isep > self._limit: raise LimitOverrunError( 'Separator is found, but chunk is longer than limit', isep) chunk = self._buffer[:isep + seplen] del self._buffer[:isep + seplen] self._maybe_resume_transport() return bytes(chunk) @coroutine def read(self, n=-1): """Read up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if self._exception is not None: raise self._exception if n == 0: return b'' if n < 0: # This used to just loop creating a new waiter hoping to # collect everything in self._buffer, but that would # deadlock if the subprocess sends more than self.limit # bytes. So just call self.read(self._limit) until EOF. blocks = [] while True: block = yield from self.read(self._limit) if not block: break blocks.append(block) return b''.join(blocks) if not self._buffer and not self._eof: yield from self._wait_for_data('read') # This will work right even if buffer is less than n bytes data = bytes(self._buffer[:n]) del self._buffer[:n] self._maybe_resume_transport() return data @coroutine def readexactly(self, n): """Read exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if n < 0: raise ValueError('readexactly size can not be less than zero') if self._exception is not None: raise self._exception if n == 0: return b'' while len(self._buffer) < n: if self._eof: incomplete = bytes(self._buffer) self._buffer.clear() raise IncompleteReadError(incomplete, n) yield from self._wait_for_data('readexactly') if len(self._buffer) == n: data = bytes(self._buffer) self._buffer.clear() else: data = bytes(self._buffer[:n]) del self._buffer[:n] self._maybe_resume_transport() return data if compat.PY35: @coroutine def __aiter__(self): return self @coroutine def __anext__(self): val = yield from self.readline() if val == b'': raise StopAsyncIteration return val if compat.PY352: # In Python 3.5.2 and greater, __aiter__ should return # the asynchronous iterator directly. def __aiter__(self): return self PK!  trsock.pynu[import socket import warnings class TransportSocket: """A socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. """ __slots__ = ('_sock',) def __init__(self, sock: socket.socket): self._sock = sock def _na(self, what): warnings.warn( f"Using {what} on sockets returned from get_extra_info('socket') " f"will be prohibited in asyncio 3.9. Please report your use case " f"to bugs.python.org.", DeprecationWarning, source=self) @property def family(self): return self._sock.family @property def type(self): return self._sock.type @property def proto(self): return self._sock.proto def __repr__(self): s = ( f"" def __getstate__(self): raise TypeError("Cannot serialize asyncio.TransportSocket object") def fileno(self): return self._sock.fileno() def dup(self): return self._sock.dup() def get_inheritable(self): return self._sock.get_inheritable() def shutdown(self, how): # asyncio doesn't currently provide a high-level transport API # to shutdown the connection. self._sock.shutdown(how) def getsockopt(self, *args, **kwargs): return self._sock.getsockopt(*args, **kwargs) def setsockopt(self, *args, **kwargs): self._sock.setsockopt(*args, **kwargs) def getpeername(self): return self._sock.getpeername() def getsockname(self): return self._sock.getsockname() def getsockbyname(self): return self._sock.getsockbyname() def accept(self): self._na('accept() method') return self._sock.accept() def connect(self, *args, **kwargs): self._na('connect() method') return self._sock.connect(*args, **kwargs) def connect_ex(self, *args, **kwargs): self._na('connect_ex() method') return self._sock.connect_ex(*args, **kwargs) def bind(self, *args, **kwargs): self._na('bind() method') return self._sock.bind(*args, **kwargs) def ioctl(self, *args, **kwargs): self._na('ioctl() method') return self._sock.ioctl(*args, **kwargs) def listen(self, *args, **kwargs): self._na('listen() method') return self._sock.listen(*args, **kwargs) def makefile(self): self._na('makefile() method') return self._sock.makefile() def sendfile(self, *args, **kwargs): self._na('sendfile() method') return self._sock.sendfile(*args, **kwargs) def close(self): self._na('close() method') return self._sock.close() def detach(self): self._na('detach() method') return self._sock.detach() def sendmsg_afalg(self, *args, **kwargs): self._na('sendmsg_afalg() method') return self._sock.sendmsg_afalg(*args, **kwargs) def sendmsg(self, *args, **kwargs): self._na('sendmsg() method') return self._sock.sendmsg(*args, **kwargs) def sendto(self, *args, **kwargs): self._na('sendto() method') return self._sock.sendto(*args, **kwargs) def send(self, *args, **kwargs): self._na('send() method') return self._sock.send(*args, **kwargs) def sendall(self, *args, **kwargs): self._na('sendall() method') return self._sock.sendall(*args, **kwargs) def set_inheritable(self, *args, **kwargs): self._na('set_inheritable() method') return self._sock.set_inheritable(*args, **kwargs) def share(self, process_id): self._na('share() method') return self._sock.share(process_id) def recv_into(self, *args, **kwargs): self._na('recv_into() method') return self._sock.recv_into(*args, **kwargs) def recvfrom_into(self, *args, **kwargs): self._na('recvfrom_into() method') return self._sock.recvfrom_into(*args, **kwargs) def recvmsg_into(self, *args, **kwargs): self._na('recvmsg_into() method') return self._sock.recvmsg_into(*args, **kwargs) def recvmsg(self, *args, **kwargs): self._na('recvmsg() method') return self._sock.recvmsg(*args, **kwargs) def recvfrom(self, *args, **kwargs): self._na('recvfrom() method') return self._sock.recvfrom(*args, **kwargs) def recv(self, *args, **kwargs): self._na('recv() method') return self._sock.recv(*args, **kwargs) def settimeout(self, value): if value == 0: return raise ValueError( 'settimeout(): only 0 timeout is allowed on transport sockets') def gettimeout(self): return 0 def setblocking(self, flag): if not flag: return raise ValueError( 'setblocking(): transport sockets cannot be blocking') def __enter__(self): self._na('context manager protocol') return self._sock.__enter__() def __exit__(self, *err): self._na('context manager protocol') return self._sock.__exit__(*err) PK!j1 queues.pynu["""Queues""" __all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty'] import collections import heapq from . import compat from . import events from . import locks from .coroutines import coroutine class QueueEmpty(Exception): """Exception raised when Queue.get_nowait() is called on a Queue object which is empty. """ pass class QueueFull(Exception): """Exception raised when the Queue.put_nowait() method is called on a Queue object which is full. """ pass class Queue: """A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. """ def __init__(self, maxsize=0, *, loop=None): if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._maxsize = maxsize # Futures. self._getters = collections.deque() # Futures. self._putters = collections.deque() self._unfinished_tasks = 0 self._finished = locks.Event(loop=self._loop) self._finished.set() self._init(maxsize) # These three are overridable in subclasses. def _init(self, maxsize): self._queue = collections.deque() def _get(self): return self._queue.popleft() def _put(self, item): self._queue.append(item) # End of the overridable methods. def _wakeup_next(self, waiters): # Wake up the next waiter (if any) that isn't cancelled. while waiters: waiter = waiters.popleft() if not waiter.done(): waiter.set_result(None) break def __repr__(self): return '<{} at {:#x} {}>'.format( type(self).__name__, id(self), self._format()) def __str__(self): return '<{} {}>'.format(type(self).__name__, self._format()) def _format(self): result = 'maxsize={!r}'.format(self._maxsize) if getattr(self, '_queue', None): result += ' _queue={!r}'.format(list(self._queue)) if self._getters: result += ' _getters[{}]'.format(len(self._getters)) if self._putters: result += ' _putters[{}]'.format(len(self._putters)) if self._unfinished_tasks: result += ' tasks={}'.format(self._unfinished_tasks) return result def qsize(self): """Number of items in the queue.""" return len(self._queue) @property def maxsize(self): """Number of items allowed in the queue.""" return self._maxsize def empty(self): """Return True if the queue is empty, False otherwise.""" return not self._queue def full(self): """Return True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. """ if self._maxsize <= 0: return False else: return self.qsize() >= self._maxsize @coroutine def put(self, item): """Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. """ while self.full(): putter = self._loop.create_future() self._putters.append(putter) try: yield from putter except: putter.cancel() # Just in case putter is not done yet. if not self.full() and not putter.cancelled(): # We were woken up by get_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._putters) raise return self.put_nowait(item) def put_nowait(self, item): """Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. """ if self.full(): raise QueueFull self._put(item) self._unfinished_tasks += 1 self._finished.clear() self._wakeup_next(self._getters) @coroutine def get(self): """Remove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. """ while self.empty(): getter = self._loop.create_future() self._getters.append(getter) try: yield from getter except: getter.cancel() # Just in case getter is not done yet. if not self.empty() and not getter.cancelled(): # We were woken up by put_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._getters) raise return self.get_nowait() def get_nowait(self): """Remove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. """ if self.empty(): raise QueueEmpty item = self._get() self._wakeup_next(self._putters) return item def task_done(self): """Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 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._finished.set() @coroutine def join(self): """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 calls 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, join() unblocks. """ if self._unfinished_tasks > 0: yield from self._finished.wait() class PriorityQueue(Queue): """A subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). """ def _init(self, maxsize): self._queue = [] def _put(self, item, heappush=heapq.heappush): heappush(self._queue, item) def _get(self, heappop=heapq.heappop): return heappop(self._queue) class LifoQueue(Queue): """A subclass of Queue that retrieves most recently added entries first.""" def _init(self, maxsize): self._queue = [] def _put(self, item): self._queue.append(item) def _get(self): return self._queue.pop() if not compat.PY35: JoinableQueue = Queue """Deprecated alias for Queue.""" __all__.append('JoinableQueue') PK!$}]#]#base_subprocess.pynu[import collections import subprocess import warnings from . import compat from . import protocols from . import transports from .coroutines import coroutine from .log import logger class BaseSubprocessTransport(transports.SubprocessTransport): def __init__(self, loop, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=None, extra=None, **kwargs): super().__init__(extra) self._closed = False self._protocol = protocol self._loop = loop self._proc = None self._pid = None self._returncode = None self._exit_waiters = [] self._pending_calls = collections.deque() self._pipes = {} self._finished = False if stdin == subprocess.PIPE: self._pipes[0] = None if stdout == subprocess.PIPE: self._pipes[1] = None if stderr == subprocess.PIPE: self._pipes[2] = None # Create the child process: set the _proc attribute try: self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) except: self.close() raise self._pid = self._proc.pid self._extra['subprocess'] = self._proc if self._loop.get_debug(): if isinstance(args, (bytes, str)): program = args else: program = args[0] logger.debug('process %r created: pid %s', program, self._pid) self._loop.create_task(self._connect_pipes(waiter)) def __repr__(self): info = [self.__class__.__name__] if self._closed: info.append('closed') if self._pid is not None: info.append('pid=%s' % self._pid) if self._returncode is not None: info.append('returncode=%s' % self._returncode) elif self._pid is not None: info.append('running') else: info.append('not started') stdin = self._pipes.get(0) if stdin is not None: info.append('stdin=%s' % stdin.pipe) stdout = self._pipes.get(1) stderr = self._pipes.get(2) if stdout is not None and stderr is stdout: info.append('stdout=stderr=%s' % stdout.pipe) else: if stdout is not None: info.append('stdout=%s' % stdout.pipe) if stderr is not None: info.append('stderr=%s' % stderr.pipe) return '<%s>' % ' '.join(info) def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): raise NotImplementedError def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closed def close(self): if self._closed: return self._closed = True for proto in self._pipes.values(): if proto is None: continue proto.pipe.close() if (self._proc is not None # the child process finished? and self._returncode is None # the child process finished but the transport was not notified yet? and self._proc.poll() is None ): if self._loop.get_debug(): logger.warning('Close running child process: kill %r', self) try: self._proc.kill() except ProcessLookupError: pass # Don't clear the _proc reference yet: _post_init() may still run # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if not self._closed: warnings.warn("unclosed transport %r" % self, ResourceWarning) self.close() def get_pid(self): return self._pid def get_returncode(self): return self._returncode def get_pipe_transport(self, fd): if fd in self._pipes: return self._pipes[fd].pipe else: return None def _check_proc(self): if self._proc is None: raise ProcessLookupError() def send_signal(self, signal): self._check_proc() self._proc.send_signal(signal) def terminate(self): self._check_proc() self._proc.terminate() def kill(self): self._check_proc() self._proc.kill() @coroutine def _connect_pipes(self, waiter): try: proc = self._proc loop = self._loop if proc.stdin is not None: _, pipe = yield from loop.connect_write_pipe( lambda: WriteSubprocessPipeProto(self, 0), proc.stdin) self._pipes[0] = pipe if proc.stdout is not None: _, pipe = yield from loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 1), proc.stdout) self._pipes[1] = pipe if proc.stderr is not None: _, pipe = yield from loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 2), proc.stderr) self._pipes[2] = pipe assert self._pending_calls is not None loop.call_soon(self._protocol.connection_made, self) for callback, data in self._pending_calls: loop.call_soon(callback, *data) self._pending_calls = None except Exception as exc: if waiter is not None and not waiter.cancelled(): waiter.set_exception(exc) else: if waiter is not None and not waiter.cancelled(): waiter.set_result(None) def _call(self, cb, *data): if self._pending_calls is not None: self._pending_calls.append((cb, data)) else: self._loop.call_soon(cb, *data) def _pipe_connection_lost(self, fd, exc): self._call(self._protocol.pipe_connection_lost, fd, exc) self._try_finish() def _pipe_data_received(self, fd, data): self._call(self._protocol.pipe_data_received, fd, data) def _process_exited(self, returncode): assert returncode is not None, returncode assert self._returncode is None, self._returncode if self._loop.get_debug(): logger.info('%r exited with return code %r', self, returncode) self._returncode = returncode if self._proc.returncode is None: # asyncio uses a child watcher: copy the status into the Popen # object. On Python 3.6, it is required to avoid a ResourceWarning. self._proc.returncode = returncode self._call(self._protocol.process_exited) self._try_finish() # wake up futures waiting for wait() for waiter in self._exit_waiters: if not waiter.cancelled(): waiter.set_result(returncode) self._exit_waiters = None @coroutine def _wait(self): """Wait until the process exit and return the process return code. This method is a coroutine.""" if self._returncode is not None: return self._returncode waiter = self._loop.create_future() self._exit_waiters.append(waiter) return (yield from waiter) def _try_finish(self): assert not self._finished if self._returncode is None: return if all(p is not None and p.disconnected for p in self._pipes.values()): self._finished = True self._call(self._call_connection_lost, None) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._loop = None self._proc = None self._protocol = None class WriteSubprocessPipeProto(protocols.BaseProtocol): def __init__(self, proc, fd): self.proc = proc self.fd = fd self.pipe = None self.disconnected = False def connection_made(self, transport): self.pipe = transport def __repr__(self): return ('<%s fd=%s pipe=%r>' % (self.__class__.__name__, self.fd, self.pipe)) def connection_lost(self, exc): self.disconnected = True self.proc._pipe_connection_lost(self.fd, exc) self.proc = None def pause_writing(self): self.proc._protocol.pause_writing() def resume_writing(self): self.proc._protocol.resume_writing() class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): def data_received(self, data): self.proc._pipe_data_received(self.fd, data) PK!L2base_events.pynu["""Base implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. """ import collections import concurrent.futures import heapq import inspect import itertools import logging import os import socket import subprocess import threading import time import traceback import sys import warnings import weakref from . import compat from . import coroutines from . import events from . import futures from . import tasks from .coroutines import coroutine from .log import logger __all__ = ['BaseEventLoop'] # Minimum number of _scheduled timer handles before cleanup of # cancelled handles is performed. _MIN_SCHEDULED_TIMER_HANDLES = 100 # Minimum fraction of _scheduled timer handles that are cancelled # before cleanup of cancelled handles is performed. _MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5 # Exceptions which must not call the exception handler in fatal error # methods (_fatal_error()) _FATAL_ERROR_IGNORE = (BrokenPipeError, ConnectionResetError, ConnectionAbortedError) def _format_handle(handle): cb = handle._callback if inspect.ismethod(cb) and isinstance(cb.__self__, tasks.Task): # format the task return repr(cb.__self__) else: return str(handle) def _format_pipe(fd): if fd == subprocess.PIPE: return '' elif fd == subprocess.STDOUT: return '' else: return repr(fd) def _set_reuseport(sock): if not hasattr(socket, 'SO_REUSEPORT'): raise ValueError('reuse_port not supported by socket module') else: try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except OSError: raise ValueError('reuse_port not supported by socket module, ' 'SO_REUSEPORT defined but not implemented.') def _is_stream_socket(sock): # Linux's socket.type is a bitmask that can include extra info # about socket, therefore we can't do simple # `sock_type == socket.SOCK_STREAM`. return (sock.type & socket.SOCK_STREAM) == socket.SOCK_STREAM def _is_dgram_socket(sock): # Linux's socket.type is a bitmask that can include extra info # about socket, therefore we can't do simple # `sock_type == socket.SOCK_DGRAM`. return (sock.type & socket.SOCK_DGRAM) == socket.SOCK_DGRAM def _ipaddr_info(host, port, family, type, proto): # Try to skip getaddrinfo if "host" is already an IP. Users might have # handled name resolution in their own code and pass in resolved IPs. if not hasattr(socket, 'inet_pton'): return if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or \ host is None: return None if type == socket.SOCK_STREAM: # Linux only: # getaddrinfo() can raise when socket.type is a bit mask. # So if socket.type is a bit mask of SOCK_STREAM, and say # SOCK_NONBLOCK, we simply return None, which will trigger # a call to getaddrinfo() letting it process this request. proto = socket.IPPROTO_TCP elif type == socket.SOCK_DGRAM: proto = socket.IPPROTO_UDP else: return None if port is None: port = 0 elif isinstance(port, bytes) and port == b'': port = 0 elif isinstance(port, str) and port == '': port = 0 else: # If port's a service name like "http", don't skip getaddrinfo. try: port = int(port) except (TypeError, ValueError): return None if family == socket.AF_UNSPEC: afs = [socket.AF_INET] if hasattr(socket, 'AF_INET6'): afs.append(socket.AF_INET6) else: afs = [family] if isinstance(host, bytes): host = host.decode('idna') if '%' in host: # Linux's inet_pton doesn't accept an IPv6 zone index after host, # like '::1%lo0'. return None for af in afs: try: socket.inet_pton(af, host) # The host has already been resolved. return af, type, proto, '', (host, port) except OSError: pass # "host" is not an IP address. return None def _ensure_resolved(address, *, family=0, type=socket.SOCK_STREAM, proto=0, flags=0, loop): host, port = address[:2] info = _ipaddr_info(host, port, family, type, proto) if info is not None: # "host" is already a resolved IP. fut = loop.create_future() fut.set_result([info]) return fut else: return loop.getaddrinfo(host, port, family=family, type=type, proto=proto, flags=flags) def _run_until_complete_cb(fut): exc = fut._exception if (isinstance(exc, BaseException) and not isinstance(exc, Exception)): # Issue #22429: run_forever() already finished, no need to # stop it. return fut._loop.stop() class Server(events.AbstractServer): def __init__(self, loop, sockets): self._loop = loop self.sockets = sockets self._active_count = 0 self._waiters = [] def __repr__(self): return '<%s sockets=%r>' % (self.__class__.__name__, self.sockets) def _attach(self): assert self.sockets is not None self._active_count += 1 def _detach(self): assert self._active_count > 0 self._active_count -= 1 if self._active_count == 0 and self.sockets is None: self._wakeup() def close(self): sockets = self.sockets if sockets is None: return self.sockets = None for sock in sockets: self._loop._stop_serving(sock) if self._active_count == 0: self._wakeup() def _wakeup(self): waiters = self._waiters self._waiters = None for waiter in waiters: if not waiter.done(): waiter.set_result(waiter) @coroutine def wait_closed(self): if self.sockets is None or self._waiters is None: return waiter = self._loop.create_future() self._waiters.append(waiter) yield from waiter class BaseEventLoop(events.AbstractEventLoop): def __init__(self): self._timer_cancelled_count = 0 self._closed = False self._stopping = False self._ready = collections.deque() self._scheduled = [] self._default_executor = None self._internal_fds = 0 # Identifier of the thread running the event loop, or None if the # event loop is not running self._thread_id = None self._clock_resolution = time.get_clock_info('monotonic').resolution self._exception_handler = None self.set_debug((not sys.flags.ignore_environment and bool(os.environ.get('PYTHONASYNCIODEBUG')))) # In debug mode, if the execution of a callback or a step of a task # exceed this duration in seconds, the slow callback/task is logged. self.slow_callback_duration = 0.1 self._current_handle = None self._task_factory = None self._coroutine_wrapper_set = False if hasattr(sys, 'get_asyncgen_hooks'): # Python >= 3.6 # A weak set of all asynchronous generators that are # being iterated by the loop. self._asyncgens = weakref.WeakSet() else: self._asyncgens = None # Set to True when `loop.shutdown_asyncgens` is called. self._asyncgens_shutdown_called = False def __repr__(self): return ('<%s running=%s closed=%s debug=%s>' % (self.__class__.__name__, self.is_running(), self.is_closed(), self.get_debug())) def create_future(self): """Create a Future object attached to the loop.""" return futures.Future(loop=self) def create_task(self, coro): """Schedule a coroutine object. Return a task object. """ self._check_closed() if self._task_factory is None: task = tasks.Task(coro, loop=self) if task._source_traceback: del task._source_traceback[-1] else: task = self._task_factory(self, coro) return task def set_task_factory(self, factory): """Set a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. """ if factory is not None and not callable(factory): raise TypeError('task factory must be a callable or None') self._task_factory = factory def get_task_factory(self): """Return a task factory, or None if the default one is in use.""" return self._task_factory def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): """Create socket transport.""" raise NotImplementedError def _make_ssl_transport(self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None): """Create SSL transport.""" raise NotImplementedError def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): """Create datagram transport.""" raise NotImplementedError def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create read pipe transport.""" raise NotImplementedError def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create write pipe transport.""" raise NotImplementedError @coroutine def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): """Create subprocess transport.""" raise NotImplementedError def _write_to_self(self): """Write a byte to self-pipe, to wake up the event loop. This may be called from a different thread. The subclass is responsible for implementing the self-pipe. """ raise NotImplementedError def _process_events(self, event_list): """Process selector events.""" raise NotImplementedError def _check_closed(self): if self._closed: raise RuntimeError('Event loop is closed') def _asyncgen_finalizer_hook(self, agen): self._asyncgens.discard(agen) if not self.is_closed(): self.create_task(agen.aclose()) # Wake up the loop if the finalizer was called from # a different thread. self._write_to_self() def _asyncgen_firstiter_hook(self, agen): if self._asyncgens_shutdown_called: warnings.warn( "asynchronous generator {!r} was scheduled after " "loop.shutdown_asyncgens() call".format(agen), ResourceWarning, source=self) self._asyncgens.add(agen) @coroutine def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" self._asyncgens_shutdown_called = True if self._asyncgens is None or not len(self._asyncgens): # If Python version is <3.6 or we don't have any asynchronous # generators alive. return closing_agens = list(self._asyncgens) self._asyncgens.clear() shutdown_coro = tasks.gather( *[ag.aclose() for ag in closing_agens], return_exceptions=True, loop=self) results = yield from shutdown_coro for result, agen in zip(results, closing_agens): if isinstance(result, Exception): self.call_exception_handler({ 'message': 'an error occurred during closing of ' 'asynchronous generator {!r}'.format(agen), 'exception': result, 'asyncgen': agen }) def run_forever(self): """Run until stop() is called.""" self._check_closed() if self.is_running(): raise RuntimeError('This event loop is already running') if events._get_running_loop() is not None: raise RuntimeError( 'Cannot run the event loop while another loop is running') self._set_coroutine_wrapper(self._debug) self._thread_id = threading.get_ident() if self._asyncgens is not None: old_agen_hooks = sys.get_asyncgen_hooks() sys.set_asyncgen_hooks(firstiter=self._asyncgen_firstiter_hook, finalizer=self._asyncgen_finalizer_hook) try: events._set_running_loop(self) while True: self._run_once() if self._stopping: break finally: self._stopping = False self._thread_id = None events._set_running_loop(None) self._set_coroutine_wrapper(False) if self._asyncgens is not None: sys.set_asyncgen_hooks(*old_agen_hooks) def run_until_complete(self, future): """Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. """ self._check_closed() new_task = not futures.isfuture(future) future = tasks.ensure_future(future, loop=self) if new_task: # An exception is raised if the future didn't complete, so there # is no need to log the "destroy pending task" message future._log_destroy_pending = False future.add_done_callback(_run_until_complete_cb) try: self.run_forever() except: if new_task and future.done() and not future.cancelled(): # The coroutine raised a BaseException. Consume the exception # to not log a warning, the caller doesn't have access to the # local task. future.exception() raise finally: future.remove_done_callback(_run_until_complete_cb) if not future.done(): raise RuntimeError('Event loop stopped before Future completed.') return future.result() def stop(self): """Stop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. """ self._stopping = True def close(self): """Close the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. """ if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self._closed: return if self._debug: logger.debug("Close %r", self) self._closed = True self._ready.clear() self._scheduled.clear() executor = self._default_executor if executor is not None: self._default_executor = None executor.shutdown(wait=False) def is_closed(self): """Returns True if the event loop was closed.""" return self._closed # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if not self.is_closed(): warnings.warn("unclosed event loop %r" % self, ResourceWarning) if not self.is_running(): self.close() def is_running(self): """Returns True if the event loop is running.""" return (self._thread_id is not None) def time(self): """Return the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. """ return time.monotonic() def call_later(self, delay, callback, *args): """Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. """ timer = self.call_at(self.time() + delay, callback, *args) if timer._source_traceback: del timer._source_traceback[-1] return timer def call_at(self, when, callback, *args): """Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. """ self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_at') timer = events.TimerHandle(when, callback, args, self) if timer._source_traceback: del timer._source_traceback[-1] heapq.heappush(self._scheduled, timer) timer._scheduled = True return timer def call_soon(self, callback, *args): """Arrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. """ self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_soon') handle = self._call_soon(callback, args) if handle._source_traceback: del handle._source_traceback[-1] return handle def _check_callback(self, callback, method): if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError( "coroutines cannot be used with {}()".format(method)) if not callable(callback): raise TypeError( 'a callable object was expected by {}(), got {!r}'.format( method, callback)) def _call_soon(self, callback, args): handle = events.Handle(callback, args, self) if handle._source_traceback: del handle._source_traceback[-1] self._ready.append(handle) return handle def _check_thread(self): """Check that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. """ if self._thread_id is None: return thread_id = threading.get_ident() if thread_id != self._thread_id: raise RuntimeError( "Non-thread-safe operation invoked on an event loop other " "than the current one") def call_soon_threadsafe(self, callback, *args): """Like call_soon(), but thread-safe.""" self._check_closed() if self._debug: self._check_callback(callback, 'call_soon_threadsafe') handle = self._call_soon(callback, args) if handle._source_traceback: del handle._source_traceback[-1] self._write_to_self() return handle def run_in_executor(self, executor, func, *args): self._check_closed() if self._debug: self._check_callback(func, 'run_in_executor') if executor is None: executor = self._default_executor if executor is None: executor = concurrent.futures.ThreadPoolExecutor() self._default_executor = executor return futures.wrap_future(executor.submit(func, *args), loop=self) def set_default_executor(self, executor): self._default_executor = executor def _getaddrinfo_debug(self, host, port, family, type, proto, flags): msg = ["%s:%r" % (host, port)] if family: msg.append('family=%r' % family) if type: msg.append('type=%r' % type) if proto: msg.append('proto=%r' % proto) if flags: msg.append('flags=%r' % flags) msg = ', '.join(msg) logger.debug('Get address info %s', msg) t0 = self.time() addrinfo = socket.getaddrinfo(host, port, family, type, proto, flags) dt = self.time() - t0 msg = ('Getting address info %s took %.3f ms: %r' % (msg, dt * 1e3, addrinfo)) if dt >= self.slow_callback_duration: logger.info(msg) else: logger.debug(msg) return addrinfo def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): if self._debug: return self.run_in_executor(None, self._getaddrinfo_debug, host, port, family, type, proto, flags) else: return self.run_in_executor(None, socket.getaddrinfo, host, port, family, type, proto, flags) def getnameinfo(self, sockaddr, flags=0): return self.run_in_executor(None, socket.getnameinfo, sockaddr, flags) @coroutine def create_connection(self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None): """Connect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. """ if server_hostname is not None and not ssl: raise ValueError('server_hostname is only meaningful with ssl') if server_hostname is None and ssl: # Use host as default for server_hostname. It is an error # if host is empty or not set, e.g. when an # already-connected socket was passed or when only a port # is given. To avoid this error, you can pass # server_hostname='' -- this will bypass the hostname # check. (This also means that if host is a numeric # IP/IPv6 address, we will attempt to verify that exact # address; this will probably fail, but it is possible to # create a certificate for a specific IP address, so we # don't judge it here.) if not host: raise ValueError('You must set server_hostname ' 'when using ssl without a host') server_hostname = host if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') f1 = _ensure_resolved((host, port), family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) fs = [f1] if local_addr is not None: f2 = _ensure_resolved(local_addr, family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) fs.append(f2) else: f2 = None yield from tasks.wait(fs, loop=self) infos = f1.result() if not infos: raise OSError('getaddrinfo() returned empty list') if f2 is not None: laddr_infos = f2.result() if not laddr_infos: raise OSError('getaddrinfo() returned empty list') exceptions = [] for family, type, proto, cname, address in infos: try: sock = socket.socket(family=family, type=type, proto=proto) sock.setblocking(False) if f2 is not None: for _, _, _, _, laddr in laddr_infos: try: sock.bind(laddr) break except OSError as exc: exc = OSError( exc.errno, 'error while ' 'attempting to bind on address ' '{!r}: {}'.format( laddr, exc.strerror.lower())) exceptions.append(exc) else: sock.close() sock = None continue if self._debug: logger.debug("connect %r to %r", sock, address) yield from self.sock_connect(sock, address) except OSError as exc: if sock is not None: sock.close() exceptions.append(exc) except: if sock is not None: sock.close() raise else: break else: if len(exceptions) == 1: raise exceptions[0] else: # If they all have the same str(), raise one. model = str(exceptions[0]) if all(str(exc) == model for exc in exceptions): raise exceptions[0] # Raise a combined exception so the user can see all # the various error messages. raise OSError('Multiple exceptions: {}'.format( ', '.join(str(exc) for exc in exceptions))) else: if sock is None: raise ValueError( 'host and port was not specified and no sock specified') if not _is_stream_socket(sock): # We allow AF_INET, AF_INET6, AF_UNIX as long as they # are SOCK_STREAM. # We support passing AF_UNIX sockets even though we have # a dedicated API for that: create_unix_connection. # Disallowing AF_UNIX in this method, breaks backwards # compatibility. raise ValueError( 'A Stream Socket was expected, got {!r}'.format(sock)) transport, protocol = yield from self._create_connection_transport( sock, protocol_factory, ssl, server_hostname) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r connected to %s:%r: (%r, %r)", sock, host, port, transport, protocol) return transport, protocol @coroutine def _create_connection_transport(self, sock, protocol_factory, ssl, server_hostname, server_side=False): sock.setblocking(False) protocol = protocol_factory() waiter = self.create_future() if ssl: sslcontext = None if isinstance(ssl, bool) else ssl transport = self._make_ssl_transport( sock, protocol, sslcontext, waiter, server_side=server_side, server_hostname=server_hostname) else: transport = self._make_socket_transport(sock, protocol, waiter) try: yield from waiter except: transport.close() raise return transport, protocol @coroutine def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None): """Create datagram connection.""" if sock is not None: if not _is_dgram_socket(sock): raise ValueError( 'A UDP Socket was expected, got {!r}'.format(sock)) if (local_addr or remote_addr or family or proto or flags or reuse_address or reuse_port or allow_broadcast): # show the problematic kwargs in exception msg opts = dict(local_addr=local_addr, remote_addr=remote_addr, family=family, proto=proto, flags=flags, reuse_address=reuse_address, reuse_port=reuse_port, allow_broadcast=allow_broadcast) problems = ', '.join( '{}={}'.format(k, v) for k, v in opts.items() if v) raise ValueError( 'socket modifier keyword arguments can not be used ' 'when sock is specified. ({})'.format(problems)) sock.setblocking(False) r_addr = None else: if not (local_addr or remote_addr): if family == 0: raise ValueError('unexpected address family') addr_pairs_info = (((family, proto), (None, None)),) else: # join address by (family, protocol) addr_infos = collections.OrderedDict() for idx, addr in ((0, local_addr), (1, remote_addr)): if addr is not None: assert isinstance(addr, tuple) and len(addr) == 2, ( '2-tuple is expected') infos = yield from _ensure_resolved( addr, family=family, type=socket.SOCK_DGRAM, proto=proto, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo() returned empty list') for fam, _, pro, _, address in infos: key = (fam, pro) if key not in addr_infos: addr_infos[key] = [None, None] addr_infos[key][idx] = address # each addr has to have info for each (family, proto) pair addr_pairs_info = [ (key, addr_pair) for key, addr_pair in addr_infos.items() if not ((local_addr and addr_pair[0] is None) or (remote_addr and addr_pair[1] is None))] if not addr_pairs_info: raise ValueError('can not get address information') exceptions = [] if reuse_address is None: reuse_address = os.name == 'posix' and sys.platform != 'cygwin' for ((family, proto), (local_address, remote_address)) in addr_pairs_info: sock = None r_addr = None try: sock = socket.socket( family=family, type=socket.SOCK_DGRAM, proto=proto) if reuse_address: sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) if reuse_port: _set_reuseport(sock) if allow_broadcast: sock.setsockopt( socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.setblocking(False) if local_addr: sock.bind(local_address) if remote_addr: yield from self.sock_connect(sock, remote_address) r_addr = remote_address except OSError as exc: if sock is not None: sock.close() exceptions.append(exc) except: if sock is not None: sock.close() raise else: break else: raise exceptions[0] protocol = protocol_factory() waiter = self.create_future() transport = self._make_datagram_transport( sock, protocol, r_addr, waiter) if self._debug: if local_addr: logger.info("Datagram endpoint local_addr=%r remote_addr=%r " "created: (%r, %r)", local_addr, remote_addr, transport, protocol) else: logger.debug("Datagram endpoint remote_addr=%r created: " "(%r, %r)", remote_addr, transport, protocol) try: yield from waiter except: transport.close() raise return transport, protocol @coroutine def _create_server_getaddrinfo(self, host, port, family, flags): infos = yield from _ensure_resolved((host, port), family=family, type=socket.SOCK_STREAM, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo({!r}) returned empty list'.format(host)) return infos @coroutine def create_server(self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None): """Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. """ if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') AF_INET6 = getattr(socket, 'AF_INET6', 0) if reuse_address is None: reuse_address = os.name == 'posix' and sys.platform != 'cygwin' sockets = [] if host == '': hosts = [None] elif (isinstance(host, str) or not isinstance(host, collections.Iterable)): hosts = [host] else: hosts = host fs = [self._create_server_getaddrinfo(host, port, family=family, flags=flags) for host in hosts] infos = yield from tasks.gather(*fs, loop=self) infos = set(itertools.chain.from_iterable(infos)) completed = False try: for res in infos: af, socktype, proto, canonname, sa = res try: sock = socket.socket(af, socktype, proto) except socket.error: # Assume it's a bad family/type/protocol combination. if self._debug: logger.warning('create_server() failed to create ' 'socket.socket(%r, %r, %r)', af, socktype, proto, exc_info=True) continue sockets.append(sock) if reuse_address: sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, True) if reuse_port: _set_reuseport(sock) # Disable IPv4/IPv6 dual stack support (enabled by # default on Linux) which makes a single socket # listen on both address families. if af == AF_INET6 and hasattr(socket, 'IPPROTO_IPV6'): sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, True) try: sock.bind(sa) except OSError as err: raise OSError(err.errno, 'error while attempting ' 'to bind on address %r: %s' % (sa, err.strerror.lower())) completed = True finally: if not completed: for sock in sockets: sock.close() else: if sock is None: raise ValueError('Neither host/port nor sock were specified') if not _is_stream_socket(sock): raise ValueError( 'A Stream Socket was expected, got {!r}'.format(sock)) sockets = [sock] server = Server(self, sockets) for sock in sockets: sock.listen(backlog) sock.setblocking(False) self._start_serving(protocol_factory, sock, ssl, server, backlog) if self._debug: logger.info("%r is serving", server) return server @coroutine def connect_accepted_socket(self, protocol_factory, sock, *, ssl=None): """Handle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. """ if not _is_stream_socket(sock): raise ValueError( 'A Stream Socket was expected, got {!r}'.format(sock)) transport, protocol = yield from self._create_connection_transport( sock, protocol_factory, ssl, '', server_side=True) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r handled: (%r, %r)", sock, transport, protocol) return transport, protocol @coroutine def connect_read_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_read_pipe_transport(pipe, protocol, waiter) try: yield from waiter except: transport.close() raise if self._debug: logger.debug('Read pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol @coroutine def connect_write_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_write_pipe_transport(pipe, protocol, waiter) try: yield from waiter except: transport.close() raise if self._debug: logger.debug('Write pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol def _log_subprocess(self, msg, stdin, stdout, stderr): info = [msg] if stdin is not None: info.append('stdin=%s' % _format_pipe(stdin)) if stdout is not None and stderr == subprocess.STDOUT: info.append('stdout=stderr=%s' % _format_pipe(stdout)) else: if stdout is not None: info.append('stdout=%s' % _format_pipe(stdout)) if stderr is not None: info.append('stderr=%s' % _format_pipe(stderr)) logger.debug(' '.join(info)) @coroutine def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=True, bufsize=0, **kwargs): if not isinstance(cmd, (bytes, str)): raise ValueError("cmd must be a string") if universal_newlines: raise ValueError("universal_newlines must be False") if not shell: raise ValueError("shell must be True") if bufsize != 0: raise ValueError("bufsize must be 0") protocol = protocol_factory() if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = 'run shell command %r' % cmd self._log_subprocess(debug_log, stdin, stdout, stderr) transport = yield from self._make_subprocess_transport( protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs) if self._debug: logger.info('%s: %r', debug_log, transport) return transport, protocol @coroutine def subprocess_exec(self, protocol_factory, program, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=False, bufsize=0, **kwargs): if universal_newlines: raise ValueError("universal_newlines must be False") if shell: raise ValueError("shell must be False") if bufsize != 0: raise ValueError("bufsize must be 0") popen_args = (program,) + args for arg in popen_args: if not isinstance(arg, (str, bytes)): raise TypeError("program arguments must be " "a bytes or text string, not %s" % type(arg).__name__) protocol = protocol_factory() if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = 'execute program %r' % program self._log_subprocess(debug_log, stdin, stdout, stderr) transport = yield from self._make_subprocess_transport( protocol, popen_args, False, stdin, stdout, stderr, bufsize, **kwargs) if self._debug: logger.info('%s: %r', debug_log, transport) return transport, protocol def get_exception_handler(self): """Return an exception handler, or None if the default one is in use. """ return self._exception_handler def set_exception_handler(self, handler): """Set handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). """ if handler is not None and not callable(handler): raise TypeError('A callable object or None is expected, ' 'got {!r}'.format(handler)) self._exception_handler = handler def default_exception_handler(self, context): """Default exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. The context parameter has the same meaning as in `call_exception_handler()`. """ message = context.get('message') if not message: message = 'Unhandled exception in event loop' exception = context.get('exception') if exception is not None: exc_info = (type(exception), exception, exception.__traceback__) else: exc_info = False if ('source_traceback' not in context and self._current_handle is not None and self._current_handle._source_traceback): context['handle_traceback'] = self._current_handle._source_traceback log_lines = [message] for key in sorted(context): if key in {'message', 'exception'}: continue value = context[key] if key == 'source_traceback': tb = ''.join(traceback.format_list(value)) value = 'Object created at (most recent call last):\n' value += tb.rstrip() elif key == 'handle_traceback': tb = ''.join(traceback.format_list(value)) value = 'Handle created at (most recent call last):\n' value += tb.rstrip() else: value = repr(value) log_lines.append('{}: {}'.format(key, value)) logger.error('\n'.join(log_lines), exc_info=exc_info) def call_exception_handler(self, context): """Call the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. """ if self._exception_handler is None: try: self.default_exception_handler(context) except Exception: # Second protection layer for unexpected errors # in the default implementation, as well as for subclassed # event loops with overloaded "default_exception_handler". logger.error('Exception in default exception handler', exc_info=True) else: try: self._exception_handler(self, context) except Exception as exc: # Exception in the user set custom exception handler. try: # Let's try default handler. self.default_exception_handler({ 'message': 'Unhandled error in exception handler', 'exception': exc, 'context': context, }) except Exception: # Guard 'default_exception_handler' in case it is # overloaded. logger.error('Exception in default exception handler ' 'while handling an unexpected error ' 'in custom exception handler', exc_info=True) def _add_callback(self, handle): """Add a Handle to _scheduled (TimerHandle) or _ready.""" assert isinstance(handle, events.Handle), 'A Handle is required here' if handle._cancelled: return assert not isinstance(handle, events.TimerHandle) self._ready.append(handle) def _add_callback_signalsafe(self, handle): """Like _add_callback() but called from a signal handler.""" self._add_callback(handle) self._write_to_self() def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" if handle._scheduled: self._timer_cancelled_count += 1 def _run_once(self): """Run one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. """ sched_count = len(self._scheduled) if (sched_count > _MIN_SCHEDULED_TIMER_HANDLES and self._timer_cancelled_count / sched_count > _MIN_CANCELLED_TIMER_HANDLES_FRACTION): # Remove delayed calls that were cancelled if their number # is too high new_scheduled = [] for handle in self._scheduled: if handle._cancelled: handle._scheduled = False else: new_scheduled.append(handle) heapq.heapify(new_scheduled) self._scheduled = new_scheduled self._timer_cancelled_count = 0 else: # Remove delayed calls that were cancelled from head of queue. while self._scheduled and self._scheduled[0]._cancelled: self._timer_cancelled_count -= 1 handle = heapq.heappop(self._scheduled) handle._scheduled = False timeout = None if self._ready or self._stopping: timeout = 0 elif self._scheduled: # Compute the desired timeout. when = self._scheduled[0]._when timeout = max(0, when - self.time()) if self._debug and timeout != 0: t0 = self.time() event_list = self._selector.select(timeout) dt = self.time() - t0 if dt >= 1.0: level = logging.INFO else: level = logging.DEBUG nevent = len(event_list) if timeout is None: logger.log(level, 'poll took %.3f ms: %s events', dt * 1e3, nevent) elif nevent: logger.log(level, 'poll %.3f ms took %.3f ms: %s events', timeout * 1e3, dt * 1e3, nevent) elif dt >= 1.0: logger.log(level, 'poll %.3f ms took %.3f ms: timeout', timeout * 1e3, dt * 1e3) else: event_list = self._selector.select(timeout) self._process_events(event_list) # Handle 'later' callbacks that are ready. end_time = self.time() + self._clock_resolution while self._scheduled: handle = self._scheduled[0] if handle._when >= end_time: break handle = heapq.heappop(self._scheduled) handle._scheduled = False self._ready.append(handle) # This is the only place where callbacks are actually *called*. # All other places just add them to ready. # Note: We run all currently scheduled callbacks, but not any # callbacks scheduled by callbacks run this time around -- # they will be run the next time (after another I/O poll). # Use an idiom that is thread-safe without using locks. ntodo = len(self._ready) for i in range(ntodo): handle = self._ready.popleft() if handle._cancelled: continue if self._debug: try: self._current_handle = handle t0 = self.time() handle._run() dt = self.time() - t0 if dt >= self.slow_callback_duration: logger.warning('Executing %s took %.3f seconds', _format_handle(handle), dt) finally: self._current_handle = None else: handle._run() handle = None # Needed to break cycles when an exception occurs. def _set_coroutine_wrapper(self, enabled): try: set_wrapper = sys.set_coroutine_wrapper get_wrapper = sys.get_coroutine_wrapper except AttributeError: return enabled = bool(enabled) if self._coroutine_wrapper_set == enabled: return wrapper = coroutines.debug_wrapper current_wrapper = get_wrapper() if enabled: if current_wrapper not in (None, wrapper): warnings.warn( "loop.set_debug(True): cannot set debug coroutine " "wrapper; another wrapper is already set %r" % current_wrapper, RuntimeWarning) else: set_wrapper(wrapper) self._coroutine_wrapper_set = True else: if current_wrapper not in (None, wrapper): warnings.warn( "loop.set_debug(False): cannot unset debug coroutine " "wrapper; another wrapper was set %r" % current_wrapper, RuntimeWarning) else: set_wrapper(None) self._coroutine_wrapper_set = False def get_debug(self): return self._debug def set_debug(self, enabled): self._debug = enabled if self.is_running(): self._set_coroutine_wrapper(enabled) PK!windows_utils.pynu[""" Various Windows specific bits and pieces """ import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('win32 only') import _winapi import itertools import msvcrt import os import socket import subprocess import tempfile import warnings __all__ = ['socketpair', 'pipe', 'Popen', 'PIPE', 'PipeHandle'] # Constants/globals BUFSIZE = 8192 PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT _mmap_counter = itertools.count() if hasattr(socket, 'socketpair'): # Since Python 3.5, socket.socketpair() is now also available on Windows socketpair = socket.socketpair else: # Replacement for socket.socketpair() def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): """A socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. """ if family == socket.AF_INET: host = '127.0.0.1' elif family == socket.AF_INET6: host = '::1' else: raise ValueError("Only AF_INET and AF_INET6 socket address " "families are supported") if type != socket.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(0) # that prevents us from having to create a thread. lsock = socket.socket(family, type, proto) try: lsock.bind((host, 0)) lsock.listen(1) # On IPv6, ignore flow_info and scope_id addr, port = lsock.getsockname()[:2] csock = socket.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) # Replacement for os.pipe() using handles instead of fds def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE): """Like os.pipe() but with overlapped support and using handles not fds.""" address = tempfile.mktemp(prefix=r'\\.\pipe\python-pipe-%d-%d-' % (os.getpid(), next(_mmap_counter))) if duplex: openmode = _winapi.PIPE_ACCESS_DUPLEX access = _winapi.GENERIC_READ | _winapi.GENERIC_WRITE obsize, ibsize = bufsize, bufsize else: openmode = _winapi.PIPE_ACCESS_INBOUND access = _winapi.GENERIC_WRITE obsize, ibsize = 0, bufsize openmode |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE if overlapped[0]: openmode |= _winapi.FILE_FLAG_OVERLAPPED if overlapped[1]: flags_and_attribs = _winapi.FILE_FLAG_OVERLAPPED else: flags_and_attribs = 0 h1 = h2 = None try: h1 = _winapi.CreateNamedPipe( address, openmode, _winapi.PIPE_WAIT, 1, obsize, ibsize, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) h2 = _winapi.CreateFile( address, access, 0, _winapi.NULL, _winapi.OPEN_EXISTING, flags_and_attribs, _winapi.NULL) ov = _winapi.ConnectNamedPipe(h1, overlapped=True) ov.GetOverlappedResult(True) return h1, h2 except: if h1 is not None: _winapi.CloseHandle(h1) if h2 is not None: _winapi.CloseHandle(h2) raise # Wrapper for a pipe handle class PipeHandle: """Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. """ def __init__(self, handle): self._handle = handle def __repr__(self): if self._handle is not None: handle = 'handle=%r' % self._handle else: handle = 'closed' return '<%s %s>' % (self.__class__.__name__, handle) @property def handle(self): return self._handle def fileno(self): if self._handle is None: raise ValueError("I/O operatioon on closed pipe") return self._handle def close(self, *, CloseHandle=_winapi.CloseHandle): if self._handle is not None: CloseHandle(self._handle) self._handle = None def __del__(self): if self._handle is not None: warnings.warn("unclosed %r" % self, ResourceWarning) self.close() def __enter__(self): return self def __exit__(self, t, v, tb): self.close() # Replacement for subprocess.Popen using overlapped pipe handles class Popen(subprocess.Popen): """Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. """ def __init__(self, args, stdin=None, stdout=None, stderr=None, **kwds): assert not kwds.get('universal_newlines') assert kwds.get('bufsize', 0) == 0 stdin_rfd = stdout_wfd = stderr_wfd = None stdin_wh = stdout_rh = stderr_rh = None if stdin == PIPE: stdin_rh, stdin_wh = pipe(overlapped=(False, True), duplex=True) stdin_rfd = msvcrt.open_osfhandle(stdin_rh, os.O_RDONLY) else: stdin_rfd = stdin if stdout == PIPE: stdout_rh, stdout_wh = pipe(overlapped=(True, False)) stdout_wfd = msvcrt.open_osfhandle(stdout_wh, 0) else: stdout_wfd = stdout if stderr == PIPE: stderr_rh, stderr_wh = pipe(overlapped=(True, False)) stderr_wfd = msvcrt.open_osfhandle(stderr_wh, 0) elif stderr == STDOUT: stderr_wfd = stdout_wfd else: stderr_wfd = stderr try: super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd, stderr=stderr_wfd, **kwds) except: for h in (stdin_wh, stdout_rh, stderr_rh): if h is not None: _winapi.CloseHandle(h) raise else: if stdin_wh is not None: self.stdin = PipeHandle(stdin_wh) if stdout_rh is not None: self.stdout = PipeHandle(stdout_rh) if stderr_rh is not None: self.stderr = PipeHandle(stderr_rh) finally: if stdin == PIPE: os.close(stdin_rfd) if stdout == PIPE: os.close(stdout_wfd) if stderr == PIPE: os.close(stderr_wfd) PK!E{C||log.pynu["""Logging configuration.""" import logging # Name the logger after the package. logger = logging.getLogger(__package__) PK!ّ>hh staggered.pynu["""Support for running coroutines in parallel with staggered start times.""" __all__ = 'staggered_race', import contextlib import typing from . import events from . import exceptions as exceptions_mod from . import locks from . import tasks async def staggered_race( coro_fns: typing.Iterable[typing.Callable[[], typing.Awaitable]], delay: typing.Optional[float], *, loop: events.AbstractEventLoop = None, ) -> typing.Tuple[ typing.Any, typing.Optional[int], typing.List[typing.Optional[Exception]] ]: """Run coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. """ # TODO: when we have aiter() and anext(), allow async iterables in coro_fns. loop = loop or events.get_running_loop() enum_coro_fns = enumerate(coro_fns) winner_result = None winner_index = None exceptions = [] running_tasks = [] async def run_one_coro( previous_failed: typing.Optional[locks.Event]) -> None: # Wait for the previous task to finish, or for delay seconds if previous_failed is not None: with contextlib.suppress(exceptions_mod.TimeoutError): # Use asyncio.wait_for() instead of asyncio.wait() here, so # that if we get cancelled at this point, Event.wait() is also # cancelled, otherwise there will be a "Task destroyed but it is # pending" later. await tasks.wait_for(previous_failed.wait(), delay) # Get the next coroutine to run try: this_index, coro_fn = next(enum_coro_fns) except StopIteration: return # Start task that will run the next coroutine this_failed = locks.Event() next_task = loop.create_task(run_one_coro(this_failed)) running_tasks.append(next_task) assert len(running_tasks) == this_index + 2 # Prepare place to put this coroutine's exceptions if not won exceptions.append(None) assert len(exceptions) == this_index + 1 try: result = await coro_fn() except (SystemExit, KeyboardInterrupt): raise except BaseException as e: exceptions[this_index] = e this_failed.set() # Kickstart the next coroutine else: # Store winner's results nonlocal winner_index, winner_result assert winner_index is None winner_index = this_index winner_result = result # Cancel all other tasks. We take care to not cancel the current # task as well. If we do so, then since there is no `await` after # here and CancelledError are usually thrown at one, we will # encounter a curious corner case where the current task will end # up as done() == True, cancelled() == False, exception() == # asyncio.CancelledError. This behavior is specified in # https://bugs.python.org/issue30048 for i, t in enumerate(running_tasks): if i != this_index: t.cancel() first_task = loop.create_task(run_one_coro(None)) running_tasks.append(first_task) try: # Wait for a growing list of tasks to all finish: poor man's version of # curio's TaskGroup or trio's nursery done_count = 0 while done_count != len(running_tasks): done, _ = await tasks.wait(running_tasks) done_count = len(done) # If run_one_coro raises an unhandled exception, it's probably a # programming error, and I want to see it. if __debug__: for d in done: if d.done() and not d.cancelled() and d.exception(): raise d.exception() return winner_result, winner_index, exceptions finally: # Make sure no tasks are left running if we leave this function for t in running_tasks: t.cancel() PK! DD futures.pynu["""A Future class similar to the one in PEP 3148.""" __all__ = ['CancelledError', 'TimeoutError', 'InvalidStateError', 'Future', 'wrap_future', 'isfuture', ] import concurrent.futures._base import logging import reprlib import sys import traceback from . import compat from . import events # States for Future. _PENDING = 'PENDING' _CANCELLED = 'CANCELLED' _FINISHED = 'FINISHED' Error = concurrent.futures._base.Error CancelledError = concurrent.futures.CancelledError TimeoutError = concurrent.futures.TimeoutError STACK_DEBUG = logging.DEBUG - 1 # heavy-duty debugging class InvalidStateError(Error): """The operation is not allowed in this state.""" class _TracebackLogger: """Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. """ __slots__ = ('loop', 'source_traceback', 'exc', 'tb') def __init__(self, future, exc): self.loop = future._loop self.source_traceback = future._source_traceback self.exc = exc self.tb = None def activate(self): exc = self.exc if exc is not None: self.exc = None self.tb = traceback.format_exception(exc.__class__, exc, exc.__traceback__) def clear(self): self.exc = None self.tb = None def __del__(self): if self.tb: msg = 'Future/Task exception was never retrieved\n' if self.source_traceback: src = ''.join(traceback.format_list(self.source_traceback)) msg += 'Future/Task created at (most recent call last):\n' msg += '%s\n' % src.rstrip() msg += ''.join(self.tb).rstrip() self.loop.call_exception_handler({'message': msg}) def isfuture(obj): """Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. """ return (hasattr(obj.__class__, '_asyncio_future_blocking') and obj._asyncio_future_blocking is not None) class Future: """This class is *almost* compatible with concurrent.futures.Future. Differences: - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon_threadsafe(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) """ # Class variables serving as defaults for instance variables. _state = _PENDING _result = None _exception = None _loop = None _source_traceback = None # This field is used for a dual purpose: # - Its presence is a marker to declare that a class implements # the Future protocol (i.e. is intended to be duck-type compatible). # The value must also be not-None, to enable a subclass to declare # that it is not compatible by setting this to None. # - It is set by __iter__() below so that Task._step() can tell # the difference between `yield from Future()` (correct) vs. # `yield Future()` (incorrect). _asyncio_future_blocking = False _log_traceback = False # Used for Python 3.4 and later _tb_logger = None # Used for Python 3.3 only def __init__(self, *, loop=None): """Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. """ if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._callbacks = [] if self._loop.get_debug(): self._source_traceback = traceback.extract_stack(sys._getframe(1)) def __format_callbacks(self): cb = self._callbacks size = len(cb) if not size: cb = '' def format_cb(callback): return events._format_callback_source(callback, ()) if size == 1: cb = format_cb(cb[0]) elif size == 2: cb = '{}, {}'.format(format_cb(cb[0]), format_cb(cb[1])) elif size > 2: cb = '{}, <{} more>, {}'.format(format_cb(cb[0]), size-2, format_cb(cb[-1])) return 'cb=[%s]' % cb def _repr_info(self): info = [self._state.lower()] if self._state == _FINISHED: if self._exception is not None: info.append('exception={!r}'.format(self._exception)) else: # use reprlib to limit the length of the output, especially # for very long strings result = reprlib.repr(self._result) info.append('result={}'.format(result)) if self._callbacks: info.append(self.__format_callbacks()) if self._source_traceback: frame = self._source_traceback[-1] info.append('created at %s:%s' % (frame[0], frame[1])) return info def __repr__(self): info = self._repr_info() return '<%s %s>' % (self.__class__.__name__, ' '.join(info)) # On Python 3.3 and older, objects with a destructor part of a reference # cycle are never destroyed. It's not more the case on Python 3.4 thanks # to the PEP 442. if compat.PY34: def __del__(self): if not self._log_traceback: # set_exception() was not called, or result() or exception() # has consumed the exception return exc = self._exception context = { 'message': ('%s exception was never retrieved' % self.__class__.__name__), 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) def cancel(self): """Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. """ self._log_traceback = False if self._state != _PENDING: return False self._state = _CANCELLED self._schedule_callbacks() return True def _schedule_callbacks(self): """Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. """ callbacks = self._callbacks[:] if not callbacks: return self._callbacks[:] = [] for callback in callbacks: self._loop.call_soon(callback, self) def cancelled(self): """Return True if the future was cancelled.""" return self._state == _CANCELLED # Don't implement running(); see http://bugs.python.org/issue18699 def done(self): """Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. """ return self._state != _PENDING def result(self): """Return the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. """ if self._state == _CANCELLED: raise CancelledError if self._state != _FINISHED: raise InvalidStateError('Result is not ready.') self._log_traceback = False if self._tb_logger is not None: self._tb_logger.clear() self._tb_logger = None if self._exception is not None: raise self._exception return self._result def exception(self): """Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. """ if self._state == _CANCELLED: raise CancelledError if self._state != _FINISHED: raise InvalidStateError('Exception is not set.') self._log_traceback = False if self._tb_logger is not None: self._tb_logger.clear() self._tb_logger = None return self._exception def add_done_callback(self, fn): """Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. """ if self._state != _PENDING: self._loop.call_soon(fn, self) else: self._callbacks.append(fn) # New method not in PEP 3148. def remove_done_callback(self, fn): """Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. """ filtered_callbacks = [f for f in self._callbacks if f != fn] removed_count = len(self._callbacks) - len(filtered_callbacks) if removed_count: self._callbacks[:] = filtered_callbacks return removed_count # So-called internal methods (note: no set_running_or_notify_cancel()). def set_result(self, result): """Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise InvalidStateError('{}: {!r}'.format(self._state, self)) self._result = result self._state = _FINISHED self._schedule_callbacks() def set_exception(self, exception): """Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise InvalidStateError('{}: {!r}'.format(self._state, self)) if isinstance(exception, type): exception = exception() if type(exception) is StopIteration: raise TypeError("StopIteration interacts badly with generators " "and cannot be raised into a Future") self._exception = exception self._state = _FINISHED self._schedule_callbacks() if compat.PY34: self._log_traceback = True else: self._tb_logger = _TracebackLogger(self, exception) # Arrange for the logger to be activated after all callbacks # have had a chance to call result() or exception(). self._loop.call_soon(self._tb_logger.activate) def __iter__(self): if not self.done(): self._asyncio_future_blocking = True yield self # This tells Task to wait for completion. assert self.done(), "yield from wasn't used with future" return self.result() # May raise too. if compat.PY35: __await__ = __iter__ # make compatible with 'await' expression def _set_result_unless_cancelled(fut, result): """Helper setting the result only if the future was not cancelled.""" if fut.cancelled(): return fut.set_result(result) def _set_concurrent_future_state(concurrent, source): """Copy state from a future to a concurrent.futures.Future.""" assert source.done() if source.cancelled(): concurrent.cancel() if not concurrent.set_running_or_notify_cancel(): return exception = source.exception() if exception is not None: concurrent.set_exception(exception) else: result = source.result() concurrent.set_result(result) def _copy_future_state(source, dest): """Internal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. """ assert source.done() if dest.cancelled(): return assert not dest.done() if source.cancelled(): dest.cancel() else: exception = source.exception() if exception is not None: dest.set_exception(exception) else: result = source.result() dest.set_result(result) def _chain_future(source, destination): """Chain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. """ if not isfuture(source) and not isinstance(source, concurrent.futures.Future): raise TypeError('A future is required for source argument') if not isfuture(destination) and not isinstance(destination, concurrent.futures.Future): raise TypeError('A future is required for destination argument') source_loop = source._loop if isfuture(source) else None dest_loop = destination._loop if isfuture(destination) else None def _set_state(future, other): if isfuture(future): _copy_future_state(other, future) else: _set_concurrent_future_state(future, other) def _call_check_cancel(destination): if destination.cancelled(): if source_loop is None or source_loop is dest_loop: source.cancel() else: source_loop.call_soon_threadsafe(source.cancel) def _call_set_state(source): if dest_loop is None or dest_loop is source_loop: _set_state(destination, source) else: dest_loop.call_soon_threadsafe(_set_state, destination, source) destination.add_done_callback(_call_check_cancel) source.add_done_callback(_call_set_state) def wrap_future(future, *, loop=None): """Wrap concurrent.futures.Future object.""" if isfuture(future): return future assert isinstance(future, concurrent.futures.Future), \ 'concurrent.futures.Future is expected, got {!r}'.format(future) if loop is None: loop = events.get_event_loop() new_future = loop.create_future() _chain_future(future, new_future) return new_future PK! *)) coroutines.pynu[__all__ = ['coroutine', 'iscoroutinefunction', 'iscoroutine'] import functools import inspect import opcode import os import sys import traceback import types from . import compat from . import events from . import futures from .log import logger # Opcode of "yield from" instruction _YIELD_FROM = opcode.opmap['YIELD_FROM'] # If you set _DEBUG to true, @coroutine will wrap the resulting # generator objects in a CoroWrapper instance (defined below). That # instance will log a message when the generator is never iterated # over, which may happen when you forget to use "yield from" with a # coroutine call. Note that the value of the _DEBUG flag is taken # when the decorator is used, so to be of any use it must be set # before you define your coroutines. A downside of using this feature # is that tracebacks show entries for the CoroWrapper.__next__ method # when _DEBUG is true. _DEBUG = (not sys.flags.ignore_environment and bool(os.environ.get('PYTHONASYNCIODEBUG'))) try: _types_coroutine = types.coroutine _types_CoroutineType = types.CoroutineType except AttributeError: # Python 3.4 _types_coroutine = None _types_CoroutineType = None try: _inspect_iscoroutinefunction = inspect.iscoroutinefunction except AttributeError: # Python 3.4 _inspect_iscoroutinefunction = lambda func: False try: from collections.abc import Coroutine as _CoroutineABC, \ Awaitable as _AwaitableABC except ImportError: _CoroutineABC = _AwaitableABC = None # Check for CPython issue #21209 def has_yield_from_bug(): class MyGen: def __init__(self): self.send_args = None def __iter__(self): return self def __next__(self): return 42 def send(self, *what): self.send_args = what return None def yield_from_gen(gen): yield from gen value = (1, 2, 3) gen = MyGen() coro = yield_from_gen(gen) next(coro) coro.send(value) return gen.send_args != (value,) _YIELD_FROM_BUG = has_yield_from_bug() del has_yield_from_bug def debug_wrapper(gen): # This function is called from 'sys.set_coroutine_wrapper'. # We only wrap here coroutines defined via 'async def' syntax. # Generator-based coroutines are wrapped in @coroutine # decorator. return CoroWrapper(gen, None) class CoroWrapper: # Wrapper for coroutine object in _DEBUG mode. def __init__(self, gen, func=None): assert inspect.isgenerator(gen) or inspect.iscoroutine(gen), gen self.gen = gen self.func = func # Used to unwrap @coroutine decorator self._source_traceback = traceback.extract_stack(sys._getframe(1)) self.__name__ = getattr(gen, '__name__', None) self.__qualname__ = getattr(gen, '__qualname__', None) def __repr__(self): coro_repr = _format_coroutine(self) if self._source_traceback: frame = self._source_traceback[-1] coro_repr += ', created at %s:%s' % (frame[0], frame[1]) return '<%s %s>' % (self.__class__.__name__, coro_repr) def __iter__(self): return self def __next__(self): return self.gen.send(None) if _YIELD_FROM_BUG: # For for CPython issue #21209: using "yield from" and a custom # generator, generator.send(tuple) unpacks the tuple instead of passing # the tuple unchanged. Check if the caller is a generator using "yield # from" to decide if the parameter should be unpacked or not. def send(self, *value): frame = sys._getframe() caller = frame.f_back assert caller.f_lasti >= 0 if caller.f_code.co_code[caller.f_lasti] != _YIELD_FROM: value = value[0] return self.gen.send(value) else: def send(self, value): return self.gen.send(value) def throw(self, type, value=None, traceback=None): return self.gen.throw(type, value, traceback) def close(self): return self.gen.close() @property def gi_frame(self): return self.gen.gi_frame @property def gi_running(self): return self.gen.gi_running @property def gi_code(self): return self.gen.gi_code if compat.PY35: def __await__(self): cr_await = getattr(self.gen, 'cr_await', None) if cr_await is not None: raise RuntimeError( "Cannot await on coroutine {!r} while it's " "awaiting for {!r}".format(self.gen, cr_await)) return self @property def gi_yieldfrom(self): return self.gen.gi_yieldfrom @property def cr_await(self): return self.gen.cr_await @property def cr_running(self): return self.gen.cr_running @property def cr_code(self): return self.gen.cr_code @property def cr_frame(self): return self.gen.cr_frame def __del__(self): # Be careful accessing self.gen.frame -- self.gen might not exist. gen = getattr(self, 'gen', None) frame = getattr(gen, 'gi_frame', None) if frame is None: frame = getattr(gen, 'cr_frame', None) if frame is not None and frame.f_lasti == -1: msg = '%r was never yielded from' % self tb = getattr(self, '_source_traceback', ()) if tb: tb = ''.join(traceback.format_list(tb)) msg += ('\nCoroutine object created at ' '(most recent call last):\n') msg += tb.rstrip() logger.error(msg) def coroutine(func): """Decorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. """ if _inspect_iscoroutinefunction(func): # In Python 3.5 that's all we need to do for coroutines # defined with "async def". # Wrapping in CoroWrapper will happen via # 'sys.set_coroutine_wrapper' function. return func if inspect.isgeneratorfunction(func): coro = func else: @functools.wraps(func) def coro(*args, **kw): res = func(*args, **kw) if (futures.isfuture(res) or inspect.isgenerator(res) or isinstance(res, CoroWrapper)): res = yield from res elif _AwaitableABC is not None: # If 'func' returns an Awaitable (new in 3.5) we # want to run it. try: await_meth = res.__await__ except AttributeError: pass else: if isinstance(res, _AwaitableABC): res = yield from await_meth() return res if not _DEBUG: if _types_coroutine is None: wrapper = coro else: wrapper = _types_coroutine(coro) else: @functools.wraps(func) def wrapper(*args, **kwds): w = CoroWrapper(coro(*args, **kwds), func=func) if w._source_traceback: del w._source_traceback[-1] # Python < 3.5 does not implement __qualname__ # on generator objects, so we set it manually. # We use getattr as some callables (such as # functools.partial may lack __qualname__). w.__name__ = getattr(func, '__name__', None) w.__qualname__ = getattr(func, '__qualname__', None) return w wrapper._is_coroutine = _is_coroutine # For iscoroutinefunction(). return wrapper # A marker for iscoroutinefunction. _is_coroutine = object() def iscoroutinefunction(func): """Return True if func is a decorated coroutine function.""" return (getattr(func, '_is_coroutine', None) is _is_coroutine or _inspect_iscoroutinefunction(func)) _COROUTINE_TYPES = (types.GeneratorType, CoroWrapper) if _CoroutineABC is not None: _COROUTINE_TYPES += (_CoroutineABC,) if _types_CoroutineType is not None: # Prioritize native coroutine check to speed-up # asyncio.iscoroutine. _COROUTINE_TYPES = (_types_CoroutineType,) + _COROUTINE_TYPES def iscoroutine(obj): """Return True if obj is a coroutine object.""" return isinstance(obj, _COROUTINE_TYPES) def _format_coroutine(coro): assert iscoroutine(coro) if not hasattr(coro, 'cr_code') and not hasattr(coro, 'gi_code'): # Most likely a built-in type or a Cython coroutine. # Built-in types might not have __qualname__ or __name__. coro_name = getattr( coro, '__qualname__', getattr(coro, '__name__', type(coro).__name__)) coro_name = '{}()'.format(coro_name) running = False try: running = coro.cr_running except AttributeError: try: running = coro.gi_running except AttributeError: pass if running: return '{} running'.format(coro_name) else: return coro_name coro_name = None if isinstance(coro, CoroWrapper): func = coro.func coro_name = coro.__qualname__ if coro_name is not None: coro_name = '{}()'.format(coro_name) else: func = coro if coro_name is None: coro_name = events._format_callback(func, (), {}) try: coro_code = coro.gi_code except AttributeError: coro_code = coro.cr_code try: coro_frame = coro.gi_frame except AttributeError: coro_frame = coro.cr_frame filename = coro_code.co_filename lineno = 0 if (isinstance(coro, CoroWrapper) and not inspect.isgeneratorfunction(coro.func) and coro.func is not None): source = events._get_function_source(coro.func) if source is not None: filename, lineno = source if coro_frame is None: coro_repr = ('%s done, defined at %s:%s' % (coro_name, filename, lineno)) else: coro_repr = ('%s running, defined at %s:%s' % (coro_name, filename, lineno)) elif coro_frame is not None: lineno = coro_frame.f_lineno coro_repr = ('%s running at %s:%s' % (coro_name, filename, lineno)) else: lineno = coro_code.co_firstlineno coro_repr = ('%s done, defined at %s:%s' % (coro_name, filename, lineno)) return coro_repr PK!̻.__pycache__/windows_utils.cpython-36.opt-1.pycnu[3  f@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdfd dZd de dddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces NZwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd \}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r:/opt/alt/python36/lib64/python3.6/asyncio/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)prefixrrNT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@s\eZdZdZddZddZeddZdd Ze j d d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r" __class____name__)r#r$rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r"r )r#rrrfilenos zPipeHandle.fileno)r cCs|jdk r||jd|_dS)N)r")r#r rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r"warningswarnResourceWarningr)r#rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r#rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r#tvtbrrr__exit__szPipeHandle.__exit__N)r( __module__ __qualname____doc__r%r)propertyr$r*rr rr/r0r4rrrrrs cs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|d}}}d} } } |tkr@tddd\} } tj| tj}n|}|tkrhtdd\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy tj|f|||d|Wn4x$| | | fD]}|dk rt j |qWYn>X| dk rt | |_ | dk r"t | |_ | dk r6t | |_Wd|tkrNtj||tkrbtj||tkrvtj|XdS) NFT)rr)rr)stdinstdoutstderr)FT)TF)TF)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr%rr rr9r:r;r)r#argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r'rrr%sH            zPopen.__init__)NNN)r(r5r6r7r% __classcell__rr)r'rrs)TT)r7sysplatform ImportErrorr itertoolsr<rr subprocessrr,__all__ZBUFSIZErr>countrhasattrrr r rrrrrrrs,  .0-PK!2z$__pycache__/log.cpython-36.opt-2.pycnu[3 2a|@sddlZejeZdS)N)ZloggingZ getLogger __package__Zloggerrr(/opt/alt/python36/lib64/python3.6/log.pysPK!/gg,__pycache__/unix_events.cpython-36.opt-2.pycnu[3 2a @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZdddddgZejdkredddZy ejZWnek r(ddZYnXGdddejZe edrRddZ!nddl"Z"ddZ!Gd d!d!ej#Z$Gd"d#d#ej%ej&Z'e ed$rej(Z)nddl"Z"d%d&Z)Gd'd(d(e j*Z+Gd)ddZ,Gd*d+d+e,Z-Gd,dde-Z.Gd-dde-Z/Gd.d/d/ej0Z1eZ2e1Z3dS)0N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on WindowscCsdS)N)signumframerr0/opt/alt/python36/lib64/python3.6/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZd!fdd ZddZfddZdd Zd d Zd d ZddZ ddZ d"ddZ d#ddZ e d$ddZddZe ddddddZe d%dddddd ZZS)&_UnixSelectorEventLoopNcstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)r rrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)r sig)r"rrr&>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)r datarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)Nz3coroutines cannot be used with add_signal_handler()Frzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)r r/callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)N)rgetZ _cancelledr*Z_add_callback_signalsafe)r r/rErrrr0s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)NFzsig {} cannot be caughtrzset_wakeup_fd(-1) failed: %sTr3)r5rKeyErrorr6SIGINTdefault_int_handlerSIG_DFLr:r?r@r;rAr7r9rr>)r r/ZhandlerrDrrrr*s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)Nzsig must be an int, not {!r}rzsig {} out of range(1, {})) isinstanceintr4rAr6NSIGr9)r r/rrrr5s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)r pipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)r rPrQrRrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rRrS) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr&Z_wait)r rQrCshellstdinstdoutstderrbufsizerSkwargswatcherrRtransprDerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)r pid returncodercrrrrZsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|r|dkr&tdn|dk r&td|dk r|dk r>tdtjtjtjd}y |jd|j||EdHWq|jYqXnB|dkrtd|jtjkstj |j  rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r9r#AF_UNIX SOCK_STREAM setblockingZ sock_connectr&familyr_is_stream_sockettyperAZ_create_connection_transport)r protocol_factoryrrhrirj transportrQrrrcreate_unix_connections8    z-_UnixSelectorEventLoop.create_unix_connectiond)ribacklogrhc !Cst|trtd|dk r0|dk r,tdt|}tjtjtj}|dd kry tj t j|j rnt j |WnBt k rYn0tk r}ztjd||WYdd}~XnXy|j|Wnjtk r}z8|j|jtjkrdj|}ttj|dnWYdd}~Xn|jYnXn>|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrv)rLboolr4r9_fspathr#rkrlstatS_ISSOCKosst_moderemoveFileNotFoundErrorr:rerrorZbindr&r?Z EADDRINUSErArnrrorpZServerZlistenrmZ_start_serving) r rqrrirurhrdrDmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname__rr$r&r2rFr0r*r5rTrVr rerZrsr __classcell__rr)r"rr1s* -      %r set_blockingcCstj|ddS)NF)r{r)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLr{ O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rOiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrPFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper8_fileno _protocol_closingr{fstatr|ryS_ISFIFOrzS_ISCHRr9r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r looprPrQrRrSmode)r"rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r"rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)r r>r!rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)r{readrmax_sizeBlockingIOErrorInterruptedErrorr: _fatal_errorrZ data_receivedr get_debugrr>r_remove_readerrZ eof_received_call_connection_lost)r r1rDrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)r rrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)r rrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)r rQrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)r rrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)r rrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)r rrrr&sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r%)rr+r,r-r&)r rrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrrrQ) rLr:r?ZEIOrrrdebugcall_exception_handlerrr)r rDrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)r rDrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr&r)r rDrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr&rPY34rrrrrrr)r"rrOMs rOcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rUNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrPrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr8rr bytearray_buffer _conn_lostrr{rr|ryrrrzr9rrrrr'platform startswithrrr r) r rrPrQrRrSrZis_charZis_fifoZ is_socket)r"rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r"rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)r r>r!rr`rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)r rrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr>rrBrokenPipeError)r rrrrs   z#_UnixWritePipeTransport._read_readycCst|trt|}|sdS|js&|jrN|jtjkrs&   z$_UnixWritePipeTransport._write_readycCsdS)NTr)r rrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr dSd|_|js4|jj|j|jj|jddS)NT)rrrrrrr)r rrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)r rQrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)r rrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)r rrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)r rrrr&msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r%)rr+r,r-r&)r rrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)r rrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrrrQ) rLrZ_FATAL_ERROR_IGNORErrrrrrr)r rDrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr.rrr)r rDrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr&r)r rDrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr&rrrrrrrrrr)r"rrUs$% !   rUset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rXc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r\r]r^r_Zuniversal_newlinesr`wb) buffering) subprocessPIPErr$rr8Popen_procr&rdetachr]) r rCr\r]r^r_r`raZstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrXsrXc@s<eZdZddZddZddZddZd d Zd d Zd S)rcGs tdS)N)NotImplementedError)r rfrBrCrrrrYs z&AbstractChildWatcher.add_child_handlercCs tdS)N)r)r rfrrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)N)r)r rrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)N)r)r rrrr&szAbstractChildWatcher.closecCs tdS)N)r)r rrr __enter__szAbstractChildWatcher.__enter__cCs tdS)N)r)r abcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrYrrr&rrrrrrrs   c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)r rrrrszBaseChildWatcher.__init__cCs|jddS)N)r)r rrrr&szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)r rrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk r$|dkr$|jr$tjdt|jdk r<|jjtj||_|dk rb|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrr+r,RuntimeWarningr*r6SIGCHLDrF _sig_chldr)r rrrrrs zBaseChildWatcher.attach_loopcCsFy |jWn4tk r@}z|jjd|dWYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)rr)rr[rr)r rDrrrr1s  zBaseChildWatcher._sig_chldcCs2tj|rtj| Stj|r*tj|S|SdS)N)r{ WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)r statusrrr_compute_returncode=s     z$BaseChildWatcher._compute_returncodeN) rrrrr&rrrrrrrrrrs rcsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)rcs|jjtjdS)N)rr.rr&)r )r"rrr&Vs zSafeChildWatcher.closecCs|S)Nr)r rrrrZszSafeChildWatcher.__enter__cCsdS)Nr)r rrrrrrr]szSafeChildWatcher.__exit__cGs.|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr;rr)r rfrBrCrrrrY`s  z"SafeChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrH)r rfrrrrks z%SafeChildWatcher.remove_child_handlercCs"xt|jD]}|j|q WdS)N)r)rr)r rfrrrrrsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn(tk r>|}d}tjd|Yn0X|dkrLdS|j|}|jjrntj d||y|j j |\}}Wn.t k r|jjrtjd|ddYnX|||f|dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r) r{waitpidWNOHANGChildProcessErrorrrrrrrrpoprH)r rrfrrgrBrCrrrrws*    zSafeChildWatcher._do_waitpid) rrrr&rrrYrrrrrr)r"rrKs  csPeZdZfddZfddZddZddZd d Zd d Zd dZ Z S)rcs$tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r )r"rrrs  zFastChildWatcher.__init__cs"|jj|jjtjdS)N)rr.rrr&)r )r"rrr&s  zFastChildWatcher.closec Cs$|j|jd7_|SQRXdS)Nr)rr)r rrrrszFastChildWatcher.__enter__c CsV|j:|jd8_|js$|j r(dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr<r.rr)r rrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGsl|jdkrtd|j:y|jj|}Wn"tk rL||f|j|<dSXWdQRX|||f|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr;rrrrHr)r rfrBrCrgrrrrYs z"FastChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrH)r rfrrrrs z%FastChildWatcher.remove_child_handlercCsxytjdtj\}}Wntk r,dSX|dkr:dS|j|}|jvy|jj|\}}WnBtk r|j r||j |<|j j rt jd||wd}YnX|j j rt jd||WdQRX|dkrt jd||q|||f|qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr3)r{rrrrrrrrHrrrrrrr)r rfrrgrBrCrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrr&rrrYrrrrr)r"rrs  csDeZdZeZfddZddZfddZddZd d Z Z S) _UnixDefaultEventLoopPolicycstjd|_dS)N)rr_watcher)r )r"rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrLrcurrent_thread _MainThreadr_localr)r rrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)N)rset_event_looprrLrrrr)r r)r"rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)N)rr)r rrrrW&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|jj||_dS)N)rr&)r rbrrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrZ _loop_factoryrrrrWrrrr)r"rrs    r)4r?r{r6r#ryrr'rr+rrrrrrr r r r r logr__all__r ImportErrorrfspathrxAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrOZ_FlowControlMixinZWriteTransportrUrrZBaseSubprocessTransportrXrrrrZBaseDefaultEventLoopPolicyrrrrrrrsl                O  F=On2PK!@uo#o#0__pycache__/base_subprocess.cpython-36.opt-2.pycnu[3 2a#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|j| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__4/opt/alt/python36/lib64/python3.6/base_subprocess.pyrs@            z BaseSubprocessTransport.__init__cCs |jjg}|jr|jd|jdk r4|jd|j|jdk rP|jd|jn |jdk rf|jdn |jd|jjd}|dk r|jd|j|jjd}|jjd }|dk r||kr|jd |jn0|dk r|jd |j|dk r|jd |jd dj |S)Nclosedzpid=%sz returncode=%sZrunningz not startedrzstdin=%srr zstdout=stderr=%sz stdout=%sz stderr=%sz<%s> ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #sPyj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x"j D]\}}|j|f|qWd_ WnDt k r*}z&|dk r|j r|j|WYdd}~Xn"X|dk rL|j rL|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s6          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrR)r)cbrZr/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r]rZpipe_connection_lost _try_finish)r)rIr[r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r]rZpipe_data_received)r)rIrZr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCst|jjrtjd||||_|jjdkr2||j_|j|jj |j x |j D]}|j sP|j |qPWd|_ dS)Nz%r exited with return code %r)rr#rr8rr returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0_process_exiteds   z'BaseSubprocessTransport._process_exitedccs0|jdk r|jS|jj}|jj||EdHS)N)rrZ create_futurerr4)r)r,r/r/r0_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jjDr:d|_|j|jddS)Ncss|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rallrr>rr]_call_connection_lost)r)r/r/r0r^s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r[r/r/r0ris z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rWr pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rWrresume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN) r3rkrlrrSr9rjrnror/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rWr`rI)r)rZr/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { PK!]TT+__pycache__/base_tasks.cpython-36.opt-1.pycnu[3  f@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror 7/opt/alt/python36/lib64/python3.6/asyncio/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   PK!96AA*__pycache__/proactor_events.cpython-36.pycnu[3  fO@sdZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j rXddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__ ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname____doc__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs<eZdZdZd fdd ZddZddZd d d ZZS) _ProactorReadPipeTransportzTransport for read pipes.Ncs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrRrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrRrSrrrTrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z@yf|dk rN|j|ks@|jdkr<|js@td|_|j}|jr\d}dS|dkrhdS|jjj|j d|_Wnt k r}z2|js|j |dn|jj rt jdddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r$}z|j |dWYdd}~Xn0tjk rD|js@YnX|jj|jWd|rl|jj|n:|dk r|jj rt jd||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrrAssertionErrorresultr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrTrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rTsL      z(_ProactorReadPipeTransport._loop_reading)NNN)N) r(rMrNrOr rUrVrTrPr#r#)r"r$rQs  rQc@s:eZdZdZddZd ddZddZd d Zd d ZdS)_ProactorBaseWritePipeTransportzTransport for write pipes.cCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr rjZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rtvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJrp)rr#r#r$ruys   z"_ProactorSocketTransport.write_eof)NNN) r(rMrNrOr rrtrurPr#r#)r"r$r\s rcseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rZ _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r)rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler~Z SSLProtocolrZ_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r})rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rQ)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)rw)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningri is_closed_stop_accept_futures_close_self_piperZr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rZr[)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rZrq)rrrbr#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rZZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rZaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r~)rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rYrZr[rrr_ ExceptionrDrr`r)rrsrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rrq)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rYZ_debugr rCrrrrZrr^r*rDr7rr_rr`)rsZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrZ _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrPr#r#)r"r$rs4          ()rO__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrQZWriteTransportrcrwZ Transportr}rZ BaseEventLooprr#r#r#r$s2        M T  #PK!.*55"__pycache__/futures.cpython-36.pycnu[3  f> @s dZddddddgZddlZddlZddlZddlZd d lmZd d lm Z d d lm Z ej Z ej Z ej Z ejZejZejZejZejd ZGd ddZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s4eZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr4/opt/alt/python36/lib64/python3.6/asyncio/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr) __name__ __module__ __qualname____doc__ __slots__rrrr&rrrrr s 0r c@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZejrRd d Zd d Zd dZddZddZddZddZddZddZddZddZdd ZejreZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r5_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N)r-r call_soon)rZ callbackscallbackrrrr;s  zFuture._schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r8r:)rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r8r9)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN)r8r:r _FINISHEDrr5r6_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r8r:rrArr5r6)rrrrr4s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r8r9rr=r-append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. csg|]}|kr|qSrr).0f)rErr sz/Future.remove_done_callback..N)r-len)rrEZfiltered_callbacksZ removed_countr)rErremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r8r9rformatrBrAr;)rrCrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL isinstancetype StopIteration TypeErrorr6rAr;r PY34r5r Z _tb_loggerrr=r)rr4rrr set_exception,s    zFuture.set_exceptionccs,|jsd|_|V|js$td|jS)NTz"yield from wasn't used with future)r@_asyncio_future_blockingAssertionErrorrC)rrrr__iter__Ds zFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr Z_future_repr_infor2r3r rRr&r<r;r?r@rCr4rFrKrMrSrVZPY35 __await__rrrrrns4   cCs|jr dS|j|dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr_set_result_unless_cancelledSsrXcCsZ|js t|jr|j|js(dS|j}|dk rD|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N) r@rUr?r<Zset_running_or_notify_cancelr4rSrCrM) concurrentsourcer4rCrrr_set_concurrent_future_stateZs  r[cCsj|js t|jrdS|j s&t|jr8|jn.|j}|dk rT|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r@rUr?r<r4rSrCrM)rZdestr4rCrrr_copy_future_stateis   r]cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|rt||n t||dS)N)rr]r[)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r?r<call_soon_threadsafe) destination) dest_looprZ source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r?Z is_closedr`)rZ)r_rbrarcrr_call_set_states  z&_chain_future.._call_set_state)rrNrYfuturesrrQrrF)rZrardrer)r_rbrarZrcr _chain_future}s   rg)r cCsNt|r |St|tjjs(tdj||dkr8tj}|j }t |||S)z&Wrap concurrent.futures.Future object.z/concurrent.futures.Future is expected, got {!r}N) rrNrYrfrrUrLr r,Z create_futurerg)rr Z new_futurerrrrs  )r*__all__Zconcurrent.futuresrYZloggingr/rrr r r rrrrr9r:rADEBUGZ STACK_DEBUGr rZ _PyFuturerXr[r]rgrZ_asyncio ImportErrorZ_CFuturerrrrs>     Pc*  PK!A.jj.__pycache__/windows_utils.cpython-36.opt-2.pycnu[3 2a@sddlZejdkredddlZddlZddlZddlZddlZddlZddl Z ddl Z dddddgZ d Z ej Z ejZejZeedrejZnejejdfd dZd de d ddZGdddZGdddejZdS)Nwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd\}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) Nz 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r2/opt/alt/python36/lib64/python3.6/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)Nz\\.\pipe\python-pipe-%d-%d-)prefixrrT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@sXeZdZddZddZeddZddZej d d d Z d d Z ddZ ddZ dS)rcCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r# __class____name__)r$r%rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r#)r$rrrr%szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r#r )r$rrrfilenos zPipeHandle.fileno)r!cCs|jdk r||jd|_dS)N)r#)r$r!rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r#warningswarnResourceWarningr)r$rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r$rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r$tvtbrrr__exit__szPipeHandle.__exit__N)r) __module__ __qualname__r&r*propertyr%r+r r!rr0r1r5rrrrrs cseZdZdfdd ZZS)rNc s|d}}}d} } } |tkr@tddd\} } tj| tj}n|}|tkrhtdd\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy tj|f|||d|Wn4x$| | | fD]}|dk rt j |qWYn>X| dk rt | |_ | dk r"t | |_ | dk r6t | |_Wd|tkrNtj||tkrbtj||tkrvtj|XdS) NFT)rr)rr)stdinstdoutstderr)FT)TF)TF)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr&r r!rr9r:r;r)r$argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r(rrr&sH            zPopen.__init__)NNN)r)r6r7r& __classcell__rr)r(rrs)TT)sysplatform ImportErrorr itertoolsr<rr subprocessrr-__all__ZBUFSIZErr>countrhasattrrr r rrrrrrrs*  .0-PK!g5TsTs0__pycache__/selector_events.cpython-36.opt-1.pycnu[3  f @s<dZdgZddlZddlZddlZddlZddlZddlZy ddlZWne k r^dZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyrZ ed?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(Z)S)VrzJSelector event loop. See events.EventLoop for API specification. NcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)zAdd a reader callback.)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. This method is a coroutine. rzthe socket must be non-blockingN)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. This method is a coroutine. rzthe socket must be non-blockingN)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIX)familyprotoloopN)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)a|Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. This method is a coroutine. rzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r __module__ __qualname____doc__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sT      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jr dSy|jj|j}Wn\ttfk r4Yntk rx}z*|jj|j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrHrrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs&   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0) r__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsD             iiPK!o`JJ __pycache__/tasks.cpython-36.pycnu[3  fa @sdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ddl mZGddde jZeZy ddlZWnek rYn XejZZej jZej jZej jZeddedddZddZeddddZeddZddd d!dZed/ddd"dZddd#d$Zeed <d e_ [ddd%d Z!ed&d'Z"Gd(d)d)e jZ#dd*d+d,d Z$ddd-d Z%d.d Z&dS)0z0Support for tasks, coroutines and the scheduler.TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZdZejZiZdZe dddZ e dddZ ddfd d Z e jrXd d Zd dZddddZdddddZddZdfdd ZddZZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj}|jj|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. N)rget_event_loop_current_tasksget)clsloopr2/opt/alt/python36/lib64/python3.6/asyncio/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsdtj|stt|tj|d|jr2|jd=||_d|_d|_ |j j |j |j jj|dS)N)rrF)r iscoroutineAssertionErrorreprsuper__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r0rrr)Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr*rZcall_exception_handlerFuture__del__)r2contextrrrr8Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r2rrr _repr_info^szTask._repr_info)limitcCs tj||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)r2r;rrr get_stackaszTask.get_stack)r;filecCstj|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)r2r;r=rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner,cancelr-)r2rrrr@s  z Task.cancelcs|j stdj|||jr:t|tjs4tj}d|_|j}d|_||j j |j <zy"|dkrn|j d}n |j |}Wntk r}z.|jrd|_|jtjn |j|jWYdd}~Xntjk rtjYn~tk r}z|j|WYdd}~XnPtk rD}z|j|WYdd}~Xn Xt|dd}|dk r|j |j k r|j j|jtdj||n||r||kr|j j|jtdj|n2d|_|j|j||_|jr|jjrd|_n|j j|jtdj||n^|dkr |j j|jnDtj|rJ|j j|jtdj||n|j j|jtdj|Wd|j j j|j d}XdS) Nz!_step(): already done: {!r}, {!r}F_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r}) r?r&formatr- isinstancerCancelledErrorr+r,r0rrsendthrow StopIteration set_exception set_resultvaluer(r@ Exception BaseExceptiongetattrr.r/ RuntimeErrorrAadd_done_callback_wakeupinspectZ isgeneratorpop)r2excr3resultZblocking)r0rrr/s            z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rTrKr/)r2futurerSrrrrPs  z Task._wakeup)N)N)N)__name__ __module__ __qualname____doc__weakrefWeakSetr"rr6 classmethodrr#r)rZPY34r8r:r<r>r@r/rP __classcell__rr)r0rrs"     !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)aWait for the Futures and coroutines given by fs to complete. The sequence futures must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = yield from asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturerr% TypeErrortyperV ValueErrorrrrrBrrset_wait)fsrr^r_r)rrrscGs|js|jddS)N)r?rI)waiterargsrrr_release_waiter<srj)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. N)r)rr create_future call_laterrj functoolspartialr rOrrDremove_done_callbackr@r?rT TimeoutError)futr^rrhtimeout_handlecbrrrrAs,       c #s|s td|jd|dk r.|j|tt|fdd}x|D]}|j|qNWzEdHWddk rjXtt}}x4|D],}|j||j r|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. zSet of Futures is empty.Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr@r?rI)r`)counterr_rrrhrr_on_completion|s z_wait.._on_completion) r&rkrlrjlenrOr@reror?r1)rgr^r_rrwr`r?pendingr)rvr_rrrhrrfos(      rf)rr^c#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcsh|]}t|dqS))r)r )rr`)rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)ro put_nowaitclear)r`)rwr?todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)remover{r@)r`)r?rrr}rrrws   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrprT)r`)r?rr _wait_for_onesz#as_completed.._wait_for_one)rrarr%rbrcrVrrreZqueuesrzrrOrlrangerx)rgrr^rzr~rr`_r)rwr?rrrr}rrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrkrrlrZ_set_result_unless_cancelledr@)ZdelayrTrrUhrrrrs cCstjdtddt||dS)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rrarrdrr%rrZ create_taskr*rZPY35rQZ isawaitabler _wrap_awaitablerb)rrr4rrrr s   ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. N)rcstj|d||_d|_dS)N)rF)r(r) _children_cancel_requested)r2childrenr)r0rrr)$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r?rr@r)r2ZretZchildrrrr@)s z_GatheringFuture.cancel)rVrWrXrYr)r@r]rr)r0rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd }x&t |D]\}}|jtj||qWS) a7Return a future aggregating results from the given coroutines or futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r?rtrurrDrHZ _exceptionZ_resultrrI)irqres) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrkrIrerrar rr6rdrxr enumeraterOrmrn)rrZcoros_or_futuresrrqrrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None )rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rtrur@rHrIrT)innerrS)rrrrs  zshield.._done_callback)r r?rrkrO)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rKZset_running_or_notify_cancelrH)rS)r3rUrrrcallbacks  z*run_coroutine_threadsafe..callback)rr%rb concurrentrr7Zcall_soon_threadsafe)r3rrr)r3rUrrr s    )N)'rY__all__Zconcurrent.futuresrrmrQrrZrrrrrrr7rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrjrrfrrrglobalsrVr rrr r r rrrrsZ        s  - -8  W5PK!ȻYzDzD+__pycache__/test_utils.cpython-36.opt-1.pycnu[3  f: @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrHddl%m&Z&n ddlm&Z&ddZ'e'dZ(e'dZ)ddZ*ddZ+dRddZ,ddZ-Gdd d eZ.Gd!d"d"eZ/Gd#d$d$Z0Gd%d&d&e0e/Z1d'd(d)d*Z2e3ed+rZGd,d-d-ej4eZ5Gd.d/d/e5eZ6Gd0d1d1e6Z7Gd2d3d3e0e7Z8d4d5Z9ej:d6d7Z;ej:d'd(d8d9Zd?Z>Gd@dAdAej?Z@GdBdCdCejAZBdDdEZCGdFdGdGeDZEdHdIZFGdJdKdKe jGZGej:dLdMZHejIejJejKfdNdOZLdPdQZMdS)SzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportZwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer7/opt/alt/python36/lib64/python3.6/asyncio/test_utils.py data_file-s   rz ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr"c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr#gentrrr run_brieflyCs  r)cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r&)timer TimeoutErrorr$r Zsleep)r&ZpredtimeoutZdeadlinerrr run_untilRs  r.cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)r&rrrrun_once\s r0c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r5r8rrrrr1gsr1cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r4request client_addr) __class__rrr?ts zSilentWSGIServer.get_requestcCsdS)Nr)r4rBclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF __classcell__rr)rDrr<ps r<c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr r!Zload_cert_chainZ wrap_socketZRequestHandlerClassr%OSError)r4rBrEZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@s eZdZdS) SSLWSGIServerN)r9r:r;rrrrrNsrNF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rPrQr)environZstart_responseZstatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r1Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rWrO server_clsserver_ssl_clsrSZ server_classZ server_threadr)rTr_run_test_servers    r]ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r4rrrrbs zUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^sr^cs(eZdZdZddZfddZZS)UnixWSGIServerr=cCstj||jdS)N)r^rbZ setup_environ)r4rrrrbs zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rdre)r>r?r@rA)r4rBrC)rDrrr?s zUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrcsrcc@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrFsz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrfsrfc@s eZdZdS)UnixSSLWSGIServerN)r9r:r;rrrrrgsrgc Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rkccs<t}z |VWdytj|Wntk r4YnXXdS)N)rkrunlinkrK)rrrrunix_socket_paths rmc cs,t}t||ttdEdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrrrun_test_unix_serversrnz 127.0.0.1)hostportrOccst||f|ttdEdHdS)N)rWrOr[r\)r]r<rN)rorprOrrrrun_test_servers rqcCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrirrrmake_test_protocols r{c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r4rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr})r4fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)r}pop)r4rrrr unregister szTestSelector.unregistercCsgS)Nr)r4r-rrrselectszTestSelector.selectcCs|jS)N)r})r4rrrget_mapszTestSelector.get_map)N)r9r:r;r~rrrrrrrrr|s  r|cseZdZdZd-fdd ZddZddZfd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zfd%d&Zfd'd(Zd)d*Zd+d,ZZS).TestLoopaLoop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. Ncsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr',szTestLoop.__init__..genFTrg& .>)r>r~_check_on_close_gennext_timeZ_clock_resolution_timersr|Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r4r')rDrrr~(s  zTestLoop.__init__cCs|jS)N)r)r4rrrr+?sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r4advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r>r%rrsend StopIterationAssertionError)r4)rDrrr%Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r4fdcallbackr7rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r4rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rrZ _callbackZ_args)r4rrr7handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r4rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r4rrr7rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r4rrrr_remove_writerns  zTestLoop._remove_writercGs|j|}dS)N)r)r4rrr7rrrr assert_writervs zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr6)r4rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)zAdd a reader callback.)rr)r4rrr7rrr add_readers zTestLoop.add_readercCs|j||j|S)zRemove a reader callback.)rr)r4rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rr)r4rrr7rrr add_writers zTestLoop.add_writercCs|j||j|S)zRemove a writer callback.)rr)r4rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r4rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r> _run_oncerrrr)r4whenr)rDrrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr>call_at)r4rrr7)rDrrrs zTestLoop.call_atcCsdS)Nr)r4Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r4rrr_write_to_selfszTestLoop._write_to_self)N)r9r:r;__doc__r~r+rr%rrrrrrrrrrrrrrrrrrGrr)rDrrs,     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrwsrwc@seZdZdZddZdS) MockPatternzA regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) cCsttjt||tjS)N)boolresearchstrS)r4otherrrr__eq__szMockPattern.__eq__N)r9r:r;rrrrrrrsrcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorrZr%)r&Zexecutorrrr close_loops zTestCase.close_loopT)cleanupcCs tjd|r|j|j|dS)N)r set_event_loopZ addCleanupr)r4r&rrrrrs zTestCase.set_event_loopNcCst|}|j||S)N)rr)r4r'r&rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r4rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrUsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r4rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r4rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r4rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r4excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r9r:r;rrrrrrEmptyCMsrr)r4r7rrrrrsubTestszTestCase.subTest)N) r9r:r; staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorxfamilyZ gettimeoutrs)rrxrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrrforce_legacy_ssl_supportsr)r*)Nrr contextlibr2rrrrr`rrhrXr+ZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrerrr r r r Z coroutinesr logrrrplatformZ windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrkcontextmanagerrmrnrqr{Z BaseSelectorr|Z BaseEventLooprrwrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 PK!& $ c c!__pycache__/events.cpython-36.pycnu[3  f[@sdZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddZddZd3ddZddZd4ddZGdddZGd ddeZGd!ddZGd"ddZGd#ddZGd$d%d%eZdae jZGd&d'd'e jZeZd(dZd)d Z d*d+Z!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'd2d Z(dS)5z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder 3/opt/alt/python36/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s<eZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3__doc__ __slots__rSrYr[r\rer r r r!rbs   csxeZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZZS)rz7Object returned by timed callback registration methods. _scheduled_whencs:|dk s ttj||||jr*|jd=||_d|_dS)NrFrT)AssertionErrorsuperrSrLrjri)rPwhenrQr/rR)rUr r!rSs  zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rlrYrJinsertrj)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashrj)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)rj)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)rj__eq__)rPrsr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)rj)rPrsr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rjru)rPrsr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJNotImplemented)rPrsr r r!rus      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rury)rPrsZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrlr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrhrSrYrrrtrvrwrxrurzr\ __classcell__r r )rUr!rs  c@s eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)ry)rPr r r!closeszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)ry)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3rgr}r~r r r r!rsc @seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d$d$d$d%d&d'Zdhd(d)Zdid*d$d$d$d*d*d*d+d,d-Zdjejejd*d.d*d*d*d/d0d1Zd*d*d*d2d3d4Zd*d.d*d5d6d7Zdkd$d$d$d*d*d*d*d8d9d:Zd;d<Zd=d>Z e!j"e!j"e!j"d?d@dAZ#e!j"e!j"e!j"d?dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4dddeZ5dfdgZ6d*S)lrzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)r)rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)r)rPr r r!stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.N)r)rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.N)r)rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)r)rPr r r!r}s zAbstractEventLoop.closecCstdS)z,Shutdown all active asynchronous generators.N)r)rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.N)r)rPr^r r r!r{sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r)rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r)rPrmrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r)rPr r r!time"szAbstractEventLoop.timecCstdS)N)r)rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r)rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r)rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r)rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r)rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r)rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r)rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)r) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r)rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)r)rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)r) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)r)rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)r)rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r)rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r)rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r)rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r)rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r)rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r)rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r)rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r)rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r)rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r)rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r)rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r)rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r)rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r)rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r)rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r)rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r)rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r)rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r)rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r)rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgrrrrrr}rr{rrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rst   '!   c@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)r)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.N)r)rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)r)rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.N)r)rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.N)r)rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN) r4rfr3rgrr r r r r r r r!rs  c@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|tst||j_dS)zSet the event loop.TN)rrrrrkrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rgrrlocalrrSrr r r r r r!r9s rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr r r r!rscCs|dkst|tst|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)rrrkr)Zpolicyr r r!rscCst}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr r r!rs cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rRr r r!r scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r r r r!r scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r r r r!r scCs tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr r r!r s)r2)NN))rg__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sZ    >8 5"7   PK!K__NN)__pycache__/sslproto.cpython-36.opt-1.pycnu[3  fe @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjr|j|jj|t|ks|jrDPqDW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr rr7r r;reasonr>r6r?r@rrAr:r8)r#rBoffsetr0ZviewrDrrr feed_appdatas2       z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname____doc__r9r%propertyr$r&r'r)r2r4r5r.rIrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r#loopZ ssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rQ_get_extra_info)r#namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rQ _app_protocol)r#protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rQrX)r#rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rR)r#rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rRrQ_start_shutdown)r#rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rRwarningswarnResourceWarningr^)r#rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rQ _transport pause_reading)r#rrrreQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rQrdresume_reading)r#rrrrfYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rQrdset_write_buffer_limits)r#ZhighZlowrrrrgasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)z,Return the current size of the write buffer.)rQrdget_write_buffer_size)r#rrrrhvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrF TypeErrorformattyperJrQ_write_appdata)r#rBrrrr7zs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rQ_abort)r#rrrabortsz_SSLProtocolTransport.abort)N)NN)rJrKrLr%rWrZr[r\r^rZPY34rcrerfrgrhr7rprrrrrrrO&s   rOc@seZdZdZd(ddZd)ddZd d Zd d Zd dZddZ ddZ ddZ d*ddZ ddZ ddZddZddZdd Zd+d"d#Zd$d%Zd&d'ZdS), SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrPrXrO_app_transport_sslpipe_session_established _in_handshake _in_shutdownrd_call_connection_made)r#rSZ app_protocolrZwaiterrrZcall_connection_maderrrr%s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)r{Z cancelledZ set_exceptionZ set_result)r#rDrrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rdrrtrrr}_start_handshake)r# transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)r~rP call_soonrXconnection_lostrdr|r)r#rDrrrrs zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rX pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rXresume_writing)r#rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. Nz%r: SSL error %s (reason %s))r}r.r r;rP get_debugrwarningr6rGrqrdr7rX data_receivedr])r#rBr0r1erCrrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rPrrdebugrConnectionResetErrorrrX eof_receivedrrdr^)r#Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rvrdrW)r#rUrVrrrrT!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr*)rrrqro)r#rrrr])s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)ryr:rzrE_process_write_backlog)r#rBrrrro2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr*r)r*r) rPrrrtime_handshake_start_timerryr:r)r#rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr&)$rr}r&Z getpeercertr rtrr r Z CERT_NONEZmatch_hostname BaseExceptionrPrrir<rrrdr^ ExceptionrrrrrvupdaterrrrXrr|r~rr)r#Z handshake_excZsslobjrrDZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q*WWnRtk r8}z4|jr|j|n |j|dt|ts(WYdd}~XnXdS)NrrzFatal error on SSL transport)rdr}rangerEryrIr2rr4 _finalizer7Z_pausedrfrzrr _fatal_errorrir)r#irBrHr0rCrDrrrrws8      z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrY) rirZ_FATAL_ERROR_IGNORErPrrrZcall_exception_handlerrdZ _force_close)r#rDrrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r}rdr^)r#rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rdrrr)r#rrrrqs zSSLProtocol._abort)FNT)N)N)r)rJrKrLrMr%rrrrrrrrTr]rorrrrrrqrrrrrss& "     4, rs)rwr`r ImportErrorrrrrlogrrrrr-r(r3objectrZ_FlowControlMixinZ TransportrOZProtocolrsrrrrs*       wnPK!G^@vv,__pycache__/unix_events.cpython-36.opt-1.pycnu[3  f @s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkredddZy ejZWnek r,ddZYnXGdddejZ e!edrVddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%rej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python36/lib64/python3.6/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZdZd"fdd ZddZfddZd d Zd d Zd dZ ddZ ddZ d#ddZ d$ddZ ed%ddZddZeddddddZed&ddddd d!ZZS)'_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)rrrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)rsig)r!rrr%>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)rdatarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)rr.callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4rKeyErrorr5SIGINTdefault_int_handlerSIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr3r@r5NSIGr8)rr.rrrr4s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)rpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)rrOrPrQrRrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rQrR) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)rrPrBshellstdinstdoutstderrbufsizerRkwargswatcherrQtransprCerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)rpid returncoderbrrrrYsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|r|dkr&tdn|dk r&td|dk r|dk r>tdtjtjtjd}y |jd|j||EdHWq|jYqXnB|dkrtd|jtjkstj |j  rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r8r"AF_UNIX SOCK_STREAM setblockingZ sock_connectr%familyr_is_stream_sockettyper@Z_create_connection_transport)rprotocol_factoryrrgrhri transportrPrrrcreate_unix_connections8    z-_UnixSelectorEventLoop.create_unix_connectiond)rhbacklogrgc !Cst|trtd|dk r0|dk r,tdt|}tjtjtj}|dd kry tj t j|j rnt j |WnBt k rYn0tk r}ztjd||WYdd}~XnXy|j|Wnjtk r}z8|j|jtjkrdj|}ttj|dnWYdd}~Xn|jYnXn>|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rru)rKboolr3r8_fspathr"rjrkstatS_ISSOCKosst_moderemoveFileNotFoundErrorr9rerrorZbindr%r>Z EADDRINUSEr@rmrrnroZServerZlistenrlZ_start_serving) rrprrhrtrgrcrCmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname____doc__rr#r%r1rEr/r)r4rSrUr rdrYrrr __classcell__rr)r!rr1s, -      %r set_blockingcCstj|ddS)NF)rzr)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrz O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rNiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrOFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper7_fileno _protocol_closingrzfstatr{rxS_ISFIFOryS_ISCHRr8r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rlooprOrPrQrRmode)r!rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r!rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)rr=r rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rzreadrmax_sizeBlockingIOErrorInterruptedErrorr9 _fatal_errorrZ data_receivedr get_debugrr=r_remove_readerrZ eof_received_call_connection_lost)rr0rCrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)rrrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)rrrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)rrPrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)rrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)rrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)rrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrqrP) rKr9r>ZEIOrrrdebugcall_exception_handlerrr)rrCrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)rrCrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)rrCrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr%rPY34rrrrrrr)r!rrNMs rNcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rTNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrOrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr7rr bytearray_buffer _conn_lostrrzrr{rxrrryr8rrrrr&platform startswithrrr r) rrrOrPrQrRrZis_charZis_fifoZ is_socket)r!rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r!rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)rr=r rr_rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)rrrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr=rrBrokenPipeError)rrrrrs   z#_UnixWritePipeTransport._read_readycCst|trt|}|sdS|js&|jrN|jtjkrs&   z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr dSd|_|js4|jj|j|jj|jddS)NT)rrrrrrr)rrrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)rrPrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)rrrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)rrrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)rrrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrqrP) rKrZ_FATAL_ERROR_IGNORErrrrrrr)rrCrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr-rrr)rrCrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)rrCrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr%rrrrrrrrrr)r!rrTs$% !   rTset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rWc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r[r\r]r^Zuniversal_newlinesr_wb) buffering) subprocessPIPErr#rr7Popen_procr%rdetachr\) rrBr[r\r]r^r_r`Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrWsrWc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)rrerArBrrrrXs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)rrerrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)rrrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)rrrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)rrrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)rabcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrrXrrr%rrrrrrrs  c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)rrrrrszBaseChildWatcher.__init__cCs|jddS)N)r)rrrrr%szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)rrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk r$|dkr$|jr$tjdt|jdk r<|jjtj||_|dk rb|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrr*r+RuntimeWarningr)r5SIGCHLDrE _sig_chldr)rrrrrrs zBaseChildWatcher.attach_loopcCsFy |jWn4tk r@}z|jjd|dWYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)rr)rrZrr)rrCrrrr1s  zBaseChildWatcher._sig_chldcCs2tj|rtj| Stj|r*tj|S|SdS)N)rz WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)rstatusrrr_compute_returncode=s     z$BaseChildWatcher._compute_returncodeN) rrrrr%rrrrrrrrrrs rcsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cs|jjtjdS)N)rr-rr%)r)r!rrr%Vs zSafeChildWatcher.closecCs|S)Nr)rrrrrZszSafeChildWatcher.__enter__cCsdS)Nr)rrrrrrrr]szSafeChildWatcher.__exit__cGs.|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rr)rrerArBrrrrX`s  z"SafeChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrks z%SafeChildWatcher.remove_child_handlercCs"xt|jD]}|j|q WdS)N)r(rr)rrerrrrrsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn(tk r>|}d}tjd|Yn0X|dkrLdS|j|}|jjrntj d||y|j j |\}}Wn.t k r|jjrtjd|ddYnX|||f|dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r) rzwaitpidWNOHANGChildProcessErrorrrrrrrrpoprG)rrrerrfrArBrrrrws*    zSafeChildWatcher._do_waitpid) rrrrr%rrrXrrrrrr)r!rrKs   csTeZdZdZfddZfddZddZdd Zd d Zd d Z ddZ Z S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs$tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r)r!rrrs  zFastChildWatcher.__init__cs"|jj|jjtjdS)N)rr-rrr%)r)r!rrr%s  zFastChildWatcher.closec Cs$|j|jd7_|SQRXdS)Nr)rr)rrrrrszFastChildWatcher.__enter__c CsV|j:|jd8_|js$|j r(dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr;r-rr)rrrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGsl|jdkrtd|j:y|jj|}Wn"tk rL||f|j|<dSXWdQRX|||f|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rrrrGr)rrerArBrfrrrrXs z"FastChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrs z%FastChildWatcher.remove_child_handlercCsxytjdtj\}}Wntk r,dSX|dkr:dS|j|}|jvy|jj|\}}WnBtk r|j r||j |<|j j rt jd||wd}YnX|j j rt jd||WdQRX|dkrt jd||q|||f|qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)rzrrrrrrrrGrrrrrrr)rrerrfrArBrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrrr%rrrXrrrrr)r!rrs   csHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r)r!rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrKrcurrent_thread _MainThreadr_localr)rrrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrKrrrr)rr)r!rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)rrrrrV&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|jj||_dS)z$Set the watcher for child processes.N)rr%)rrarrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrrrVrrrr)r!rrs   r)5rr>rzr5r"rxrr&rr*rrrrrrr r r r r logr__all__r ImportErrorrfspathrwAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrNZ_FlowControlMixinZWriteTransportrTrrZBaseSubprocessTransportrWrrrrZBaseDefaultEventLoopPolicyrrrrrrrsn                O  F=On2PK!$pJ..&__pycache__/tasks.cpython-36.opt-2.pycnu[3 2aa @sdddddddddd d d d g Zd dlZd dlZd dlZd dlZd dlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddl m Z Gddde jZeZy d dlZWnek rYn XejZZej jZej jZej jZe ddedddZddZe ddddZe ddZdddd dZe d.ddd!dZddd"d#Zeed<de_[ddd$d Z e d%d&Z!Gd'd(d(e jZ"dd)d*d+d Z#ddd,d Z$d-d Z%dS)/TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZejZiZdZedddZ edddZ ddfdd Z e j rTd d Zd d ZddddZdddddZddZdfdd ZddZZS)rTNcCs|dkrtj}|jj|S)N)rget_event_loop_current_tasksget)clsloopr*/opt/alt/python36/lib64/python3.6/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsNtj|d|jr|jd=||_d|_d|_|jj|j|j j j |dS)N)rrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r-rrr&Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr'rZcall_exception_handlerFuture__del__)r/contextrrrr5Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r/rrr _repr_info^szTask._repr_info)limitcCs tj||S)N)rZ_task_get_stack)r/r8rrr get_stackaszTask.get_stack)r8filecCstj|||S)N)rZ_task_print_stack)r/r8r:rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)NFT)Z_log_tracebackdoner)cancelr*)r/rrrr=s  z Task.cancelcsf|jr t|tjstj}d|_|j}d|_||jj|j<zy"|dkrT|j d}n |j |}Wnt k r}z.|jrd|_|j tjn |j |jWYdd}~Xntjk rtjYn|tk r}z|j |WYdd}~XnPtk r(}z|j |WYdd}~Xn Xt|dd}|dk r|j|jk rl|jj|jtdj||n||r||kr|jj|jtdj|n2d|_|j|j||_|jr|jjrd|_n|jj|jtdj||n^|dkr|jj|jnDtj|r.|jj|jtdj||n|jj|jtdj|Wd|jjj|jd}XdS)NF_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r* isinstancerCancelledErrorr(r)r-rrsendthrow StopIteration set_exception set_resultvaluer%r= Exception BaseExceptiongetattrr+r, RuntimeErrorformatr>add_done_callback_wakeupinspectZ isgeneratorpop)r/excr0resultZblocking)r-rrr,s~           z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rQrGr,)r/futurerPrrrrMs  z Task._wakeup)N)N)N)__name__ __module__ __qualname__weakrefWeakSetr"rr3 classmethodrr#r&rZPY34r5r7r9r;r=r,rM __classcell__rr)r-rrs      !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)Nz expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}csh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturer iscoroutine TypeErrortyperS ValueErrorrrrrKrrset_wait)fsrrZr[r)rrrscGs|js|jddS)N)r<rE)waiterargsrrr_release_waiter<srg)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)N)r)rr create_future call_laterrg functoolspartialr rLrr@remove_done_callbackr=r<rQ TimeoutError)futrZrretimeout_handlecbrrrrAs,       c #s|jd|dk r"|j|tt|fdd}x|D]}|j|qBWzEdHWddk rtjXtt}}x4|D],}|j||jr|j |q|j |qW||fS)Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr=r<rE)r\)counterr[rorerr_on_completion|s z_wait.._on_completion) rhrirglenrLr=rbrlr<r.)rdrZr[rrtr\r<pendingr)rsr[rorerrcos&     rc)rrZc#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd}fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS) Nz expect a list of futures, not %scsh|]}t|dqS))r)r )rr\)rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)rl put_nowaitclear)r\)rtr<todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)removerxr=)r\)r<rorzrrrts   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrmrQ)r\)r<rr _wait_for_onesz#as_completed.._wait_for_one)rr]rr^r_r`rSrrrbZqueuesrwrrLrirangeru)rdrrZrwr{r}r\_r)rtr<rrorzrrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)Nr)rrrhrrirZ_set_result_unless_cancelledr=)ZdelayrQrrRhrrrrs cCstjdtddt||dS)Nz;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr]rrarr^rrZ create_taskr'rZPY35rNZ isawaitabler _wrap_awaitabler_)rrr1rrrr s   ccs|jEdHS)N) __await__)Z awaitablerrrrsrcs*eZdZddfdd ZddZZS)_GatheringFutureN)rcstj|d||_d|_dS)N)rF)r%r& _children_cancel_requested)r/childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r<rr=r)r/retZchildrrrr=)s z_GatheringFuture.cancel)rSrTrUr&r=rYrr)r-rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd}x&t |D]\}}|jtj||qWS) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r<rqrrrr@rDZ _exceptionZ_resultrrE)irnres) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrhrErbrr]r rr3rarur enumeraterLrjrk)rrZcoros_or_futuresrrnrrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)N)rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rqrrr=rDrErQ)innerrP)rrrrs  zshield.._done_callback)r r<rrhrL)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)NzA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rGZset_running_or_notify_cancelrD)rP)r0rRrrrcallbacks  z*run_coroutine_threadsafe..callback)rr^r_ concurrentrr4Zcall_soon_threadsafe)r0rrr)r0rRrrr s    )N)&__all__concurrent.futuresrrjrNrrVrrrrrrr4rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrgrrcrrrglobalsrSr rrr r r rrrrsX        s  - -8  W5PK!= __pycache__/log.cpython-36.pycnu[3  f|@sdZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python36/lib64/python3.6/asyncio/log.pysPK!.5?+__pycache__/subprocess.cpython-36.opt-1.pycnu[3  f@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__7/opt/alt/python36/lib64/python3.6/asyncio/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr=szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr?szProcess.terminatecCs|jjdS)N)rkill)rrrrr@sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrCr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|j}|jjrJ|dkr8dnd}tjd|||jEdH}|jjr|dkrndnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&rAr rCreadr-)rr*r(streamnameoutputrrr _read_streams   zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rGrHrrMrrZgatherr&r<)rrFrrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr;r r<r=r?r@rGrHrMrNrrrrr9ks      r9c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr9) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrPsz(create_subprocess_exec..)rrr)rrQZsubprocess_execr9) Zprogramrrrr rargsrSrTr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r9Z_DEFAULT_LIMITrrrrrrs(      X] PK! :t?t?0__pycache__/proactor_events.cpython-36.opt-2.pycnu[3 2aO@sdgZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z Gd d d e j e j ZGd ddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercs~eZdZdfdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ dddZ ddZddZddZZS)_ProactorBasePipeTransportNcstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__4/opt/alt/python36/lib64/python3.6/proactor_events.pyr s$    z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jdk rN|jd|jj|jdk rh|jd|j|jdk r|jd|j|jrt |j}|jd||j r|jddd j |S) Nclosedclosingzfd=%szread=%szwrite=%rzwrite_bufsize=%sz EOF writtenz<%s> ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs8eZdZd fdd ZddZddZd dd ZZS) _ProactorReadPipeTransportNcs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrQrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrQrRrrrSrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z"yH|dk r0d|_|j}|jr>d}dS|dkrJdS|jjj|jd|_Wnt k r}z2|js|j |dn|jj rt j dddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r}z|j |dWYdd}~Xn0tjk r&|js"YnX|jj|jWd|rN|jj|n:|dk r|jj rpt j d||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rQrRrresultrr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrSrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rSsH     z(_ProactorReadPipeTransport._loop_reading)NNN)N)r(rMrNr rTrUrSrOr#r#)r"r$rPs  rPc@s6eZdZddZd ddZddZdd Zd d ZdS) _ProactorBaseWritePipeTransportcCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr rhZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rrvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJrn)rr#r#r$rsys   z"_ProactorSocketTransport.write_eof)NNN)r(rMrNr rrrrsrOr#r#)r"r$r}\s r}cseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rX _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r})rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler|Z SSLProtocolr}Z_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r{)rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rP)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)ru)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningrg is_closed_stop_accept_futures_close_self_piperXr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rXrY)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rXro)rrr`r#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rXZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rXaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r|)rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rWrXrYrrr] ExceptionrDrr^r)rrqrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rro)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr~)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rWZ_debugr rCrrrrXrr\r*rDr7rr]rr^)rqZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrX _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrOr#r#)r"r$rs4          ()__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrPZWriteTransportraruZ Transportr{r}Z BaseEventLooprr#r#r#r$s0        M T  #PK!II&__pycache__/tasks.cpython-36.opt-1.pycnu[3  fa @sdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ddl mZGddde jZeZy ddlZWnek rYn XejZZej jZej jZej jZeddedddZddZeddddZeddZddd d!dZed/ddd"dZddd#d$Zeed <d e_ [ddd%d Z!ed&d'Z"Gd(d)d)e jZ#dd*d+d,d Z$ddd-d Z%d.d Z&dS)0z0Support for tasks, coroutines and the scheduler.TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZdZejZiZdZe dddZ e dddZ ddfd d Z e jrXd d Zd dZddddZdddddZddZdfdd ZddZZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj}|jj|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. N)rget_event_loop_current_tasksget)clsloopr2/opt/alt/python36/lib64/python3.6/asyncio/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsNtj|d|jr|jd=||_d|_d|_|jj|j|j j j |dS)N)rrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r-rrr&Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr'rZcall_exception_handlerFuture__del__)r/contextrrrr5Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r/rrr _repr_info^szTask._repr_info)limitcCs tj||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)r/r8rrr get_stackaszTask.get_stack)r8filecCstj|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)r/r8r:rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner)cancelr*)r/rrrr=s  z Task.cancelcsf|jr t|tjstj}d|_|j}d|_||jj|j<zy"|dkrT|j d}n |j |}Wnt k r}z.|jrd|_|j tjn |j |jWYdd}~Xntjk rtjYn|tk r}z|j |WYdd}~XnPtk r(}z|j |WYdd}~Xn Xt|dd}|dk r|j|jk rl|jj|jtdj||n||r||kr|jj|jtdj|n2d|_|j|j||_|jr|jjrd|_n|jj|jtdj||n^|dkr|jj|jnDtj|r.|jj|jtdj||n|jj|jtdj|Wd|jjj|jd}XdS)NF_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r* isinstancerCancelledErrorr(r)r-rrsendthrow StopIteration set_exception set_resultvaluer%r= Exception BaseExceptiongetattrr+r, RuntimeErrorformatr>add_done_callback_wakeupinspectZ isgeneratorpop)r/excr0resultZblocking)r-rrr,s~           z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rQrGr,)r/futurerPrrrrMs  z Task._wakeup)N)N)N)__name__ __module__ __qualname____doc__weakrefWeakSetr"rr3 classmethodrr#r&rZPY34r5r7r9r;r=r,rM __classcell__rr)r-rrs"     !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)aWait for the Futures and coroutines given by fs to complete. The sequence futures must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = yield from asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturer iscoroutine TypeErrortyperS ValueErrorrrrrKrrset_wait)fsrr[r\r)rrrscGs|js|jddS)N)r<rE)waiterargsrrr_release_waiter<srh)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. N)r)rr create_future call_laterrh functoolspartialr rLrr@remove_done_callbackr=r<rQ TimeoutError)futr[rrftimeout_handlecbrrrrAs,       c #s|jd|dk r"|j|tt|fdd}x|D]}|j|qBWzEdHWddk rtjXtt}}x4|D],}|j||jr|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr=r<rE)r])counterr\rprfrr_on_completion|s z_wait.._on_completion) rirjrhlenrLr=rcrmr<r.)rer[r\rrur]r<pendingr)rtr\rprfrrdos&     rd)rr[c#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcsh|]}t|dqS))r)r )rr])rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)rm put_nowaitclear)r])rur<todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)removeryr=)r])r<rpr{rrrus   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrnrQ)r])r<rr _wait_for_onesz#as_completed.._wait_for_one)rr^rr_r`rarSrrrcZqueuesrxrrLrjrangerv)rerr[rxr|r~r]_r)rur<rrpr{rrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrirrjrZ_set_result_unless_cancelledr=)ZdelayrQrrRhrrrrs cCstjdtddt||dS)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr^rrbrr_rrZ create_taskr'rZPY35rNZ isawaitabler _wrap_awaitabler`)rrr1rrrr s   ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. N)rcstj|d||_d|_dS)N)rF)r%r& _children_cancel_requested)r/childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r<rr=r)r/ZretZchildrrrr=)s z_GatheringFuture.cancel)rSrTrUrVr&r=rZrr)r-rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd }x&t |D]\}}|jtj||qWS) a7Return a future aggregating results from the given coroutines or futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r<rrrsrr@rDZ _exceptionZ_resultrrE)irores) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrirErcrr^r rr3rbrvr enumeraterLrkrl)rrZcoros_or_futuresrrorrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None )rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rrrsr=rDrErQ)innerrP)rrrrs  zshield.._done_callback)r r<rrirL)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rGZset_running_or_notify_cancelrD)rP)r0rRrrrcallbacks  z*run_coroutine_threadsafe..callback)rr_r` concurrentrr4Zcall_soon_threadsafe)r0rrr)r0rRrrr s    )N)'rV__all__Zconcurrent.futuresrrkrNrrWrrrrrrr4rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrhrrdrrrglobalsrSr rrr r r rrrrsZ        s  - -8  W5PK!ݸBa#__pycache__/__init__.cpython-36.pycnu[3  f@sBdZddlZyddlmZWnek r8ddlZYnXejdkrryddlmZWnek rpddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkr,ddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorsZwin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r 5/opt/alt/python36/lib64/python3.6/asyncio/__init__.pys8  :  PK!w<`?`?+__pycache__/test_utils.cpython-36.opt-2.pycnu[3 2a: @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"ej#dkrDddl$m%Z%n ddlm%Z%ddZ&e&dZ'e&dZ(ddZ)ddZ*dQddZ+ddZ,GdddeZ-Gd d!d!eZ.Gd"d#d#Z/Gd$d%d%e/e.Z0d&d'd(d)Z1e2ed*rVGd+d,d,ej3eZ4Gd-d.d.e4eZ5Gd/d0d0e5Z6Gd1d2d2e/e6Z7d3d4Z8ej9d5d6Z:ej9d&d'd7d8Z;ej9d9dd&d:d;d<ZZ=Gd?d@d@ej>Z?GdAdBdBej@ZAdCdDZBGdEdFdFeCZDdGdHZEGdIdJdJe jFZFej9dKdLZGejHejIejJfdMdNZKdOdPZLdS)RN)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer//opt/alt/python36/lib64/python3.6/test_utils.py data_file-s   r z ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr#c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr$gentrrr run_brieflyCs  r*cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r')timer TimeoutErrorr%r Zsleep)r'ZpredtimeoutZdeadlinerrr run_untilRs  r/cCs|j|j|jdS)N)Z call_soonstopZ run_forever)r'rrrrun_once\s r1c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r5formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r6r9rrrrr2gsr2cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r5request client_addr) __class__rrr@ts zSilentWSGIServer.get_requestcCsdS)Nr)r5rCclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r:r;r<rBr@rG __classcell__rr)rErr=ps r=c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr!r"Zload_cert_chainZ wrap_socketZRequestHandlerClassr&OSError)r5rCrFZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r:r;r<rNrrrrrI}srIc@s eZdZdS) SSLWSGIServerN)r:r;r<rrrrrOsrOF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rQrRr)environZstart_responsestatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r2Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rYrP server_clsserver_ssl_clsrUZ server_classZ server_threadr)rVr_run_test_servers    r_ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r5rrrrds zUnixHTTPServer.server_bindN)r:r;r<rdrrrrr`sr`cs(eZdZdZddZfddZZS)UnixWSGIServerr>cCstj||jdS)N)r`rdZ setup_environ)r5rrrrds zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rfrg)r?r@rArB)r5rCrD)rErrr@s zUnixWSGIServer.get_request)r:r;r<rBrdr@rHrr)rErresrec@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r5rCrFrrrrGsz!SilentUnixWSGIServer.handle_errorN)r:r;r<rGrrrrrhsrhc@s eZdZdS)UnixSSLWSGIServerN)r:r;r<rrrrrisric Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rmccs<t}z |VWdytj|Wntk r4YnXXdS)N)rmrunlinkrL)rrrrunix_socket_paths roc cs,t}t||ttdEdHWdQRXdS)N)rYrPr]r^)ror_rhri)rPrrrrrun_test_unix_serversrpz 127.0.0.1)hostportrPccst||f|ttdEdHdS)N)rYrPr]r^)r_r=rO)rqrrrPrrrrun_test_servers rscCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrkrrrmake_test_protocols r}c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r5rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr)r5fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)rpop)r5rrrr unregister szTestSelector.unregistercCsgS)Nr)r5r.rrrselectszTestSelector.selectcCs|jS)N)r)r5rrrget_mapszTestSelector.get_map)N)r:r;r<rrrrrrrrrr~s  r~cseZdZd,fdd ZddZddZfdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zfd$d%Zfd&d'Zd(d)Zd*d+ZZS)-TestLoopNcsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr(,szTestLoop.__init__..genFTrg& .>)r?r_check_on_close_gennext_timeZ_clock_resolution_timersr~Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r5r()rErrr(s  zTestLoop.__init__cCs|jS)N)r)r5rrrr,?sz TestLoop.timecCs|r|j|7_dS)N)r)r5advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r?r&rrsend StopIterationAssertionError)r5)rErrr&Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r5fdcallbackr8rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r5rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rrZ _callbackZ_args)r5rrr8handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r5rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r5rrr8rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r5rrrr_remove_writerns  zTestLoop._remove_writercGs|j|}dS)N)r)r5rrr8rrrr assert_writervs zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr7)r5rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)N)rr)r5rrr8rrr add_readers zTestLoop.add_readercCs|j||j|S)N)rr)r5rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)N)rr)r5rrr8rrr add_writers zTestLoop.add_writercCs|j||j|S)N)rr)r5rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r5rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r? _run_oncerrrr)r5whenr)rErrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr?call_at)r5rrr8)rErrrs zTestLoop.call_atcCsdS)Nr)r5Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r5rrr_write_to_selfszTestLoop._write_to_self)N)r:r;r<rr,rr&rrrrrrrrrrrrrrrrrrHrr)rErrs*     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrysryc@seZdZddZdS) MockPatterncCsttjt||tjS)N)boolresearchstrS)r5otherrrr__eq__szMockPattern.__eq__N)r:r;r<rrrrrrs rcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorr\r&)r'executorrrr close_loops zTestCase.close_loopT)cleanupcCs tjd|r|j|j|dS)N)r set_event_loopZ addCleanupr)r5r'rrrrrs zTestCase.set_event_loopNcCst|}|j||S)N)rr)r5r(r'rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r5rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrWsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r5rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r5rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r5rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r5excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r:r;r<rrrrrrEmptyCMsrr)r5r8rrrrrsubTestszTestCase.subTest)N) r:r;r< staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)Nr)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)Ng)rZ MagicMocksocketprotorzfamilyZ gettimeoutru)rrzrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)ru)rZpatchrrrrforce_legacy_ssl_supportsr)r+)Mr contextlibr3rrrrrbrrjrZr,ZunittestrrZ http.serverrZwsgiref.simple_serverrrr! ImportErrorrgrrr r r r Z coroutinesr logrrrplatformZ windows_utilsrr rKrJr#r*r/r1r2r=rIrOr_rrcr`rerhrirmcontextmanagerrorprsr}Z BaseSelectorr~Z BaseEventLooprryrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 PK!= $__pycache__/log.cpython-36.opt-1.pycnu[3  f|@sdZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python36/lib64/python3.6/asyncio/log.pysPK!=( ! !+__pycache__/coroutines.cpython-36.opt-1.pycnu[3  f+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r 7/opt/alt/python36/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCs>||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGs4tj}|j}|jj|jtkr(|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr!r/Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r9szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r:szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r;szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r<szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr=r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rAszCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rr r r r=szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rBszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rCszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rDszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr:rDrz%r was never yielded fromr)zB Coroutine object created at (most recent call last, truncated to z last lines): r+) r*r4joinr8 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr/msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr0rr_YIELD_FROM_BUGrr6r9propertyr:r;r<rZPY35r@rAr=rBrCrDrLr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r ZisfutureinspectZ isgenerator isinstancer$ _AwaitableABCr@AttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..coroNcs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr+)r$r)r*rr)rSkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionrOisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rXr )r"r r rs   cCst|ddtkpt|S)z6Return True if func is a decorated coroutine function.r_N)r*r_rY)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rP_COROUTINE_TYPES)objr r r rsc Cst|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk r~y |j}Wntk rxYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkrt j |fi}d}t|dr|jr|j}nt|dr|jr|j}d}t|dr0|jr0|j}nt|d rJ|jrJ|j}d }|rb|jrb|j}d }|}t|t rtj|j  r|j dk rt j|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r|j}d |||f}|S)NrCr<rrz{}()Fz {} runningrDr:zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr?rBrRr;rPr$r rrZ_format_callbackrCr<rDr: co_filenamerOrZZ_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor.sourcer r r r,sx              r,).__all__r[rOZopcodeosr'r8typesrErrrr logr Zopmapr5flagsignore_environmentboolenvirongetr]rr^ CoroutineTypeZ_types_CoroutineTyperRrrYcollections.abcrZ _CoroutineABCrrQ ImportErrorr#rMr%r$objectr_ GeneratorTyper`rr,r r r r sZ         j:     PK! E E%__pycache__/test_utils.cpython-36.pycnu[3  f: @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrHddl%m&Z&n ddlm&Z&ddZ'e'dZ(e'dZ)ddZ*ddZ+dRddZ,ddZ-Gdd d eZ.Gd!d"d"eZ/Gd#d$d$Z0Gd%d&d&e0e/Z1d'd(d)d*Z2e3ed+rZGd,d-d-ej4eZ5Gd.d/d/e5eZ6Gd0d1d1e6Z7Gd2d3d3e0e7Z8d4d5Z9ej:d6d7Z;ej:d'd(d8d9Zd?Z>Gd@dAdAej?Z@GdBdCdCejAZBdDdEZCGdFdGdGeDZEdHdIZFGdJdKdKe jGZGej:dLdMZHejIejJejKfdNdOZLdPdQZMdS)SzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportZwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer7/opt/alt/python36/lib64/python3.6/asyncio/test_utils.py data_file-s   rz ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr"c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr#gentrrr run_brieflyCs  r)cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r&)timer TimeoutErrorr$r Zsleep)r&ZpredtimeoutZdeadlinerrr run_untilRs  r.cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)r&rrrrun_once\s r0c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r5r8rrrrr1gsr1cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r4request client_addr) __class__rrr?ts zSilentWSGIServer.get_requestcCsdS)Nr)r4rBclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF __classcell__rr)rDrr<ps r<c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr r!Zload_cert_chainZ wrap_socketZRequestHandlerClassr%OSError)r4rBrEZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@s eZdZdS) SSLWSGIServerN)r9r:r;rrrrrNsrNF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rPrQr)environZstart_responseZstatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r1Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rWrO server_clsserver_ssl_clsrSZ server_classZ server_threadr)rTr_run_test_servers    r]ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r4rrrrbs zUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^sr^cs(eZdZdZddZfddZZS)UnixWSGIServerr=cCstj||jdS)N)r^rbZ setup_environ)r4rrrrbs zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rdre)r>r?r@rA)r4rBrC)rDrrr?s zUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrcsrcc@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrFsz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrfsrfc@s eZdZdS)UnixSSLWSGIServerN)r9r:r;rrrrrgsrgc Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rkccs<t}z |VWdytj|Wntk r4YnXXdS)N)rkrunlinkrK)rrrrunix_socket_paths rmc cs,t}t||ttdEdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrrrun_test_unix_serversrnz 127.0.0.1)hostportrOccst||f|ttdEdHdS)N)rWrOr[r\)r]r<rN)rorprOrrrrun_test_servers rqcCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrirrrmake_test_protocols r{c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r4rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr})r4fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)r}pop)r4rrrr unregister szTestSelector.unregistercCsgS)Nr)r4r-rrrselectszTestSelector.selectcCs|jS)N)r})r4rrrget_mapszTestSelector.get_map)N)r9r:r;r~rrrrrrrrr|s  r|cseZdZdZd-fdd ZddZddZfd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zfd%d&Zfd'd(Zd)d*Zd+d,ZZS).TestLoopaLoop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. Ncsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr',szTestLoop.__init__..genFTrg& .>)r>r~_check_on_close_gennext_timeZ_clock_resolution_timersr|Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r4r')rDrrr~(s  zTestLoop.__init__cCs|jS)N)r)r4rrrr+?sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r4advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r>r%rrsend StopIterationAssertionError)r4)rDrrr%Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r4fdcallbackr7rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r4rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rr _callback_args)r4rrr7handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r4rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r4rrr7rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r4rrrr_remove_writerns  zTestLoop._remove_writercGs^||jkstdj||j|}|j|ks>tdj|j||j|ksZtdj|j|dS)Nzfd {} is not registeredz {!r} != {!r})rrr6rr)r4rrr7rrrr assert_writervs   zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr6)r4rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)zAdd a reader callback.)rr)r4rrr7rrr add_readers zTestLoop.add_readercCs|j||j|S)zRemove a reader callback.)rr)r4rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rr)r4rrr7rrr add_writers zTestLoop.add_writercCs|j||j|S)zRemove a writer callback.)rr)r4rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r4rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r> _run_oncerrrr)r4whenr)rDrrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr>call_at)r4rrr7)rDrrrs zTestLoop.call_atcCsdS)Nr)r4Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r4rrr_write_to_selfszTestLoop._write_to_self)N)r9r:r;__doc__r~r+rr%rrrrrrrrrrrrrrrrrrGrr)rDrrs,     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrwsrwc@seZdZdZddZdS) MockPatternzA regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) cCsttjt||tjS)N)boolresearchstrS)r4otherrrr__eq__szMockPattern.__eq__N)r9r:r;rrrrrrrsrcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorrZr%)r&Zexecutorrrr close_loops zTestCase.close_loopT)cleanupcCs,|dk s ttjd|r(|j|j|dS)N)rr set_event_loopZ addCleanupr)r4r&rrrrrs  zTestCase.set_event_loopNcCst|}|j||S)N)rr)r4r'r&rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r4rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrUsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r4rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r4rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r4rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r4excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r9r:r;rrrrrrEmptyCMsrr)r4r7rrrrrsubTestszTestCase.subTest)N) r9r:r; staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorxfamilyZ gettimeoutrs)rrxrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrrforce_legacy_ssl_supportsr)r*)Nrr contextlibr2rrrrr`rrhrXr+ZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrerrr r r r Z coroutinesr logrrrplatformZ windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrkcontextmanagerrmrnrqr{Z BaseSelectorr|Z BaseEventLooprrwrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 PK! / /+__pycache__/transports.cpython-36.opt-1.pycnu[3  fR'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkr i}||_dS)N)_extra)selfextrar 7/opt/alt/python36/lib64/python3.6/asyncio/transports.py__init__ szBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCstdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s eZdZdZddZddZdS)rz#Interface for read-only transports.cCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-sc@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineses zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort)NN) rrrrr!r"r$r%r&r'r(r r r r rAs   c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rsc@s"eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)N)rrrrr)r(r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs csVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. Ncs$tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r" _high_waterr5 _protocolZ pause_writing Exceptionr4call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r8r9r:r)r5r" _low_waterr<Zresume_writingr=r4r>)r r@r r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rBr;)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr;rB)r rr r r r r6s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr )r6rA)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrArCrDr6r!r" __classcell__r r )r7r r2s  r2N) rZasyncior__all__rrrrrrr2r r r r s  #D4PK!`hh$__pycache__/protocols.cpython-36.pycnu[3  f@sRdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s0eZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr6/opt/alt/python36/lib64/python3.6/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs c@s eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>sc@s eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgsc@s(eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrtsN)r__all__rrrrrrrrs 7) PK!RZR   +__pycache__/coroutines.cpython-36.opt-2.pycnu[3 2a+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r //opt/alt/python36/lib64/python3.6/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCs>||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGs4tj}|j}|jj|jtkr(|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr!r/Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r9szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r:szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r;szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r<szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr=r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rAszCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rr r r r=szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rBszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rCszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rDszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr:rDrz%r was never yielded fromr)zB Coroutine object created at (most recent call last, truncated to z last lines): r+) r*r4joinr8 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr/msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr0rr_YIELD_FROM_BUGrr6r9propertyr:r;r<rZPY35r@rAr=rBrCrDrLr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)Nc ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r ZisfutureinspectZ isgenerator isinstancer$ _AwaitableABCr@AttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr+)r$r)r*rr)rSkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionrOisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rXr )r"r r rs   cCst|ddtkpt|S)Nr_)r*r_rY)r r r r rscCs t|tS)N)rP_COROUTINE_TYPES)objr r r rsc Cst|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk r~y |j}Wntk rxYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkrt j |fi}d}t|dr|jr|j}nt|dr|jr|j}d}t|dr0|jr0|j}nt|d rJ|jrJ|j}d }|rb|jrb|j}d }|}t|t rtj|j  r|j dk rt j|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r|j}d |||f}|S)NrCr<rrz{}()Fz {} runningrDr:zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr?rBrRr;rPr$r rrZ_format_callbackrCr<rDr: co_filenamerOrZZ_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor.sourcer r r r,sx              r,).__all__r[rOZopcodeosr'r8typesrErrrr logr Zopmapr5flagsignore_environmentboolenvirongetr]rr^ CoroutineTypeZ_types_CoroutineTyperRrrYcollections.abcrZ _CoroutineABCrrQ ImportErrorr#rMr%r$objectr_ GeneratorTyper`rr,r r r r sZ         j:     PK!+k44(__pycache__/futures.cpython-36.opt-1.pycnu[3  f> @s dZddddddgZddlZddlZddlZddlZd d lmZd d lm Z d d lm Z ej Z ej Z ej Z ejZejZejZejZejd ZGd ddZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s4eZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr4/opt/alt/python36/lib64/python3.6/asyncio/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr) __name__ __module__ __qualname____doc__ __slots__rrrr&rrrrr s 0r c@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZejrRd d Zd d Zd dZddZddZddZddZddZddZddZddZdd ZejreZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r5_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N)r-r call_soon)rZ callbackscallbackrrrr;s  zFuture._schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r8r:)rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r8r9)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN)r8r:r _FINISHEDrr5r6_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r8r:rrArr5r6)rrrrr4s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r8r9rr=r-append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. csg|]}|kr|qSrr).0f)rErr sz/Future.remove_done_callback..N)r-len)rrEZfiltered_callbacksZ removed_countr)rErremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r8r9rformatrBrAr;)rrCrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL isinstancetype StopIteration TypeErrorr6rAr;r PY34r5r Z _tb_loggerrr=r)rr4rrr set_exception,s    zFuture.set_exceptionccs|jsd|_|V|jS)NT)r@_asyncio_future_blockingrC)rrrr__iter__DszFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr Z_future_repr_infor2r3r rRr&r<r;r?r@rCr4rFrKrMrSrUZPY35 __await__rrrrrns4   cCs|jr dS|j|dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr_set_result_unless_cancelledSsrWcCsN|jr|j|jsdS|j}|dk r8|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N)r?r<Zset_running_or_notify_cancelr4rSrCrM) concurrentsourcer4rCrrr_set_concurrent_future_stateZs rZcCsP|jr dS|jr|jn.|j}|dk r:|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r?r<r4rSrCrM)rYdestr4rCrrr_copy_future_stateis  r\cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|rt||n t||dS)N)rr\rZ)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r?r<call_soon_threadsafe) destination) dest_looprY source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r?Z is_closedr_)rY)r^rar`rbrr_call_set_states  z&_chain_future.._call_set_state)rrNrXZfuturesrrQrrF)rYr`rcrdr)r^rar`rYrbr _chain_future}s   re)r cCs2t|r |S|dkrtj}|j}t|||S)z&Wrap concurrent.futures.Future object.N)rr r,Z create_futurere)rr Z new_futurerrrrs )r*__all__Zconcurrent.futuresrXZloggingr/rrr r r rrrrr9r:rADEBUGZ STACK_DEBUGr rZ _PyFuturerWrZr\rerZ_asyncio ImportErrorZ_CFuturerrrrs>     Pc*  PK! VC '__pycache__/queues.cpython-36.opt-1.pycnu[3  f@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr3/opt/alt/python36/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrsc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS)*ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts  z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7remove ValueErrorr8r( get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr>s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rr=rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r@r>rArCrrrrrs&      c@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrEr%rFr"rrrrrsc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs JoinableQueue)r__all__rrGrr r Z coroutinesr ExceptionrrrrrZPY35rIr#rrrrs     H PK!**__pycache__/constants.cpython-36.opt-2.pycnu[3 2as@sdZdZdZdS) N)Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr./opt/alt/python36/lib64/python3.6/constants.pysPK!n][3434(__pycache__/streams.cpython-36.opt-2.pycnu[3 2a_@sHdddddddgZddlZeed r2ejd d gd d lmZd dlmZd dlmZd dlmZd dlm Z d dl m Z d!Z Gddde ZGdddeZe d"de dddZe d#de dddZeed re d$de ddd Ze d%de ddd ZGdddejZGdddeejZGdddZGd ddZdS)& StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs$eZdZfddZddZZS)rcs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__,/opt/alt/python36/lib64/python3.6/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname__rr __classcell__rr)rrrs cs$eZdZfddZddZZS)rcstj|||_dS)N)rrconsumed)rmessager#)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr#)rrrrr4szLimitOverrunError.__reduce__)rr r!rrr"rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)N)r'r&)r&csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr&r'kwdsreader transport_writerr)r(rr8s   c+s8dkrtjfdd}j|||f|EdHS)Ncstd}t|d}|S)N)r'r&)r&)rr)r.r()client_connected_cbr'r&rrfactoryqs zstart_server..factory)rr*Z create_server)r2r+r,r&r'r-r3r)r2r'r&rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)N)r'r&)r&csS)Nrr)r(rrr)sz&open_unix_connection..)rr*rrZcreate_unix_connectionr)pathr&r'r-r.r/r0r1r)r(rr }s  c+s6dkrtjfdd}j||f|EdHS)Ncstd}t|d}|S)N)r'r&)r&)rr)r.r()r2r'r&rrr3s z"start_unix_server..factory)rr*Zcreate_unix_server)r2r4r&r'r-r3r)r2r'r&rr sc@s:eZdZd ddZddZddZdd Zed d ZdS) FlowControlMixinNcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr*_loop_paused _drain_waiter_connection_lost)rr&rrrrs  zFlowControlMixin.__init__cCs d|_|jjrtjd|dS)NTz%r pauses writing)r7r6 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jjrtjd||j}|dk rBd|_|jsB|jddS)NFz%r resumes writing)r7r6r:rr;r8done set_result)rwaiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r9r7r8r=r> set_exception)rexcr?rrrconnection_losts z FlowControlMixin.connection_lostccs<|jrtd|jsdS|j}|jj}||_|EdHdS)NzConnection lost)r9ConnectionResetErrorr7r8r6 create_future)rr?rrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!rr<r@rCrrFrrrrr5s   r5csBeZdZd fdd ZddZfddZdd Zd d ZZS) rNcs*tj|d||_d|_||_d|_dS)N)r&F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr2r&)rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rG set_transportget_extra_inforJrIrr6rHr Z iscoroutineZ create_task)rr/resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rGfeed_eofrArrCrH)rrB)rrrrCs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rG feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rGrOrJ)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!rrNrCrRrSr"rr)rrrs   c@sfeZdZddZddZeddZddZd d Zd d Z d dZ ddZ dddZ e ddZdS)rcCs||_||_||_||_dS)N) _transport _protocol_readerr6)rr/r(r.r&rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrTrVappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rT)rrrrr/'szStreamWriter.transportcCs|jj|dS)N)rTwrite)rrQrrrr\+szStreamWriter.writecCs|jj|dS)N)rT writelines)rrQrrrr].szStreamWriter.writelinescCs |jjS)N)rT write_eof)rrrrr^1szStreamWriter.write_eofcCs |jjS)N)rT can_write_eof)rrrrr_4szStreamWriter.can_write_eofcCs |jjS)N)rTclose)rrrrr`7szStreamWriter.closeNcCs|jj||S)N)rTrL)rnamedefaultrrrrL:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)N)rV exceptionrTZ is_closingrUrF)rrBrrrdrain=s    zStreamWriter.drain)N)rr r!rr[propertyr/r\r]r^r_r`rLrrdrrrrrs   c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr*r6 bytearray_buffer_eof_waiter _exceptionrTr7)rr'r&rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rW) rirXrrjrg_DEFAULT_LIMITrkrlrTr7rY)rrZrrrr[ks    zStreamReader.__repr__cCs|jS)N)rl)rrrrrc}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rlrk cancelledrA)rrBr?rrrrAs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)N)rkror>)rr?rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dS)N)rT)rr/rrrrKszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r7rrirgrTresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rjrp)rrrrrOszStreamReader.feed_eofcCs|jo |j S)N)rjri)rrrrat_eofszStreamReader.at_eofc Csv|sdS|jj||j|jdk rr|j rrt|jd|jkrry|jjWntk rjd|_YnXd|_dS)NrT) riextendrprTr7rrgZ pause_readingNotImplementedError)rrQrrrrPs   zStreamReader.feed_datac csV|jdk rtd||jr,d|_|jj|jj|_z|jEdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming dataF)rk RuntimeErrorr7rTrqr6rE)rZ func_namerrr_wait_for_datas   zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rB}z|jSd}~Xnftk r}zJ|jj||jrv|jd|j|=n |jj|j t |j dWYdd}~XnX|S)N r) r readuntilrrrri startswithr#clearrrrfr%)rsepseplenlineerrrreadlines  zStreamReader.readlinerxccst|}|dkrtd|jdk r(|jd}xt|j}|||kr||jj||}|dkr\P|d|}||jkr|td||jrt|j}|jj t |d|j dEdHq.W||jkrtd||jd||}|jd||=|j t|S)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitryz2Separator is found, but chunk is longer than limit) rrfrlrifindrgrrjbytesr{rrwrr)rZ separatorr}offsetbuflenZisepchunkrrrrys:         zStreamReader.readuntilr ccs|jdk r|j|dkrdS|dkrZg}x&|j|jEdH}|sBP|j|q*Wdj|S|j rz|j rz|jdEdHt|jd|}|jd|=|j |S)Nrread) rlrrgrXrYrirjrwrrr)rnZblocksblockrQrrrrPs$   zStreamReader.readccs|dkrtd|jdk r |j|dkr,dSxFt|j|krr|jr`t|j}|jjt|||jdEdHq.Wt|j|krt|j}|jjnt|jd|}|jd|=|j |S)Nrz*readexactly size can not be less than zeror readexactly) rfrlrrirjrr{rrwrr)rrZ incompleterQrrrrs&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs|jEdH}|dkrt|S)Nr)rStopAsyncIteration)rvalrrr __anext__szStreamReader.__anext__cCs|S)Nr)rrrrrs)rxr)r)rr r!rnrr[rcrArprKrrrOrsrPrrwrryrrr ZPY35rrZPY352rrrrrVs,    [ 2 *  i)NN)NN)N)N)__all__Zsockethasattrrtr r rrrlogrrnEOFErrorr Exceptionrrrr r ZProtocolr5rrrrrrrs@       "  B3GPK!^  $__pycache__/constants.cpython-36.pycnu[3  fs@sdZdZdZdZdS)z Constants. N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr6/opt/alt/python36/lib64/python3.6/asyncio/constants.pysPK!nmm0__pycache__/selector_events.cpython-36.opt-2.pycnu[3 2a @s8dgZddlZddlZddlZddlZddlZddlZy ddlZWnek rZdZYnXddl m Z ddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd lmZdd lmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyr4/opt/alt/python36/lib64/python3.6/selector_events.py_test_selector_event s rcsneZdZdNfdd ZdOdddddZdPdddddd d Zdddddd d ZdQd dZfddZddZ ddZ ddZ ddZ ddZ ddZdRddZdSd d!ZedTd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z d@dAZ!dBdCZ"dDdEZ#dFdGZ$dHdIZ%dJdKZ&dLdMZ'Z(S)UrNcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)NFT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)N)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)N)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)N)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)N)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)Nrzthe socket must be non-blocking)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)Nrzthe socket must be non-blocking)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)Nrzthe socket must be non-blockingAF_UNIX)familyprotoloop)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)Nrzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN))r __module__ __qualname__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sR      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jr dSy|jj|j}Wn\ttfk r4Yntk rx}z*|jj|j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrHrrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs&   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0)__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsB             iiPK!35)__pycache__/__init__.cpython-36.opt-2.pycnu[3 2a@s>ddlZyddlmZWnek r4ddlZYnXejdkrnyddlmZWnek rlddlZYnXddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTejejeje je je je je jejejejZejdkr(ddlTeej7ZnddlTeej7ZdS)N) selectorswin32) _overlapped)*)sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r -/opt/alt/python36/lib64/python3.6/__init__.pys6  :  PK!c=+__pycache__/subprocess.cpython-36.opt-2.pycnu[3 2a@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)SubprocessStreamProtocolcs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__//opt/alt/python36/lib64/python3.6/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr<szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr>szProcess.terminatecCs|jjdS)N)rkill)rrrrr?sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrBr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|j}|jjrJ|dkr8dnd}tjd|||jEdH}|jjr|dkrndnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&r@r rBreadr-)rr*r(streamnameoutputrrr _read_streams   zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rFrGrrLrrZgatherr&r;)rrErrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr:r r;r<r>r?rFrGrLrMrrrrr8ks      r8c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr8) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrOsz(create_subprocess_exec..)rrr)rrPZsubprocess_execr8) Zprogramrrrr rargsrRrSr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r8Z_DEFAULT_LIMITrrrrrrs(      X] PK!~^g<g<&__pycache__/locks.cpython-36.opt-1.pycnu[3  f<@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s(eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr2/opt/alt/python36/lib64/python3.6/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s r c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s  rcsReZdZdZddddZfddZdd Zed d Zd d Z ddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... N)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r?r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)z*Wake up the first waiter if it isn't done.NT)nextiterr( StopIterationdone set_result)rr@rrrr?s zLock._wake_up_first) rrrrrr0r,r rrr? __classcell__rr)r5rrYs4  csReZdZdZddddZfddZdd Zd d Zd d Ze ddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. N)r%cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rGr(rDrE)rr@rrrrHs  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rG)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rGr*r;r(r<r=)rr@rrrwait s   z Event.wait) rrrrrr0rIrHrJr rKrFrr)r5rrs  csZeZdZdZdddddZfddZedd Zed d Zdd dZ ddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. N)r%cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNTF) r,rrr*r;r(r<r=rr r>)rr@r6rrrrKEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rK)rZ predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)rnidxr@rrrnotifyys  zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rQr2r()rrrr notify_allszCondition.notify_all)N)r) rrrrrr0r rKrNrQrRrFrr)r5rr!s  &  csTeZdZdZdddddZfddZd d Zd d Zed dZ ddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rN)r%cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r r+)rvaluer%rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r(popleftrDrE)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrrs    zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rGrU)rrrrrszSemaphore.release)r) rrrrrr0rUr,r rrrFrr)r5rrs   cs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rN)r%cs||_tj||ddS)N)r%) _bound_valuer/r)rrSr%)r5rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrrs zBoundedSemaphore.release)r)rrrrrrrFrr)r5rrs)r__all__r&rr r Z coroutinesr r rrrrrrrrrrs    .ByMPK!@LL(__pycache__/streams.cpython-36.opt-1.pycnu[3  f_@sLdZdddddddgZdd lZeed r6ejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d"Z GdddeZGdddeZe d#d e dddZe d$d e dddZeed re d%d e ddd Ze d&d e ddd ZGddde jZGdddee jZGd ddZGd!ddZd S)'zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__4/opt/alt/python36/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname____doc__rr __classcell__rr)rrrs cs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager$)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N)r(r')r'csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr'r(kwdsreader transport_writerr)r)rr8s   c+s8dkrtjfdd}j|||f|EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncstd}t|d}|S)N)r(r')r')rr)r/r))client_connected_cbr(r'rrfactoryqs zstart_server..factory)rr+Z create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'csS)Nrr)r)rrr*sz&open_unix_connection..)rr+rrZcreate_unix_connectionr)pathr'r(r.r/r0r1r2r)r)rr }s  c+s6dkrtjfdd}j||f|EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncstd}t|d}|S)N)r(r')r')rr)r/r))r3r(r'rrr4s z"start_unix_server..factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr sc@s>eZdZdZd ddZddZddZd d Zed d Z dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr+_loop_paused _drain_waiter_connection_lost)rr'rrrrs  zFlowControlMixin.__init__cCs d|_|jjrtjd|dS)NTz%r pauses writing)r8r7 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jjrtjd||j}|dk rBd|_|jsB|jddS)NFz%r resumes writing)r8r7r;rr<r9done set_result)rwaiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r:r8r9r>r? set_exception)rexcr@rrrconnection_losts z FlowControlMixin.connection_lostccs<|jrtd|jsdS|j}|jj}||_|EdHdS)NzConnection lost)r:ConnectionResetErrorr8r9r7 create_future)rr@rrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!r"rr=rArDrrGrrrrr6s   r6csFeZdZdZd fdd ZddZfddZd d Zd d ZZ S)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs*tj|d||_d|_||_d|_dS)N)r'F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr3r')rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rH set_transportget_extra_inforKrJrr7rIr Z iscoroutineZ create_task)rr0resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rHfeed_eofrBrrDrI)rrC)rrrrDs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rH feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rHrPrK)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!r"rrOrDrSrTr#rr)rrrs  c@sjeZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs||_||_||_||_dS)N) _transport _protocol_readerr7)rr0r)r/r'rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrUrWappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rU)rrrrr0'szStreamWriter.transportcCs|jj|dS)N)rUwrite)rrRrrrr]+szStreamWriter.writecCs|jj|dS)N)rU writelines)rrRrrrr^.szStreamWriter.writelinescCs |jjS)N)rU write_eof)rrrrr_1szStreamWriter.write_eofcCs |jjS)N)rU can_write_eof)rrrrr`4szStreamWriter.can_write_eofcCs |jjS)N)rUclose)rrrrra7szStreamWriter.closeNcCs|jj||S)N)rUrM)rnamedefaultrrrrM:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rW exceptionrUZ is_closingrVrG)rrCrrrdrain=s    zStreamWriter.drain)N)rr r!r"rr\propertyr0r]r^r_r`rarMrrerrrrrs  c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr+r7 bytearray_buffer_eof_waiter _exceptionrUr8)rr(r'rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rX) rjrYrrkrh_DEFAULT_LIMITrlrmrUr8rZ)rr[rrrr\ks    zStreamReader.__repr__cCs|jS)N)rm)rrrrrd}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rmrl cancelledrB)rrCr@rrrrBs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rlrpr?)rr@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dS)N)rU)rr0rrrrLszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r8rrjrhrUresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rkrq)rrrrrPszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rkrj)rrrrat_eofszStreamReader.at_eofc Csv|sdS|jj||j|jdk rr|j rrt|jd|jkrry|jjWntk rjd|_YnXd|_dS)NrT) rjextendrqrUr8rrhZ pause_readingNotImplementedError)rrRrrrrQs   zStreamReader.feed_datac csV|jdk rtd||jr,d|_|jj|jj|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzH%s() called while another coroutine is already waiting for incoming dataF)rl RuntimeErrorr8rUrrr7rF)rZ func_namerrr_wait_for_datas   zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rB}z|jSd}~Xnftk r}zJ|jj||jrv|jd|j|=n |jj|j t |j dWYdd}~XnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilrrrrj startswithr$clearrsrgr&)rsepseplenlineerrrreadlines  zStreamReader.readlineryccst|}|dkrtd|jdk r(|jd}xt|j}|||kr||jj||}|dkr\P|d|}||jkr|td||jrt|j}|jj t |d|j dEdHq.W||jkrtd||jd||}|jd||=|j t|S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrzz2Separator is found, but chunk is longer than limit) rrgrmrjfindrhrrkbytesr|rrxrs)rZ separatorr~offsetZbuflenZisepchunkrrrrzs:         zStreamReader.readuntilr ccs|jdk r|j|dkrdS|dkrZg}x&|j|jEdH}|sBP|j|q*Wdj|S|j rz|j rz|jdEdHt|jd|}|jd|=|j |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrread) rmrrhrYrZrjrkrxrrs)rnZblocksblockrRrrrrPs$   zStreamReader.readccs|dkrtd|jdk r |j|dkr,dSxFt|j|krr|jr`t|j}|jjt|||jdEdHq.Wt|j|krt|j}|jjnt|jd|}|jd|=|j |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rgrmrrjrkrr|rrxrs)rrZ incompleterRrrrrs&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs|jEdH}|dkrt|S)Nr)rStopAsyncIteration)rvalrrr __anext__szStreamReader.__anext__cCs|S)Nr)rrrrrs)ryr)r)rr r!rorr\rdrBrqrLrsrPrtrQrrxrrzrrr ZPY35rrZPY352rrrrrVs,    [ 2 *  i)NN)NN)N)N)r"__all__Zsockethasattrrur r rrrlogrroEOFErrorr Exceptionrrrr r ZProtocolr6rrrrrrrsB       "  B3GPK!Tj*__pycache__/protocols.cpython-36.opt-2.pycnu[3 2a@sNddddgZGdddZGdddeZGdddeZGdddeZdS) BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s,eZdZddZddZddZddZd S) rcCsdS)N)selfZ transportrr./opt/alt/python36/lib64/python3.6/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname__rr r r rrrrrs c@seZdZddZddZdS)rcCsdS)Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrr>sc@seZdZddZddZdS)rcCsdS)Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrgsc@s$eZdZddZddZddZdS)rcCsdS)Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrtsN)__all__rrrrrrrrs 7) PK!~^g<g< __pycache__/locks.cpython-36.pycnu[3  f<@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s(eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr2/opt/alt/python36/lib64/python3.6/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s r c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s  rcsReZdZdZddddZfddZdd Zed d Zd d Z ddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... N)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r?r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)z*Wake up the first waiter if it isn't done.NT)nextiterr( StopIterationdone set_result)rr@rrrr?s zLock._wake_up_first) rrrrrr0r,r rrr? __classcell__rr)r5rrYs4  csReZdZdZddddZfddZdd Zd d Zd d Ze ddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. N)r%cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rGr(rDrE)rr@rrrrHs  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rG)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rGr*r;r(r<r=)rr@rrrwait s   z Event.wait) rrrrrr0rIrHrJr rKrFrr)r5rrs  csZeZdZdZdddddZfddZedd Zed d Zdd dZ ddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. N)r%cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNTF) r,rrr*r;r(r<r=rr r>)rr@r6rrrrKEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rK)rZ predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)rnidxr@rrrnotifyys  zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rQr2r()rrrr notify_allszCondition.notify_all)N)r) rrrrrr0r rKrNrQrRrFrr)r5rr!s  &  csTeZdZdZdddddZfddZd d Zd d Zed dZ ddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rN)r%cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r r+)rvaluer%rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r(popleftrDrE)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrrs    zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rGrU)rrrrrszSemaphore.release)r) rrrrrr0rUr,r rrrFrr)r5rrs   cs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rN)r%cs||_tj||ddS)N)r%) _bound_valuer/r)rrSr%)r5rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrrs zBoundedSemaphore.release)r)rrrrrrrFrr)r5rrs)r__all__r&rr r Z coroutinesr r rrrrrrrrrrs    .ByMPK!['__pycache__/compat.cpython-36.opt-1.pycnu[3  f@s6dZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCstsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar 3/opt/alt/python36/lib64/python3.6/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s    PK!~D.(__pycache__/windows_utils.cpython-36.pycnu[3  f@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdfd dZd de dddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces NZwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd \}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r:/opt/alt/python36/lib64/python3.6/asyncio/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)prefixrrNT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@s\eZdZdZddZddZeddZdd Ze j d d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r" __class____name__)r#r$rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r"r )r#rrrfilenos zPipeHandle.fileno)r cCs|jdk r||jd|_dS)N)r")r#r rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r"warningswarnResourceWarningr)r#rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r#rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r#tvtbrrr__exit__szPipeHandle.__exit__N)r( __module__ __qualname____doc__r%r)propertyr$r*rr rr/r0r4rrrrrs cs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|jd st|jdddks$td}}}d} } } |tkrdtd dd\} } tj| tj}n|}|tkrtd d\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy t j |f|||d|Wn8x(| | | fD]}|dk rt j |qWYn>X| dk r6t | |_| dk rJt | |_| dk r^t | |_Wd|tkrvtj||tkrtj||tkrtj|XdS) NZuniversal_newlinesrrFT)rr)r)stdinstdoutstderr)FT)TF)TF)getAssertionErrorrrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr%rr rr9r:r;r)r#argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r'rrr%sL             zPopen.__init__)NNN)r(r5r6r7r% __classcell__rr)r'rrs)TT)r7sysplatform ImportErrorr itertoolsr>rr subprocessrr,__all__ZBUFSIZErr@countrhasattrrr r rrrrrrrs,  .0-PK!^  *__pycache__/constants.cpython-36.opt-1.pycnu[3  fs@sdZdZdZdZdS)z Constants. N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr6/opt/alt/python36/lib64/python3.6/asyncio/constants.pysPK!Dԙԙ,__pycache__/base_events.cpython-36.opt-1.pycnu[3  f@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ e!e dZ"d)Z#e$Z%ddZ&ddZ'ddZ(ddZ)ddZ*ddZ+de j,dddddZ-e!e d rXd!d"Z.nd#d"Z.d$d%Z/Gd&d'd'ej0Z1Gd(d d ej2Z3dS)*aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr8/opt/alt/python36/lib64/python3.6/asyncio/base_events.py_format_handleCs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeLs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportUs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket`s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_socketls r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infotsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*|jdS)Nrr)rVrU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr^)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr^s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrcrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r]r_r`r^rrdrrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMe.d d d dXdYdZZ/ed[d\Z0ede1j2e1j3d d]d d d d^d_d`Z4ed dadbdcZ5edddeZ6edfdgZ7dhdiZ8ee9j:e9j:e9j:ddjdMdkdldmZ;ee9j:e9j:e9j:dddMdkdndoZdtduZ?dvdwZ@dxdyZAdzd{ZBd|d}ZCd~dZDddZEddZFddZGd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\$s zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD)szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)zDSchedule a coroutine object. Return a task object. N)rHr) _check_closedr~rr_source_traceback)rXcoroZtaskrrr create_task-s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler5r~)rXfactoryrrrset_task_factory;s zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrqrrvrhset_asyncgen_hooksrrZ_set_running_loop _run_oncerk)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. )rHFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrraZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rk)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTF)wait) rrrjrr debugrnrrorpZshutdown)rXexecutorrrrr`s   zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rj)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrr`)rXrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rq)rXrrrrszBaseEventLoop.is_runningcCstjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)a8Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrrr)rXZdelaycallbackrtimerrrr call_later$szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|jr@|jd=tj|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. rrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushro)rXwhenrrrrrrr9s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonrr)rrrr _call_soonr)rXrrrrrrrIs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrr\s   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rZHandlerrnr9)rXrrrrrrrgs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rqrrr)rXZ thread_idrrrrns  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)z"Like call_soon(), but thread-safe.rrr)rrrrrr)rXrrrrrrrs  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrp concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rp)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrrr rFr|rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d | dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfdd|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr "sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr'sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerr`rr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrrxrrr`) rXr%rrrrrrcrrrrrrAs  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#s"| dk rt| js tdj| s<s<|s<|s<|s<|s<| rzt|||||| d} djdd| jD} tdj| | jdd} nps|d krtd ||fdff}ntj }xd fd ffD]~\}}|dk rt ||t j |||d EdH}|st d xB|D]:\}}}}}||f}||kr:ddg||<||||<qWqWfdd|jD}|svtdg}|tk r|rtdntjdtddx|D]\\}}\}}d} d} yrt j |t j |d} |rt| | r| jt jt jd | jdr| j|r2|j| |EdH|} Wn^t k rt}z"| dk rZ| j|j|WYdd}~Xn"| dk r| jYnXPqW|d |}|j}|j| || |}|jrrtjd||ntjd||y|EdHWn|jYnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrmsz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.6.10 and is scheduled for removal in 3.11.rC) stacklevel)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r-r>r!rdictritemsrrl OrderedDictrKr r,r$_unsetrrDeprecationWarningr&r"r#Z SO_BROADCASTrrr`r9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrcrr)rrrcreate_datagram_endpointYs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | d iEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttdr|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rrxr5r!rynamervplatformrrlIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#Z SO_REUSEADDRr&r8r rrZ IPV6_V6ONLYrr$rrrr`r+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%r rrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r0T)rNr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketLs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrr`rr rfileno)rXrrrrcrrrrconnect_read_pipecszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrr`rr rr)rXrrrrcrrrrconnect_write_pipetsz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocessszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rr!rr rI) rXrcmdrrrr"rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rr!rr rI)rXrZprogramrrrr"rrrrZ popen_argsargrr$rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rt)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})rr5rrt)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|dkr~qp||}|dkrdjtj|}d }||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)aEDefault exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r{r> __traceback__r}rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)aCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)rrr0zeException in default exception handler while handling an unexpected error in custom exception handler)rtr3rOr r)rXr0rRrrrrs" z$BaseEventLoop.call_exception_handlercCs|jr dS|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrnr9)rXrrrr _add_callbackDszBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r5r)rXrrrr_add_callback_signalsafeLs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rori)rXrrrr_timer_handle_cancelledQsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d |d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rro_MIN_SCHEDULED_TIMER_HANDLESri%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr4r9rheapifyheappoprnrkZ_whenminmaxrrMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrsrangepopleftr}Z_runr|rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrVs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krobjectrrrr&r+r-rAr)rKrMrSZAbstractServerrTZAbstractEventLoopr rrrrsX            ;   /PK![!__pycache__/compat.cpython-36.pycnu[3  f@s6dZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCstsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar 3/opt/alt/python36/lib64/python3.6/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s    PK!a0&__pycache__/base_events.cpython-36.pycnu[3  f@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ e!e dZ"d)Z#e$Z%ddZ&ddZ'ddZ(ddZ)ddZ*ddZ+de j,dddddZ-e!e d rXd!d"Z.nd#d"Z.d$d%Z/Gd&d'd'ej0Z1Gd(d d ej2Z3dS)*aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr8/opt/alt/python36/lib64/python3.6/asyncio/base_events.py_format_handleCs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeLs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportUs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket`s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_socketls r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infotsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs |jdk st|jd7_dS)Nr)rUAssertionErrorrV)rXrrr_attachszServer._attachcCs<|jdkst|jd8_|jdkr8|jdkr8|jdS)Nrr)rVr]rU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr_)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr_s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrdrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r^r`rar_rrerrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMe.d d d dXdYdZZ/ed[d\Z0ede1j2e1j3d d]d d d d^d_d`Z4ed dadbdcZ5edddeZ6edfdgZ7dhdiZ8ee9j:e9j:e9j:ddjdMdkdldmZ;ee9j:e9j:e9j:dddMdkdndoZdtduZ?dvdwZ@dxdyZAdzd{ZBd|d}ZCd~dZDddZEddZFddZGd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\$s zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD)szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)zDSchedule a coroutine object. Return a task object. N)rHr) _check_closedrrr_source_traceback)rXcoroZtaskrrr create_task-s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler5r)rXfactoryrrrset_task_factory;s zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrrrrwriset_asyncgen_hooksrrZ_set_running_loop _run_oncerl)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. )rHFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrrbZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rl)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTF)wait) rrrkrr debugrorrprqZshutdown)rXexecutorrrrras   zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rk)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrra)rXrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rr)rXrrrrszBaseEventLoop.is_runningcCstjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rsrh)rXrrrrsszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)a8Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrsr)rXZdelaycallbackrtimerrrr call_later$szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|jr@|jd=tj|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. rrTr) rr _check_thread_check_callbackr TimerHandlerheapqheappushrp)rXwhenrrrrrrr9s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonrr)rrrr _call_soonr)rXrrrrrrrIs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrr\s   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rHandlerror9)rXrrrrrrrgs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rrrrr)rXZ thread_idrrrrns  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)z"Like call_soon(), but thread-safe.rrr)rrrrrr)rXrrrrrrrs  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrq concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rq)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrsr rFr}rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d | dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfdd|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr "sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr'sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerrarr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrryrrra) rXr%rrrrrrdrrrrrrAs  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#sB| dk rt| js tdj| s<s<|s<|s<|s<|s<| rzt|||||| d} djdd| jD} tdj| | jdd} n8ps|d krtd ||fdff}ntj }xd fd ffD]\}}|dk rt |t ot |d kst d t||tj|||dEdH}|s(tdxB|D]:\}}}}}||f}||krZddg||<||||<q.WqWfdd|jD}|stdg}|tk r|rtdntjdtd dx|D]\\}}\}}d} d} yrtj|tj|d} |rt| | r| jtjtjd | jdr6| j|rR|j| |EdH|} Wn^tk r}z"| dk rz| j|j|WYdd}~Xn"| dk r| jYnXPqW|d |}|j}|j| || |}|j rrt!j"d||nt!j#d||y|EdHWn|jYnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrmsz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrrCz2-tuple is expected)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.6.10 and is scheduled for removal in 3.11.) stacklevel)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)$r-r>r!rdictritemsrrm OrderedDictrtuplerr]rKr r,r$_unsetrrDeprecationWarningr&r"r#Z SO_BROADCASTrrrar9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrdrr)rrrcreate_datagram_endpointYs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | d iEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttdr|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rryr5r!rznamerwplatformrrmIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#Z SO_REUSEADDRr&r8r rrZ IPV6_V6ONLYrr$rrrrar+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%rrrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r0T)rNr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketLs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrrarr rfileno)rXrrrrdrrrrconnect_read_pipecszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrrarr rr!)rXrrrrdrrrrconnect_write_pipetsz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocessszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rr%rr rI) rXrcmdrrrr&rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rr%rr rI)rXrZprogramrrrr&rrrrZ popen_argsargrr(rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )ru)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})rr5rru)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|dkr~qp||}|dkrdjtj|}d }||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)aEDefault exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r|r> __traceback__r~rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)aCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)rrr4zeException in default exception handler while handling an unexpected error in custom exception handler)rur7rOr r)rXr4rRrrrrs" z$BaseEventLoop.call_exception_handlercCs@t|tjstd|jrdSt|tj s0t|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr] _cancelledrror9)rXrrrr _add_callbackDs zBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r9r)rXrrrr_add_callback_signalsafeLs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rprj)rXrrrr_timer_handle_cancelledQsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d |d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rrp_MIN_SCHEDULED_TIMER_HANDLESrj%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr8r9rheapifyheappoprorlZ_whenminmaxrsMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrtrangepopleftr~Z_runr}rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrVs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krsX            ;   /PK!|-__pycache__/base_futures.cpython-36.opt-2.pycnu[3 2a@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@s eZdZdS)InvalidStateErrorN)__name__ __module__ __qualname__rr1/opt/alt/python36/lib64/python3.6/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)N_asyncio_future_blocking)hasattr __class__r )objrrr isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) NcSs tj|fS)N)rZ_format_callback_source)callbackrrr format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerrrr _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframerrr _future_repr_info6s     r!)__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr!rrrr s   PK!F { {,__pycache__/base_events.cpython-36.opt-2.pycnu[3 2a@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZd gZd Zd ZeeefZe ed Z!d(Z"e#Z$ddZ%ddZ&ddZ'ddZ(ddZ)ddZ*dej+dddddZ,e edrTd d!Z-nd"d!Z-d#d$Z.Gd%d&d&ej/Z0Gd'd d ej1Z2dS))N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr0/opt/alt/python36/lib64/python3.6/base_events.py_format_handleCs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeLs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportUs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket`s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_socketls r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infotsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*|jdS)Nrr)rVrU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr^)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr^s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrcrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r]r_r`r^rrdrrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMe.d d d dXdYdZZ/ed[d\Z0ede1j2e1j3d d]d d d d^d_d`Z4ed dadbdcZ5edddeZ6edfdgZ7dhdiZ8ee9j:e9j:e9j:ddjdMdkdldmZ;ee9j:e9j:e9j:dddMdkdndoZdtduZ?dvdwZ@dxdyZAdzd{ZBd|d}ZCd~dZDddZEddZFddZGd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\$s zBaseEventLoop.__repr__cCs tj|dS)N)rH)rZFuture)rXrrrrD)szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)N)rHr) _check_closedr~rr_source_traceback)rXcoroZtaskrrr create_task-s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)Nz'task factory must be a callable or None)callabler5r~)rXfactoryrrrset_task_factory;s zBaseEventLoop.set_task_factorycCs|jS)N)r~)rXrrrget_task_factoryIszBaseEventLoop.get_task_factoryN)extraservercCstdS)N)NotImplementedError)rXr%protocolrcrrrrr_make_socket_transportMsz$BaseEventLoop._make_socket_transportF) server_sideserver_hostnamerrc CstdS)N)r) rXZrawsockr sslcontextrcrrrrrrr_make_ssl_transportRsz!BaseEventLoop._make_ssl_transportcCstdS)N)r)rXr%rrGrcrrrr_make_datagram_transportXsz&BaseEventLoop._make_datagram_transportcCstdS)N)r)rXpiperrcrrrr_make_read_pipe_transport]sz'BaseEventLoop._make_read_pipe_transportcCstdS)N)r)rXrrrcrrrr_make_write_pipe_transportbsz(BaseEventLoop._make_write_pipe_transportc KstdS)N)r) rXrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportgsz(BaseEventLoop._make_subprocess_transportcCstdS)N)r)rXrrr_write_to_selfnszBaseEventLoop._write_to_selfcCstdS)N)r)rX event_listrrr_process_eventswszBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rj RuntimeError)rXrrrr{szBaseEventLoop._check_closedcCs*|jj||js&|j|j|jdS)N)rdiscardrcall_soon_threadsaferaclose)rXagenrrr_asyncgen_finalizer_hooks z&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|t|d|jj|dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)source)rwarningswarnformatResourceWarningradd)rXrrrr_asyncgen_firstiter_hooks  z&BaseEventLoop._asyncgen_firstiter_hookccsd|_|jdkst|j r dSt|j}|jjtjdd|Dd|d}|EdH}x8t||D]*\}}t|t rf|j dj |||dqfWdS)NTcSsg|] }|jqSr)r).0Zagrrr sz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_cororesultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrqrrvrhset_asyncgen_hooksrrZ_set_running_loop _run_oncerk)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)N)rHFz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrraZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)NT)rk)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)Nz!Cannot close a running event loopzClose %rTF)wait) rrrjrr debugrnrrorpZshutdown)rXexecutorrrrr`s   zBaseEventLoop.closecCs|jS)N)rj)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrr`)rXrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)N)rq)rXrrrrszBaseEventLoop.is_runningcCstjS)N)rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)Nrr)call_atrrr)rXZdelaycallbackrtimerrrr call_later$szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|jr@|jd=tj|j |d|_ |S)NrrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushro)rXwhenrrrrrrr9s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|S)N call_soonrr)rrrr _call_soonr)rXrrrrrrrIs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrr\s   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rZHandlerrnr9)rXrrrrrrrgs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rqrrr)rXZ thread_idrrrrns  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)Nrrr)rrrrrr)rXrrrrrrrs  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrp concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rp)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrrr rFr|rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d| dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfd d|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr "sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr'sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerr`rr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrrxrrr`) rXr%rrrrrrcrrrrrrAs  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#s"| dk rt| js tdj| s<s<|s<|s<|s<|s<| rzt|||||| d} djdd| jD} tdj| | jdd} nps|dkrtd ||fdff}ntj }xdfd ffD]~\}}|dk rt ||t j |||d EdH}|st d xB|D]:\}}}}}||f}||kr:ddg||<||||<qWqWfd d|jD}|svtdg}|tk r|rtdntjdtddx|D]\\}}\}}d} d} yrt j |t j |d} |rt| | r| jt jt jd | jdr| j|r2|j| |EdH|} Wn^t k rt}z"| dk rZ| j|j|WYdd}~Xn"| dk r| jYnXPqW|d|}|j}|j| || |}|jrrtjd||ntjd||y|EdHWn|jYnX||fS)Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrmsz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.6.10 and is scheduled for removal in 3.11.rC) stacklevel)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r-r>r!rdictritemsrrl OrderedDictrKr r,r$_unsetrrDeprecationWarningr&r"r#Z SO_BROADCASTrrr`r9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrcrr)rrrcreate_datagram_endpointYs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | diEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttd r|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rrxr5r!rynamervplatformrrlIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#Z SO_REUSEADDRr&r8r rrZ IPV6_V6ONLYrr$rrrr`r+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%r rrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)Nz&A Stream Socket was expected, got {!r}r0T)rr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketLs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrr`rr rfileno)rXrrrrcrrrrconnect_read_pipecszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrr`rr rr)rXrrrrcrrrrconnect_write_pipetsz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocessszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rr"rr rI) rXrcmdrrrr#rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rr"rr rI)rXrZprogramrrrr#rrrrZ popen_argsargrr%rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)N)rt)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)Nz/A callable object or None is expected, got {!r})rr5rrt)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|d kr~qp||}|dkrdjtj|}d}||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)Nrz!Unhandled exception in event looprFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r{r> __traceback__r}rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)rrr1zeException in default exception handler while handling an unexpected error in custom exception handler)rtr4rOr r)rXr1rRrrrrs" z$BaseEventLoop.call_exception_handlercCs|jr dS|jj|dS)N) _cancelledrnr9)rXrrrr _add_callbackDszBaseEventLoop._add_callbackcCs|j||jdS)N)r6r)rXrrrr_add_callback_signalsafeLs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rori)rXrrrr_timer_handle_cancelledQsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d|d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) NFrrg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rro_MIN_SCHEDULED_TIMER_HANDLESri%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr5r9rheapifyheappoprnrkZ_whenminmaxrrMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrsrangepopleftr}Z_runr|rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrVs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krsV            ;   /PK!UW4=$=$*__pycache__/base_subprocess.cpython-36.pycnu[3  f#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|j| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__ ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #s^yj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<jdk st |j j j x"jD]\}}|j |f|qWd_WnDt k r8}z&|dk r(|j r(|j|WYdd}~Xn"X|dk rZ|j rZ|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piperrAssertionError call_soonrconnection_made Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s8          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrS)r)cbr[r/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r^rZpipe_connection_lost _try_finish)r)rIr\r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r^rZpipe_data_received)r)rIr[r/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|dk st||jdks$t|j|jjrsz6BaseSubprocessTransport._try_finish..T)rrRrallrr>r^_call_connection_lost)r)r/r/r0r_s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r\r/r/r0rjs z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r^r`rarcrdr_rj __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rXrIr6re)r)rXrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rTsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rerXr`rI)r)r\r/r/r0rksz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rXr pause_writing)r)r/r/r0rosz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rXrresume_writing)r)r/r/r0rpsz'WriteSubprocessPipeProto.resume_writingN) r3rlrmrrTr9rkrorpr/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rXrarI)r)r[r/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rlrmrqr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { PK!(pMM"__pycache__/streams.cpython-36.pycnu[3  f_@sLdZdddddddgZdd lZeed r6ejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d"Z GdddeZGdddeZe d#d e dddZe d$d e dddZeed re d%d e ddd Ze d&d e ddd ZGddde jZGdddee jZGd ddZGd!ddZd S)'zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__4/opt/alt/python36/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname____doc__rr __classcell__rr)rrrs cs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager$)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N)r(r')r'csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr'r(kwdsreader transport_writerr)r)rr8s   c+s8dkrtjfdd}j|||f|EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncstd}t|d}|S)N)r(r')r')rr)r/r))client_connected_cbr(r'rrfactoryqs zstart_server..factory)rr+Z create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'csS)Nrr)r)rrr*sz&open_unix_connection..)rr+rrZcreate_unix_connectionr)pathr'r(r.r/r0r1r2r)r)rr }s  c+s6dkrtjfdd}j||f|EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncstd}t|d}|S)N)r(r')r')rr)r/r))r3r(r'rrr4s z"start_unix_server..factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr sc@s>eZdZdZd ddZddZddZd d Zed d Z dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr+_loop_paused _drain_waiter_connection_lost)rr'rrrrs  zFlowControlMixin.__init__cCs,|j s td|_|jjr(tjd|dS)NTz%r pauses writing)r8AssertionErrorr7 get_debugrdebug)rrrr pause_writings  zFlowControlMixin.pause_writingcCsP|js td|_|jjr&tjd||j}|dk rLd|_|jsL|jddS)NFz%r resumes writing) r8r;r7r<rr=r9done set_result)rwaiterrrrresume_writings   zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r:r8r9r?r@ set_exception)rexcrArrrconnection_losts z FlowControlMixin.connection_lostccsP|jrtd|jsdS|j}|dks2|js2t|jj}||_|EdHdS)NzConnection lost)r:ConnectionResetErrorr8r9 cancelledr;r7 create_future)rrArrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!r"rr>rBrErrIrrrrr6s   r6csFeZdZdZd fdd ZddZfddZd d Zd d ZZ S)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs*tj|d||_d|_||_d|_dS)N)r'F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr3r')rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rJ set_transportget_extra_inforMrLrr7rKr Z iscoroutineZ create_task)rr0resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rJfeed_eofrCrrErK)rrD)rrrrEs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rJ feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rJrRrM)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!r"rrQrErUrVr#rr)rrrs  c@sjeZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs2||_||_|dks"t|ts"t||_||_dS)N) _transport _protocol isinstancerr;_readerr7)rr0r)r/r'rrrrs zStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrWrZappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rW)rrrrr0'szStreamWriter.transportcCs|jj|dS)N)rWwrite)rrTrrrr`+szStreamWriter.writecCs|jj|dS)N)rW writelines)rrTrrrra.szStreamWriter.writelinescCs |jjS)N)rW write_eof)rrrrrb1szStreamWriter.write_eofcCs |jjS)N)rW can_write_eof)rrrrrc4szStreamWriter.can_write_eofcCs |jjS)N)rWclose)rrrrrd7szStreamWriter.closeNcCs|jj||S)N)rWrO)rnamedefaultrrrrO:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rZ exceptionrWZ is_closingrXrI)rrDrrrdrain=s    zStreamWriter.drain)N)rr r!r"rr_propertyr0r`rarbrcrdrOrrhrrrrrs  c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr+r7 bytearray_buffer_eof_waiter _exceptionrWr8)rr(r'rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>r[) rmr\rrnrk_DEFAULT_LIMITrorprWr8r])rr^rrrr_ks    zStreamReader.__repr__cCs|jS)N)rp)rrrrrg}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rprorGrC)rrDrArrrrCs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rorGr@)rrArrr_wakeup_waiters zStreamReader._wakeup_waitercCs|jdkstd||_dS)NzTransport already set)rWr;)rr0rrrrNszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r8rrmrkrWresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rnrs)rrrrrRszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rnrm)rrrrat_eofszStreamReader.at_eofc Cs|j std|sdS|jj||j|jdk r|j rt|jd|jkry|jj Wnt k rzd|_YnXd|_dS)Nzfeed_data after feed_eofrT) rnr;rmextendrsrWr8rrkZ pause_readingNotImplementedError)rrTrrrrSs   zStreamReader.feed_datac csf|jdk rtd||j s&td|jrsB       "  B3GPK!c""&__pycache__/locks.cpython-36.opt-2.pycnu[3 2a<@sdddddgZddlZddlmZdd lmZdd lmZdd lmZGd d d ZGdddZ Gddde Z GdddZ Gddde Z Gddde Z Gddde ZdS)LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s$eZdZddZddZddZdS)_ContextManagercCs ||_dS)N)_lock)selflockr*/opt/alt/python36/lib64/python3.6/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname__rrrrrrrr sr c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rrr#rrrrr+s  rcsNeZdZddddZfddZddZed d Zd d Zd dZ Z S)rN)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr$rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r(r'formatlen)rresextra) __class__rrr/s  z Lock.__repr__cCs|jS)N)r()rrrrr+sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)Ncss|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..T) r(allr'r) create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)NFzLock is not acquired.)r(r>r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)NT)nextiterr' StopIterationdone set_result)rr?rrrr>s zLock._wake_up_first) rrrrr/r+r rrr> __classcell__rr)r4rrYs 6  csNeZdZddddZfddZddZd d Zd d Zed dZ Z S)rN)r$cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r%r&r'_valuer)r r*)rr$rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr-)r.r/rFr'r0r1)rr2r3)r4rrr/s  zEvent.__repr__cCs|jS)N)rF)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)NT)rFr'rCrD)rr?rrrrGs  z Event.setcCs d|_dS)NF)rF)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)NT)rFr)r:r'r;r<)rr?rrrwait s   z Event.wait) rrrrr/rHrGrIr rJrErr)r4rrs    csVeZdZdddddZfddZeddZed d Zdd d ZddZ Z S)rN)r$cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r$z"loop argument must agree with lock) r)r r*r ValueErrorr r+rrr%r&r')rrr$rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr+r,z {},waiters:{}z <{} [{}]>rr-)r.r/r+r'r0r1)rr2r3)r4rrr/>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)Nzcannot wait on un-acquired lockTF) r+rrr)r:r'r;r<rr r=)rr?r5rrrrJEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)N)rJ)r predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)Nz!cannot notify on un-acquired lockrrF)r+rr'rCrD)rnidxr?rrrnotifyys  zCondition.notifycCs|jt|jdS)N)rQr1r')rrrr notify_allszCondition.notify_all)N)r) rrrrr/r rJrNrQrRrErr)r4rr!s    &  csPeZdZdddddZfddZdd Zd d Zed d ZddZ Z S)rrN)r$cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rKrFr%r&r'r)r r*)rvaluer$rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr+zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr-)r.r/r+r0rFr'r1)rr2r3)r4rrr/s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r'popleftrCrD)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)Nr)rF)rrrrr+szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)NrrT)rFr)r:r'r;Zcancelr5rU)rr?rrrrs    zSemaphore.acquirecCs|jd7_|jdS)Nr)rFrU)rrrrrszSemaphore.release)r) rrrrr/rUr+r rrrErr)r4rrs   cs0eZdZdddfdd ZfddZZS) rrN)r$cs||_tj||ddS)N)r$) _bound_valuer.r)rrSr$)r4rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rFrVrKr.r)r)r4rrrs zBoundedSemaphore.release)r)rrrrrrErr)r4rrs)__all__r%rr r Z coroutinesr r rrrrrrrrrrs    .ByMPK! VC !__pycache__/queues.cpython-36.pycnu[3  f@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr3/opt/alt/python36/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrsc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS)*ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts  z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7remove ValueErrorr8r( get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr>s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rr=rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r@r>rArCrrrrrs&      c@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrEr%rFr"rrrrrsc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs JoinableQueue)r__all__rrGrr r Z coroutinesr ExceptionrrrrrZPY35rIr#rrrrs     H PK!;+jwjw&__pycache__/unix_events.cpython-36.pycnu[3  f @s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkredddZy ejZWnek r,ddZYnXGdddejZ e!edrVddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%rej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python36/lib64/python3.6/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZdZd"fdd ZddZfddZd d Zd d Zd dZ ddZ ddZ d#ddZ d$ddZ ed%ddZddZeddddddZed&ddddd d!ZZS)'_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)rrrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)rsig)r!rrr%>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)rdatarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)rr.callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4rKeyErrorr5SIGINTdefault_int_handlerSIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr3r@r5NSIGr8)rr.rrrr4s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)rpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)rrOrPrQrRrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rQrR) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)rrPrBshellstdinstdoutstderrbufsizerRkwargswatcherrQtransprCerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)rpid returncoderbrrrrYsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|dkst|tst|r,|dkr|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrv)rKboolr3r8_fspathr"rkrlstatS_ISSOCKosst_moderemoveFileNotFoundErrorr9rerrorZbindr%r>Z EADDRINUSEr@rnrrorpZServerZlistenrmZ_start_serving) rrqrrhrurgrcrCmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname____doc__rr#r%r1rEr/r)r4rSrUr rdrYrsr __classcell__rr)r!rr1s, -      %r set_blockingcCstj|ddS)NF)r{r)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLr{ O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rNiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrOFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper7_fileno _protocol_closingr{fstatr|ryS_ISFIFOrzS_ISCHRr8r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rlooprOrPrQrRmode)r!rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r!rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)rr=r rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)r{readrmax_sizeBlockingIOErrorInterruptedErrorr9 _fatal_errorrZ data_receivedr get_debugrr=r_remove_readerrZ eof_received_call_connection_lost)rr0rCrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)rrrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)rrrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)rrPrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)rrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)rrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)rrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrrrP) rKr9r>ZEIOrrrdebugcall_exception_handlerrr)rrCrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)rrCrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)rrCrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr%rPY34rrrrrrr)r!rrNMs rNcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rTNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrOrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr7rr bytearray_buffer _conn_lostrr{rr|ryrrrzr8rrrrr&platform startswithrrr r) rrrOrPrQrRrZis_charZis_fifoZ is_socket)r!rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r!rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)rr=r rr_rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)rrrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr=rrBrokenPipeError)rrrrrs   z#_UnixWritePipeTransport._read_readycCs0t|tttfstt|t|tr.t|}|s6dS|jsB|jrj|jtj krXt j d|jd7_dS|j syt j|j|}WnTttfk rd}Yn:tk r}z|jd7_|j|ddSd}~XnX|t|krdS|dkrt||d}|jj|j|j|j |7_ |jdS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rKbytesr memoryviewrjreprrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrr{writerrrrZrrrZ _add_writer _write_readyZ_maybe_pause_protocol)rr0nrCrrrrs4       z_UnixWritePipeTransport.writecCs|jstdytj|j|j}Wnjttfk r:Yntk r}z8|jj|j d7_ |j j |j|j |dWYdd}~XnfX|t |jkr|jj|j j |j|j|jr|j j|j|jddS|dkr|jd|=dS)NzData should not be emptyrz#Fatal write error on pipe transportr)rrjr{rrrrrZr-rr_remove_writerrrZ_maybe_resume_protocolrrr)rrrCrrrr>s(   z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCsB|jr dS|jstd|_|js>|jj|j|jj|jddS)NT) rrrjrrrrrr)rrrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)rrPrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)rrrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)rrrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)rrrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrrrP) rKrZ_FATAL_ERROR_IGNORErrrrrrr)rrCrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr-rrr)rrCrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)rrCrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr%rrrrrrrrrr)r!rrTs$% !   rTset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rWc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r[r\r]r^Zuniversal_newlinesr_wb) buffering) subprocessPIPErr#rr7Popen_procr%rdetachr\) rrBr[r\r]r^r_r`Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrWsrWc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)rrerArBrrrrXs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)rrerrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)rrrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)rrrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)rrrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)rabcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrrXrrr%rrrrrrrs  c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)rrrrrszBaseChildWatcher.__init__cCs|jddS)N)r)rrrrr%szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)rrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs~|dkst|tjst|jdk r<|dkr<|jr %dr2)r{rrrrrrrrGrrrrrrr)rrerrfrArBrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrrr%rrrXrrrrr)r!rrs   csHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r)r!rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrKrcurrent_thread _MainThreadr_localr)rrrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrKrrrr)rr)r!rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)rrrrrV&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|tst|jdk r*|jj||_dS)z$Set the watcher for child processes.N)rKrrjrr%)rrarrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrrrVrrrr)r!rrs   r)5rr>r{r5r"ryrr&rr*rrrrrrr r r r r logr__all__r ImportErrorrfspathrxAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrNZ_FlowControlMixinZWriteTransportrTrrZBaseSubprocessTransportrWrrrrZBaseDefaultEventLoopPolicyrrrrrrrsn                O  F=On2PK!]TT%__pycache__/base_tasks.cpython-36.pycnu[3  f@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror 7/opt/alt/python36/lib64/python3.6/asyncio/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   PK!{(+/+/%__pycache__/transports.cpython-36.pycnu[3  fR'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkr i}||_dS)N)_extra)selfextrar 7/opt/alt/python36/lib64/python3.6/asyncio/transports.py__init__ szBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCstdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s eZdZdZddZddZdS)rz#Interface for read-only transports.cCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-sc@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineses zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort)NN) rrrrr!r"r$r%r&r'r(r r r r rAs   c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rsc@s"eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)N)rrrrr)r(r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs csVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. Ncs0tj||dk st||_d|_|jdS)NF)superrAssertionError_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs   z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r" _high_waterr6 _protocolZ pause_writing Exceptionr5call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r9r:r;r)r6r" _low_waterr=Zresume_writingr>r5r?)r rAr r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rCr<)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr<rC)r rr r r r r7s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr )r7rB)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrBrDrEr7r!r" __classcell__r r )r8r r2s  r2N) rZasyncior__all__rrrrrrr2r r r r s  #D4PK!X޷%__pycache__/subprocess.cpython-36.pycnu[3  f@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__7/opt/alt/python36/lib64/python3.6/asyncio/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr=szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr?szProcess.terminatecCs|jjdS)N)rkill)rrrrr@sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrCr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|dks(t|j}|jjrV|dkrDdnd}tjd|||j EdH}|jjr|dkrzdnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rAssertionErrorrr&rAr rCreadr-)rr*r(streamnameoutputrrr _read_streams    zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rGrHrrNrrZgatherr&r<)rrFrrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr;r r<r=r?r@rGrHrNrOrrrrr9ks      r9c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr9) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrQsz(create_subprocess_exec..)rrr)rrRZsubprocess_execr9) Zprogramrrrr rargsrTrUr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r9Z_DEFAULT_LIMITrrrrrrs(      X] PK!~ߦw!w!%__pycache__/coroutines.cpython-36.pycnu[3  f+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r 7/opt/alt/python36/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCsZtj|stj|st|||_||_tjtj d|_ t |dd|_ t |dd|_ dS)Nrrr)inspect isgeneratorrAssertionErrorrr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner, __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGsBtj}|j}|jdkst|jj|jtkr6|d}|jj |S)Nr) r*r+f_backf_lastir(f_codeco_code _YIELD_FROMrr)rr!r2Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r9szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r<szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r=szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r>szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r?szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r-r RuntimeErrorformat)rr@r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rDszCoroWrapper.gi_yieldfromcCs|jjS)N)rr@)rr r r r@szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rEszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rFszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rGszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr=rGrz%r was never yielded fromr,zB Coroutine object created at (most recent call last, truncated to z last lines): r.) r-r5joinr; format_listrZDEBUG_STACK_DEPTHrstripr error)rrr2msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr3rr_YIELD_FROM_BUGrr9r<propertyr=r>r?rZPY35rCrDr@rErFrGrOr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r Zisfuturer&r' isinstancer$ _AwaitableABCrCAttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..coroNcs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr.)r$r,r-rr)rUkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionr&isgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rZr )r"r r rs   cCst|ddtkpt|S)z6Return True if func is a decorated coroutine function.raN)r-rar[)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rR_COROUTINE_TYPES)objr r r rsc Cs&t|s tt|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk ry |j }Wntk rYnXYnX|rdj|S|Sd}t |t r|j }|j }|dk rdj|}n|}|dkrtj|fi}d}t|do|jr|j}nt|dr|jr|j}d}t|dr>|jr>|j}nt|d rX|jrX|j}d }|rp|jrp|j}d }|}t |t rtj|j  r|j dk rtj|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r"|j}d |||f}|S)NrFr?rrz{}()Fz {} runningrGr=zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)rr(hasattrr-r:rrBrErTr>rRr$r rrZ_format_callbackrFr?rGr= co_filenamer&r\Z_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor1sourcer r r r/sz               r/).__all__r]r&Zopcodeosr*r;typesrHrrrr logr Zopmapr8flagsignore_environmentboolenvirongetr_rr` CoroutineTypeZ_types_CoroutineTyperTrr[collections.abcrZ _CoroutineABCrrS ImportErrorr#rPr%r$objectra GeneratorTyperbrr/r r r r sZ         j:     PK!4OO#__pycache__/sslproto.cpython-36.pycnu[3  fe @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tjfkrЂ|j tj k|_WYdd}~XnX|jjr |j|jj|t|ks|jrdPqdW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. rNFZPROTOCOL_IS_SHUTDOWN)r/r0rr memoryviewr rr9r r=reasonr@r8rArBrrCr<r:)r#rDoffsetr2ZviewrFrrr feed_appdatas4         z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname____doc__r;r%propertyr$r&r'r)r4r6r7r.rJrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r#loopZ ssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rR_get_extra_info)r#namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rR _app_protocol)r#protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rRrY)r#rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rS)r#rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rSrR_start_shutdown)r#rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rSwarningswarnResourceWarningr_)r#rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rR _transport pause_reading)r#rrrrfQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rRreresume_reading)r#rrrrgYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rRreset_write_buffer_limits)r#ZhighZlowrrrrhasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)z,Return the current size of the write buffer.)rRreget_write_buffer_size)r#rrrrivsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrG TypeErrorformattyperKrR_write_appdata)r#rDrrrr9zs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rR_abort)r#rrrabortsz_SSLProtocolTransport.abort)N)NN)rKrLrMr%rXr[r\r]r_rZPY34rdrfrgrhrir9rqrsrrrrrP&s   rPc@seZdZdZd(ddZd)ddZd d Zd d Zd dZddZ ddZ ddZ d*ddZ ddZ ddZddZddZdd Zd+d"d#Zd$d%Zd&d'ZdS), SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrQrYrP_app_transport_sslpipe_session_established _in_handshake _in_shutdownre_call_connection_made)r#rTZ app_protocolrZwaiterrrZcall_connection_maderrrr%s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)r|Z cancelledZ set_exceptionZ set_result)r#rFrrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rerrurrr~_start_handshake)r# transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)rrQ call_soonrYconnection_lostrer}r)r#rFrrrrs zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rY pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rYresume_writing)r#rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. Nz%r: SSL error %s (reason %s))r~r.r r=rQ get_debugrwarningr8rHrrrer9rY data_receivedr^)r#rDr2r3erErrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rQrrdebugrConnectionResetErrorrrY eof_receivedrrer_)r#Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rwrerX)r#rVrWrrrrU!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr*)rrrrrp)r#rrrr^)s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)rzr<r{r/_process_write_backlog)r#rDrrrrp2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr*r)r*r) rQrrrtime_handshake_start_timerrzr<r)r#rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr&)$rr~r&Z getpeercertr rurr r Z CERT_NONEZmatch_hostname BaseExceptionrQrrjr>rrrer_ ExceptionrrrrrwupdaterrrrYrr}rrr)r#Z handshake_excZsslobjrrFZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCsJ|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj st |jj r|jjP|jd=|jt|8_q*WWnRtk rD}z4|jr|j|n |j|dt|ts4WYdd}~XnXdS)NrrzFatal error on SSL transport)rer~ranger/rzrJr4rr6 _finalizer9r'r0Z_pausedrgr{rr _fatal_errorrjr)r#irDrIr2rErFrrrrws:       z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrZ) rjrZ_FATAL_ERROR_IGNORErQrrrZcall_exception_handlerreZ _force_close)r#rFrrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r~rer_)r#rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rersr)r#rrrrrs zSSLProtocol._abort)FNT)N)N)r)rKrLrMrNr%rrrrrrrrUr^rprrrrrrrrrrrrts& "     4, rt)rxrar ImportErrorrrrrlogrrrrr-r(r5objectrZ_FlowControlMixinZ TransportrPZProtocolrtrrrrs*       wnPK!D'__pycache__/base_futures.cpython-36.pycnu[3  f@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@seZdZdZdS)InvalidStateErrorz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__r r 9/opt/alt/python36/lib64/python3.6/asyncio/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r )objr r r isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) z#helper function for Future.__repr__cSs tj|fS)N)rZ_format_callback_source)callbackr r r format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerr r r _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)z#helper function for Future.__repr__Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframer r r _future_repr_info6s     r")__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr"r r r r s   PK!  A A0__pycache__/proactor_events.cpython-36.opt-1.pycnu[3  fO@sdZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j rXddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__ ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname____doc__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs<eZdZdZd fdd ZddZddZd d d ZZS) _ProactorReadPipeTransportzTransport for read pipes.Ncs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrRrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrRrSrrrTrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z"yH|dk r0d|_|j}|jr>d}dS|dkrJdS|jjj|jd|_Wnt k r}z2|js|j |dn|jj rt j dddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r}z|j |dWYdd}~Xn0tjk r&|js"YnX|jj|jWd|rN|jj|n:|dk r|jj rpt j d||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrresultrr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrTrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rTsH     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r(rMrNrOr rUrVrTrPr#r#)r"r$rQs  rQc@s:eZdZdZddZd ddZddZd d Zd d ZdS)_ProactorBaseWritePipeTransportzTransport for write pipes.cCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr riZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rsvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJro)rr#r#r$rtys   z"_ProactorSocketTransport.write_eof)NNN) r(rMrNrOr rrsrtrPr#r#)r"r$r~\s r~cseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rY _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r~)rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler}Z SSLProtocolr~Z_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r|)rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rQ)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)rv)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningrh is_closed_stop_accept_futures_close_self_piperYr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rYrZ)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rYrp)rrrar#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rYZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rYaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r})rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rXrYrZrrr^ ExceptionrDrr_r)rrrrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rrp)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rXZ_debugr rCrrrrYrr]r*rDr7rr^rr_)rrZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrY _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrPr#r#)r"r$rs4          ()rO__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrQZWriteTransportrbrvZ Transportr|r~Z BaseEventLooprr#r#r#r$s2        M T  #PK!`hh*__pycache__/protocols.cpython-36.opt-1.pycnu[3  f@sRdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s0eZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr6/opt/alt/python36/lib64/python3.6/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs c@s eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>sc@s eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgsc@s(eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrtsN)r__all__rrrrrrrrs 7) PK! NkTT/__pycache__/windows_events.cpython-36.opt-1.pycnu[3  fl@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__;/opt/alt/python36/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/ __classcell__rr)rrr's   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr7Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr7r=r8)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r9r8r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rCrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rCrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rCrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws   r6csFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. N)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr;r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rE)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rE)rr$)rrrr.s  z_WaitCancelFuture.set_exception) r1r2r3r4rr'r/r.r5rr)rrrDs  rDcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr:r;proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rJr< CloseHandlerKrI _unregisterrrr@)rr?)rrrr@s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r ZUnregisterWaitExrJr(rArBrr)r*rI _wait_cancelr@rK)rr;r+r,rrrrCs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrHs rHc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs      zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs     zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs  rPc@seZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd fdd ZddZeddZed d Zedd d Z Z S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt}tj|dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstjS)N)r rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)exc_infor)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterri) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerikwargsrzZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3r4rrgr rpryrr5rr)rrr/s /c@seZdZdZd1ddZddZddZd2d d Zd d Zd3ddZ d4ddZ ddZ ddZ ddZ eddZd5ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd6d)d*Zd+d,Zd-d.Zd/d0Zd S)7rz#Proactor implementation using IOCP.cCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr9 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr=)rtimeoutrXrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)r{r/)rvaluer?rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(rAr ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(rAr rrr~)rorrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrurb)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(rAerrnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rorr)rarrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrs s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(rAZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr:r+rrrrjs  zIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr:rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrE)rrFZ done_callbackr?rrrrO7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r=)rorr)rmrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r<INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rDr)rHrr)rr:rZ _is_cancelmsrr;rr)rmrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r9r]r rrtr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrhs zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr>)rrrrrrNszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr<rMrr'doner(r.rr>r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr=sJ         zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrDr'r(r)rr*r=r debugrrr<rM)rr r?rrrr+r,rrrrbs,     "   zIocpProactor.closecCs |jdS)N)rb)rrrrrdszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr=rrbrdrrrrrs.          7 c@seZdZddZdS)r|c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)rrrrrcsjj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr7rv) rr~rrrrrrrrmr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|sr|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr)-r4r<rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr6rDrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsL          0J4;]kPK!_قJ'__pycache__/queues.cpython-36.opt-2.pycnu[3 2a@sdddddgZddlZddlZddlmZdd lmZdd lmZdd lmZGd dde Z Gd dde Z GdddZ Gddde Z Gddde Zejse ZejddS)Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@s eZdZdS)rN)__name__ __module__ __qualname__rr+/opt/alt/python36/lib64/python3.6/queues.pyrsc@s eZdZdS)rN)r r rrrrrrsc@seZdZd(ddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ e ddZ ddZddZeddZddZed d!Zd"d#Zd$d%Zed&d'ZdS))rrN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)rpopleft)rrrr_get=sz Queue._getcCs|jj|dS)N)rappend)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r(r)r r+)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}rz _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r(rgetattrlistrrlenrr)rresultrrrr+Ts  z Queue._formatcCs t|jS)N)r0r)rrrrqsize`sz Queue.qsizecCs|jS)N)r)rrrrrdsz Queue.maxsizecCs|j S)N)r)rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)NrF)rr2)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)N) r4r create_futurerr"cancel cancelledr' put_nowait)rr#Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)Nr)r4rr$rrclearr'r)rr#rrrr8s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)N) r3rr5rr"r6remove ValueErrorr7r' get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)N)r3rr!r'r)rr#rrrr=s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)Nrz!task_done() called too many timesr)rr<rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)Nr)rrwait)rrrrjoins z Queue.join)r)r r rrrr!r$r'r,r-r+r2propertyrr3r4r r9r8r?r=r@rBrrrrrs$      c@s0eZdZddZejfddZejfddZdS)rcCs g|_dS)N)r)rrrrrrszPriorityQueue._initcCs||j|dS)N)r)rr#heappushrrrr$szPriorityQueue._putcCs ||jS)N)r)rheappoprrrr!szPriorityQueue._getN) r r rrheapqrDr$rEr!rrrrrsc@s$eZdZddZddZddZdS)rcCs g|_dS)N)r)rrrrrrszLifoQueue._initcCs|jj|dS)N)rr")rr#rrrr$szLifoQueue._putcCs |jjS)N)rpop)rrrrr!szLifoQueue._getN)r r rrr$r!rrrrrs JoinableQueue)__all__rrFrr r Z coroutinesr ExceptionrrrrrZPY35rHr"rrrrs    H PK!g}rbb'__pycache__/events.cpython-36.opt-1.pycnu[3  f[@sdZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddZddZd3ddZddZd4ddZGdddZGd ddeZGd!ddZGd"ddZGd#ddZGd$d%d%eZdae jZGd&d'd'e jZeZd(dZd)d Z d*d+Z!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'd2d Z(dS)5z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder 3/opt/alt/python36/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s<eZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3__doc__ __slots__rSrYr[r\rer r r r!rbs   csxeZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZZS)rz7Object returned by timed callback registration methods. _scheduled_whencs.tj||||jr|jd=||_d|_dS)NrFrT)superrSrLrjri)rPwhenrQr/rR)rUr r!rSs zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rkrYrJinsertrj)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashrj)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)rj)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)rj__eq__)rPrrr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)rj)rPrrr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rjrt)rPrrr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJNotImplemented)rPrrr r r!rts      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rtrx)rPrrZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrkr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrhrSrYrqrsrurvrwrtryr\ __classcell__r r )rUr!rs  c@s eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)rx)rPr r r!closeszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)rx)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3rgr|r}r r r r!rsc @seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d$d$d$d%d&d'Zdhd(d)Zdid*d$d$d$d*d*d*d+d,d-Zdjejejd*d.d*d*d*d/d0d1Zd*d*d*d2d3d4Zd*d.d*d5d6d7Zdkd$d$d$d*d*d*d*d8d9d:Zd;d<Zd=d>Z e!j"e!j"e!j"d?d@dAZ#e!j"e!j"e!j"d?dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4dddeZ5dfdgZ6d*S)lrzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)r~)rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)r~)rPr r r!stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.N)r~)rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.N)r~)rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)r~)rPr r r!r|s zAbstractEventLoop.closecCstdS)z,Shutdown all active asynchronous generators.N)r~)rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.N)r~)rPr^r r r!rzsz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r~)rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r~)rPrlrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r~)rPr r r!time"szAbstractEventLoop.timecCstdS)N)r~)rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r~)rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r~)rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r~)rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r~)rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r~)rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r~)rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r~) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)r~) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r~)rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)r~)rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)r~) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)r~)rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)r~)rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r~)rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r~)rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r~)rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r~)rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r~)rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r~)rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r~)rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r~)rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r~)rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r~)rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r~)rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r~)rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r~)rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r~)rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r~)rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r~)rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r~)rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r~)rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r~)rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r~)rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgrrrrrr|rrzrrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rst   '!   c@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)r~)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.N)r~)rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)r~)rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.N)r~)rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.N)r~)rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN) r4rfr3rgrr r r r r r r r!rs  c@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)rrrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rgrrlocalrrSrr r r r r r!r9s rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr r r r!rscCs|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r)Zpolicyr r r!rscCst}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr r r!rs cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rRr r r!r scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r r r r!r scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r r r r!r scCs tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr r r!r s)r2)NN))rg__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sZ    >8 5"7   PK!#m}LL+__pycache__/base_tasks.cpython-36.opt-2.pycnu[3 2a@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror //opt/alt/python36/lib64/python3.6/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   PK!(__pycache__/futures.cpython-36.opt-2.pycnu[3 2a> @sddddddgZddlZddlZddlZddlZdd lmZdd lmZdd lm Z ej Z ej Z ej Z ej Z ejZejZejZejdZGd d d ZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s0eZdZdZddZddZd d Zd d Zd S)_TracebackLoggerloopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr,/opt/alt/python36/lib64/python3.6/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr)__name__ __module__ __qualname__ __slots__rrrr&rrrrr s 2r c@seZdZeZdZdZdZdZdZ dZ ddddZ e j ZddZejrNdd Zd d Zd d ZddZddZddZddZddZddZddZddZddZejreZdS) rNF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)NFT)r4_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)N)r,r call_soon)rZ callbackscallbackrrrr:s  zFuture._schedule_callbackscCs |jtkS)N)r7r9)rrrr cancelledszFuture.cancelledcCs |jtkS)N)r7r8)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)NzResult is not ready.F)r7r9r _FINISHEDrr4r5_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)NzException is not set.F)r7r9rr@rr4r5)rrrrr3s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)N)r7r8rr<r,append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)Ncsg|]}|kr|qSrr).0f)rDrr sz/Future.remove_done_callback..)r,len)rrDZfiltered_callbacksZ removed_countr)rDrremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)Nz{}: {!r})r7r8rformatrAr@r:)rrBrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)Nz{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureT)r7r8rrK isinstancetype StopIteration TypeErrorr5r@r:r PY34r4r Z _tb_loggerrr<r)rr3rrr set_exception,s    zFuture.set_exceptionccs|jsd|_|V|jS)NT)r?_asyncio_future_blockingrB)rrrr__iter__DszFuture.__iter__) r'r(r)r8r7rAr5rrrSr4rr Z_future_repr_infor1r2r rQr&r;r:r>r?rBr3rErJrLrRrTZPY35 __await__rrrrrns2   cCs|jr dS|j|dS)N)r>rL)ZfutrBrrr_set_result_unless_cancelledSsrVcCsN|jr|j|jsdS|j}|dk r8|j|n|j}|j|dS)N)r>r;Zset_running_or_notify_cancelr3rRrBrL) concurrentsourcer3rBrrr_set_concurrent_future_stateZs rYcCsP|jr dS|jr|jn.|j}|dk r:|j|n|j}|j|dS)N)r>r;r3rRrBrL)rXdestr3rBrrr_copy_future_stateis  r[cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd}j|j|dS) Nz(A future is required for source argumentz-A future is required for destination argumentcSs"t|rt||n t||dS)N)rr[rY)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r>r;call_soon_threadsafe) destination) dest_looprX source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r>Z is_closedr^)rX)r]r`r_rarr_call_set_states  z&_chain_future.._call_set_state)rrMrWZfuturesrrPrrE)rXr_rbrcr)r]r`r_rXrar _chain_future}s   rd)r cCs2t|r |S|dkrtj}|j}t|||S)N)rr r+Z create_futurerd)rr Z new_futurerrrrs )__all__concurrent.futuresrWZloggingr.rrr r r rrrrr8r9r@DEBUGZ STACK_DEBUGr rZ _PyFuturerVrYr[rdrZ_asyncio ImportErrorZ_CFuturerrrrs<     Pc*  PK! NkTT)__pycache__/windows_events.cpython-36.pycnu[3  fl@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__;/opt/alt/python36/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/ __classcell__rr)rrr's   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr7Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr7r=r8)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r9r8r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rCrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rCrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rCrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws   r6csFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. N)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr;r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rE)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rE)rr$)rrrr.s  z_WaitCancelFuture.set_exception) r1r2r3r4rr'r/r.r5rr)rrrDs  rDcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr:r;proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rJr< CloseHandlerKrI _unregisterrrr@)rr?)rrrr@s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r ZUnregisterWaitExrJr(rArBrr)r*rI _wait_cancelr@rK)rr;r+r,rrrrCs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrHs rHc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs      zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs     zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs  rPc@seZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd fdd ZddZeddZed d Zedd d Z Z S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt}tj|dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstjS)N)r rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)exc_infor)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterri) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerikwargsrzZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3r4rrgr rpryrr5rr)rrr/s /c@seZdZdZd1ddZddZddZd2d d Zd d Zd3ddZ d4ddZ ddZ ddZ ddZ eddZd5ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd6d)d*Zd+d,Zd-d.Zd/d0Zd S)7rz#Proactor implementation using IOCP.cCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr9 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr=)rtimeoutrXrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)r{r/)rvaluer?rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(rAr ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(rAr rrr~)rorrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrurb)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(rAerrnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rorr)rarrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrs s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(rAZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr:r+rrrrjs  zIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr:rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrE)rrFZ done_callbackr?rrrrO7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r=)rorr)rmrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r<INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rDr)rHrr)rr:rZ _is_cancelmsrr;rr)rmrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r9r]r rrtr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrhs zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr>)rrrrrrNszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr<rMrr'doner(r.rr>r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr=sJ         zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrDr'r(r)rr*r=r debugrrr<rM)rr r?rrrr+r,rrrrbs,     "   zIocpProactor.closecCs |jdS)N)rb)rrrrrdszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr=rrbrdrrrrrs.          7 c@seZdZddZdS)r|c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)rrrrrcsjj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr7rv) rr~rrrrrrrrmr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|sr|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr)-r4r<rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr6rDrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsL          0J4;]kPK!ݸBa)__pycache__/__init__.cpython-36.opt-1.pycnu[3  f@sBdZddlZyddlmZWnek r8ddlZYnXejdkrryddlmZWnek rpddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkr,ddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorsZwin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r 5/opt/alt/python36/lib64/python3.6/asyncio/__init__.pys8  :  PK!t44)__pycache__/sslproto.cpython-36.opt-2.pycnu[3 2ae @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjr|j|jj|t|ks|jrDPqDW||fS)NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr!r r8r r<reasonr?r7r@rArrBr;r9)r$rCoffsetr1ZviewrErrr feed_appdatas2       z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname__r:r&propertyr%r'r(r*r3r5r6r/rJrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r$loopZ ssl_protocolrrrr&)sz_SSLProtocolTransport.__init__NcCs|jj||S)N)rQ_get_extra_info)r$namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rQ _app_protocol)r$protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rQrX)r$rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rR)r$rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)NT)rRrQ_start_shutdown)r$rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rRwarningswarnResourceWarningr^)r$rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)N)rQ _transport pause_reading)r$rrrreQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)N)rQrdresume_reading)r$rrrrfYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)N)rQrdset_write_buffer_limits)r$ZhighZlowrrrrgasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)N)rQrdget_write_buffer_size)r$rrrrhvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)Nz/data: expecting a bytes-like instance, got {!r}) isinstancebytes bytearrayrG TypeErrorformattyperKrQ_write_appdata)r$rCrrrr8zs z_SSLProtocolTransport.writecCsdS)NFr)r$rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)N)rQ_abort)r$rrrabortsz_SSLProtocolTransport.abort)N)NN)rKrLrMr&rWrZr[r\r^rZPY34rcrerfrgrhr8rprrrrrrrO&s   rOc@seZdZd'ddZd(ddZdd Zd d Zd d ZddZddZ ddZ d)ddZ ddZ ddZ ddZddZddZd*d!d"Zd#d$Zd%d&ZdS)+ SSLProtocolFNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r-rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrPrXrO_app_transport_sslpipe_session_established _in_handshake _in_shutdownrd_call_connection_made)r$rSZ app_protocolrZwaiterrrZcall_connection_maderrrr&s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)r{Z cancelledZ set_exceptionZ set_result)r$rErrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)N)rdrrtrrr}_start_handshake)r$ transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)NF)r~rP call_soonrXconnection_lostrdr|r)r$rErrrrs zSSLProtocol.connection_lostcCs|jjdS)N)rX pause_writing)r$rrrrszSSLProtocol.pause_writingcCs|jjdS)N)rXresume_writing)r$rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)Nz%r: SSL error %s (reason %s))r}r/r r<rP get_debugrwarningr7rHrqrdr8rX data_receivedr])r$rCr1r2erDrrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl) rPrrdebugrConnectionResetErrorrrX eof_receivedrrdr^)r$Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rvrdrW)r$rUrVrrrrT!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr+)rrrqro)r$rrrr])s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)ryr;rzrF_process_write_backlog)r$rCrrrro2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr+r)r+r) rPrrrtime_handshake_start_timerryr;r)r$rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr')$rr}r'Z getpeercertr rtrrr Z CERT_NONEZmatch_hostname BaseExceptionrPrrir=rrrdr^ ExceptionrrrrrvupdaterrrrXrr|r~rr)r$Z handshake_excZsslobjrrEZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q*WWnRtk r8}z4|jr|j|n |j|dt|ts(WYdd}~XnXdS)NrrzFatal error on SSL transport)rdr}rangerFryrJr3rr5 _finalizer8Z_pausedrfrzrr _fatal_errorrir)r$irCrIr1rDrErrrrws8      z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrY) rirZ_FATAL_ERROR_IGNORErPrrrZcall_exception_handlerrdZ _force_close)r$rErrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r}rdr^)r$rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rdrrr)r$rrrrqs zSSLProtocol._abort)FNT)N)N)r)rKrLrMr&rrrrrrrrTr]rorrrrrrqrrrrrss$ "     4, rs)rwr`r ImportErrorrrrrlogrrrrr.r)r4objectrZ_FlowControlMixinZ TransportrOZProtocolrsrrrrs*       wnPK!D-__pycache__/base_futures.cpython-36.opt-1.pycnu[3  f@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@seZdZdZdS)InvalidStateErrorz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__r r 9/opt/alt/python36/lib64/python3.6/asyncio/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r )objr r r isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) z#helper function for Future.__repr__cSs tj|fS)N)rZ_format_callback_source)callbackr r r format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerr r r _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)z#helper function for Future.__repr__Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframer r r _future_repr_info6s     r")__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr"r r r r s   PK!4X##0__pycache__/base_subprocess.cpython-36.opt-1.pycnu[3  f#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|j| dS)NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__ ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #sPyj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x"j D]\}}|j|f|qWd_ WnDt k r*}z&|dk r|j r|j|WYdd}~Xn"X|dk rL|j rL|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s6          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrR)r)cbrZr/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r]rZpipe_connection_lost _try_finish)r)rIr[r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r]rZpipe_data_received)r)rIrZr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCst|jjrtjd||||_|jjdkr2||j_|j|jj |j x |j D]}|j sP|j |qPWd|_ dS)Nz%r exited with return code %r)rr#rr8rr returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0_process_exiteds   z'BaseSubprocessTransport._process_exitedccs0|jdk r|jS|jj}|jj||EdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr4)r)r,r/r/r0_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jjDr:d|_|j|jddS)Ncss|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rallrr>rr]_call_connection_lost)r)r/r/r0r^s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r[r/r/r0ris z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rWr pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rWrresume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN) r3rkrlrrSr9rjrnror/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rWr`rI)r)rZr/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { PK!h{DD'__pycache__/events.cpython-36.opt-2.pycnu[3 2a[@s|dddddddddd d d d d gZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddZ ddZd2ddZddZd3ddZGdddZGdddeZGd ddZGd!ddZGd"ddZGd#d$d$eZdaejZGd%d&d&ejZeZd'd Zd(d Zd)d*Z d+dZ!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'dS)4AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder +/opt/alt/python36/lib64/python3.6/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)Ncss|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s8eZdZdZdd Zd d Zd d ZddZddZdS)r _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3 __slots__rSrYr[r\rer r r r!rbs   csteZdZddgZfddZfddZddZd d Zd d Zd dZ ddZ ddZ ddZ fddZ ZS)r _scheduled_whencs.tj||||jr|jd=||_d|_dS)NrFrT)superrSrLrirh)rPwhenrQr/rR)rUr r!rSs zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rjrYrJinsertri)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashri)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)ri)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)ri__eq__)rPrqr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)ri)rPrqr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rirs)rPrqr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrirHrIrJNotImplemented)rPrqr r r!rss      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rsrw)rPrqZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrjr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrSrYrprrrtrurvrsrxr\ __classcell__r r )rUr!rs  c@seZdZddZddZdS)rcCstS)N)rw)rPr r r!closeszAbstractServer.closecCstS)N)rw)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3r{r|r r r r!rsc @seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d#d#d#d$d%d&Zdgd'd(Zdhd)d#d#d#d)d)d)d*d+d,Zdiejejd)d-d)d)d)d.d/d0Zd)d)d)d1d2d3Zd)d-d)d4d5d6Zdjd#d#d#d)d)d)d)d7d8d9Zd:d;Zdd?d@Z"e j!e j!e j!d>dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5d)S)krcCstdS)N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)N)r})rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)N)r})rPr r r!stopszAbstractEventLoop.stopcCstdS)N)r})rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)N)r})rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)N)r})rPr r r!r{s zAbstractEventLoop.closecCstdS)N)r})rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)N)r})rPr^r r r!rysz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r})rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r})rPrkrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r})rPr r r!time"szAbstractEventLoop.timecCstdS)N)r})rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r})rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r})rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r})rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r})rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r})rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r})rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r}) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)N)r}) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r})rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)N)r})rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)N)r}) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)N)r})rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)N)r})rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r})rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r})rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r})rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r})rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r})rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r})rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r})rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r})rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r})rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r})rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r})rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r})rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r})rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r})rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r})rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r})rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r})rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r})rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r})rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r})rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)6r4rfr3r~rrrrr{rryrrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rsr   '!   c@s4eZdZddZddZddZddZd d Zd S) rcCstdS)N)r})rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)N)r})rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)N)r})rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)N)r})rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)N)r})rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN)r4rfr3rr r r r r r r r!rs  c@sBeZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)NT)rrrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)N) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rrlocalrrSrr r r r r r!r9s  rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)N)rrr r r r!rscCs|adS)N)r)Zpolicyr r r!rscCst}|dk r|StjS)N)rrr)Z current_loopr r r!rs cCstj|dS)N)rr )rRr r r!r scCs tjS)N)rr r r r r!r scCs tjS)N)rr r r r r!r scCs tj|S)N)rr )rr r r!r s)r2)NN)(__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sX    >8 5"7   PK!wll'__pycache__/compat.cpython-36.opt-2.pycnu[3 2a@s2ddlZejdkZejd kZejd kZddZdS) NcCstsdd|D}dj|S)Ncss$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar +/opt/alt/python36/lib64/python3.6/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)sys version_inforZPY35ZPY352rr r r r s   PK!lOO/__pycache__/windows_events.cpython-36.opt-2.pycnu[3 2al@sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZd dddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdddeZ Gd d!d!e j!Z"Gd"dde j#Z$Gd#ddZ%Gd$d%d%ej&Z'e"Z(Gd&d'd'ej)Z*e*Z+dS)(N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?csZeZdZddfdd ZfddZddZfd d Zfd d Zfd dZZ S)_OverlappedFutureN)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__3/opt/alt/python36/lib64/python3.6/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname__rrr-r'r.r/ __classcell__rr)rrr's    rcsjeZdZddfdd ZddZfddZd d Zd d Zfd dZfddZ fddZ Z S)_BaseWaitHandleFutureN)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr6Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr6r<r7)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r8r7r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r?)rr:r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rBrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rBrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rBrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3rr<rr?rBr'r.r/r4rr)rrr5Ws   r5csBeZdZddfdd ZddZfddZfd d ZZS) _WaitCancelFutureN)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr:r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rD)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rD)rr$)rrrr.s  z_WaitCancelFuture.set_exception)r1r2r3rr'r/r.r4rr)rrrCs rCcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr9r:proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rIr; CloseHandlerJrH _unregisterrrr?)rr>)rrrr?s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r8r7r ZUnregisterWaitExrIr(r@rArr)r*rH _wait_cancelr?rJ)rr:r+r,rrrrBs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBr4rr)rrrGs rGc@s8eZdZddZddZddZddZd d ZeZd S) PipeServercCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rTrV)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr;ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperPZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerSadd)rfirstflagshpiperrrrVs      zPipeServer._server_pipe_handlecCs |jdkS)N)rP)rrrrrYszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rUr'rPrScloserTclear)rr`rrrras     zPipeServer.closeN) r1r2r3rrXrVrYra__del__rrrrrOs   rOc@seZdZddZdS)_WindowsSelectorEventLoopcCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3rfrrrrrd(srdcsLeZdZd fdd ZddZeddZedd Zed d d ZZ S)rNcs|dkrt}tj|dS)N)rrr)rrK)rrrr2szProactorEventLoop.__init__cCstjS)N)r re)rrrrrf7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rH connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fr`protocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrg)rhrzPipe accept failed)r#r$r`zAccept pipe failed on pipe %rT)exc_infor)r0rSdiscardrYrarjrXrH accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrUadd_done_callback)rlr`rmr+)r loop_accept_piperkrserverrrrvGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rOZ call_soon)rrkr r)r rvrkrrwrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterrh) create_future_WindowsSubprocessTransport ExceptionraZ_wait)rrmargsshellstdinstdoutstderrbufsizerhkwargsryZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3rrfr rorxrr4rr)rrr/s  /c@seZdZd0ddZddZddZd1d d Zd d Zd2ddZd3ddZ ddZ ddZ ddZ e ddZd4ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd5d(d)Zd*d+Zd,d-Zd.d/ZdS)6rcCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUErZ_iocp_cacherQrRr8 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr<)rtimeoutrWrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)rzr/)rvaluer>rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(r@r ERROR_NETNAME_DELETEDConnectionResetErrorr})rnkeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr OverlappedrZ isinstancesocketZWSARecvrsZReadFileBrokenPipeErrorr _register)rconnnbytesr^rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(r@r rrr})rnrrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rrZrrZWSASendrsZ WriteFiler)rrbufr^rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructpackrs setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rnrrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrtra)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rrZZAcceptExrsr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rnrr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrsrr(r@errnoZ WSAEINVALZ getsocknamerrZZ ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rnrr)r`rrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rrZZConnectNamedPipersrr)rr`rZ connectedrr)r`rrr s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(r@ZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r[)rr Zdelayr9r+rrrris  zIocpProactor.connect_pipecCs|j||dS)NF)_wait_for_handle)rr9rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrD)rrEZ done_callbackr>rrrrN7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r<)rnrr)rlrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r;INFINITEmathceilr rrZZRegisterWaitWithQueuerr rCr)rGrr)rr9rZ _is_cancelmsrr:rr)rlrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r8r\r rrsr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrlrrrrrrhs zIocpProactor._registercCs|jj|dS)N)rr=)rrrrrrMszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr;rLrr'doner(r.rr=r/rr rb)rrrrrZ transferredrr rlrrrrrrrrr<sJ         zIocpProactor._pollcCs|jj|dS)N)rr\)rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrCr'r(r)rr*r<r debugrrr;rL)rr r>rrrr+r,rrrras,     "   zIocpProactor.closecCs |jdS)N)ra)rrrrrcszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3rrrrrrrrrrrr rirrNrrrrMrr<rrarcrrrrrs,          7 c@seZdZddZdS)r{c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)r~rrrrcsjj}j|dS)N)_procZpollZ_process_exited)rl returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rHrintr6ru) rr}r~rrrrrrrlr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr{sr{c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr),r;rrrrrQrrrrrrr r Z coroutinesr logr __all__rZrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr5rCrGobjectrOZBaseSelectorEventLooprdZBaseProactorEventLooprrZBaseSubprocessTransportr{r ZBaseDefaultEventLoopPolicyrrrrrrsJ          0J4;]kPK!aFss*__pycache__/selector_events.cpython-36.pycnu[3  f @s<dZdgZddlZddlZddlZddlZddlZddlZy ddlZWne k r^dZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyrZ ed?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(Z)S)VrzJSelector event loop. See events.EventLoop for API specification. NcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)zAdd a reader callback.)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. This method is a coroutine. rzthe socket must be non-blockingN)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. This method is a coroutine. rzthe socket must be non-blockingN)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIX)familyprotoloopN)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)a|Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. This method is a coroutine. rzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r __module__ __qualname____doc__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sT      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jstd|jrdSy|jj|j}Wn\ttfk rBYntk r}z*|jj |j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj |j |jr|jdn|jr|jjtjdS)NzData should not be emptyz%Fatal write error on socket transport)rAssertionErrorrrrHrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs(   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0) r__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsD             iiPK!L+__pycache__/transports.cpython-36.opt-2.pycnu[3 2aR'@sddlmZddddddgZGdddZGd ddeZGd ddeZGd ddeeZGd ddeZGd ddeZGdddeZ dS))compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@s@eZdZdddZdddZddZdd Zd d Zd d ZdS)rNcCs|dkr i}||_dS)N)_extra)selfextrar //opt/alt/python36/lib64/python3.6/transports.py__init__ szBaseTransport.__init__cCs|jj||S)N)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)N)r)r r r r closeszBaseTransport.closecCstdS)N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname__rrrrrrr r r r r s    c@seZdZddZddZdS)rcCstdS)N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrr r r r r-sc@sFeZdZdddZddZddZdd Zd d Zd d ZddZ dS)rNcCstdS)N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)N)rZflatten_list_bytesr#)r Z list_of_datar"r r r writelineses zWriteTransport.writelinescCstdS)N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)N)r)r r r r abort{szWriteTransport.abort)NN) rrrr r!r#r$r%r&r'r r r r rAs   c@s eZdZdS)rN)rrrr r r r rsc@seZdZdddZddZdS)rNcCstdS)N)r)r r"Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)N)r)r r r r r'szDatagramTransport.abort)N)rrrr(r'r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)N)r)r r r r kills zSubprocessTransport.killN) rrrr)r*r,r.r/r0r r r r rs csReZdZdfdd ZddZddZdd Zdd d Zdd d ZddZ Z S)_FlowControlMixinNcs$tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r! _high_waterr4 _protocolZ pause_writing Exceptionr3call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r7r8r9r)r4r! _low_waterr;Zresume_writingr<r3r=)r r?r r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rAr:)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr:rA)r rrr r r r5s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr)r5r@)r rrr r r r -sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r!1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrr@rBrCr5r r! __classcell__r r )r6r r1s  r1N) Zasyncior__all__rrrrrrr1r r r r s  #D4PK!pCP compat.pynu["""Compatibility helpers for the different Python versions.""" import sys PY34 = sys.version_info >= (3, 4) PY35 = sys.version_info >= (3, 5) PY352 = sys.version_info >= (3, 5, 2) def flatten_list_bytes(list_of_data): """Concatenate a sequence of bytes-like objects.""" if not PY34: # On Python 3.3 and older, bytes.join() doesn't handle # memoryview. list_of_data = ( bytes(data) if isinstance(data, memoryview) else data for data in list_of_data) return b''.join(list_of_data) PK!zd88 test_utils.pynu["""Utilities shared by tests.""" import collections import contextlib import io import logging import os import re import socket import socketserver import sys import tempfile import threading import time import unittest import weakref from unittest import mock from http.server import HTTPServer from wsgiref.simple_server import WSGIRequestHandler, WSGIServer try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import compat from . import events from . import futures from . import selectors from . import tasks from .coroutines import coroutine from .log import logger from test import support if sys.platform == 'win32': # pragma: no cover from .windows_utils import socketpair else: from socket import socketpair # pragma: no cover def dummy_ssl_context(): if ssl is None: return None else: return ssl.SSLContext(ssl.PROTOCOL_SSLv23) def run_briefly(loop): @coroutine def once(): pass gen = once() t = loop.create_task(gen) # Don't log a warning if the task is not done after run_until_complete(). # It occurs if the loop is stopped or if a task raises a BaseException. t._log_destroy_pending = False try: loop.run_until_complete(t) finally: gen.close() def run_until(loop, pred, timeout=30): deadline = time.time() + timeout while not pred(): if timeout is not None: timeout = deadline - time.time() if timeout <= 0: raise futures.TimeoutError() loop.run_until_complete(tasks.sleep(0.001, loop=loop)) def run_once(loop): """Legacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. """ loop.call_soon(loop.stop) loop.run_forever() class SilentWSGIRequestHandler(WSGIRequestHandler): def get_stderr(self): return io.StringIO() def log_message(self, format, *args): pass class SilentWSGIServer(WSGIServer): request_timeout = 2 def get_request(self): request, client_addr = super().get_request() request.settimeout(self.request_timeout) return request, client_addr def handle_error(self, request, client_address): pass class SSLWSGIServerMixin: def finish_request(self, request, client_address): # The relative location of our test directory (which # contains the ssl key and certificate files) differs # between the stdlib and stand-alone asyncio. # Prefer our own if we can find it. here = os.path.join(os.path.dirname(__file__), '..', 'tests') if not os.path.isdir(here): here = os.path.join(os.path.dirname(os.__file__), 'test', 'test_asyncio') keyfile = os.path.join(here, 'ssl_key.pem') certfile = os.path.join(here, 'ssl_cert.pem') ssock = ssl.wrap_socket(request, keyfile=keyfile, certfile=certfile, server_side=True) try: self.RequestHandlerClass(ssock, client_address, self) ssock.close() except OSError: # maybe socket has been closed by peer pass class SSLWSGIServer(SSLWSGIServerMixin, SilentWSGIServer): pass def _run_test_server(*, address, use_ssl=False, server_cls, server_ssl_cls): def app(environ, start_response): status = '200 OK' headers = [('Content-type', 'text/plain')] start_response(status, headers) return [b'Test message'] # Run the test WSGI server in a separate thread in order not to # interfere with event handling in the main thread server_class = server_ssl_cls if use_ssl else server_cls httpd = server_class(address, SilentWSGIRequestHandler) httpd.set_app(app) httpd.address = httpd.server_address server_thread = threading.Thread( target=lambda: httpd.serve_forever(poll_interval=0.05)) server_thread.start() try: yield httpd finally: httpd.shutdown() httpd.server_close() server_thread.join() if hasattr(socket, 'AF_UNIX'): class UnixHTTPServer(socketserver.UnixStreamServer, HTTPServer): def server_bind(self): socketserver.UnixStreamServer.server_bind(self) self.server_name = '127.0.0.1' self.server_port = 80 class UnixWSGIServer(UnixHTTPServer, WSGIServer): request_timeout = 2 def server_bind(self): UnixHTTPServer.server_bind(self) self.setup_environ() def get_request(self): request, client_addr = super().get_request() request.settimeout(self.request_timeout) # Code in the stdlib expects that get_request # will return a socket and a tuple (host, port). # However, this isn't true for UNIX sockets, # as the second return value will be a path; # hence we return some fake data sufficient # to get the tests going return request, ('127.0.0.1', '') class SilentUnixWSGIServer(UnixWSGIServer): def handle_error(self, request, client_address): pass class UnixSSLWSGIServer(SSLWSGIServerMixin, SilentUnixWSGIServer): pass def gen_unix_socket_path(): with tempfile.NamedTemporaryFile() as file: return file.name @contextlib.contextmanager def unix_socket_path(): path = gen_unix_socket_path() try: yield path finally: try: os.unlink(path) except OSError: pass @contextlib.contextmanager def run_test_unix_server(*, use_ssl=False): with unix_socket_path() as path: yield from _run_test_server(address=path, use_ssl=use_ssl, server_cls=SilentUnixWSGIServer, server_ssl_cls=UnixSSLWSGIServer) @contextlib.contextmanager def run_test_server(*, host='127.0.0.1', port=0, use_ssl=False): yield from _run_test_server(address=(host, port), use_ssl=use_ssl, server_cls=SilentWSGIServer, server_ssl_cls=SSLWSGIServer) def make_test_protocol(base): dct = {} for name in dir(base): if name.startswith('__') and name.endswith('__'): # skip magic names continue dct[name] = MockCallback(return_value=None) return type('TestProtocol', (base,) + base.__bases__, dct)() class TestSelector(selectors.BaseSelector): def __init__(self): self.keys = {} def register(self, fileobj, events, data=None): key = selectors.SelectorKey(fileobj, 0, events, data) self.keys[fileobj] = key return key def unregister(self, fileobj): return self.keys.pop(fileobj) def select(self, timeout): return [] def get_map(self): return self.keys class TestLoop(base_events.BaseEventLoop): """Loop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. """ def __init__(self, gen=None): super().__init__() if gen is None: def gen(): yield self._check_on_close = False else: self._check_on_close = True self._gen = gen() next(self._gen) self._time = 0 self._clock_resolution = 1e-9 self._timers = [] self._selector = TestSelector() self.readers = {} self.writers = {} self.reset_counters() self._transports = weakref.WeakValueDictionary() def time(self): return self._time def advance_time(self, advance): """Move test time forward.""" if advance: self._time += advance def close(self): super().close() if self._check_on_close: try: self._gen.send(0) except StopIteration: pass else: # pragma: no cover raise AssertionError("Time generator is not finished") def _add_reader(self, fd, callback, *args): self.readers[fd] = events.Handle(callback, args, self) def _remove_reader(self, fd): self.remove_reader_count[fd] += 1 if fd in self.readers: del self.readers[fd] return True else: return False def assert_reader(self, fd, callback, *args): assert fd in self.readers, 'fd {} is not registered'.format(fd) handle = self.readers[fd] assert handle._callback == callback, '{!r} != {!r}'.format( handle._callback, callback) assert handle._args == args, '{!r} != {!r}'.format( handle._args, args) def _add_writer(self, fd, callback, *args): self.writers[fd] = events.Handle(callback, args, self) def _remove_writer(self, fd): self.remove_writer_count[fd] += 1 if fd in self.writers: del self.writers[fd] return True else: return False def assert_writer(self, fd, callback, *args): assert fd in self.writers, 'fd {} is not registered'.format(fd) handle = self.writers[fd] assert handle._callback == callback, '{!r} != {!r}'.format( handle._callback, callback) assert handle._args == args, '{!r} != {!r}'.format( handle._args, args) def _ensure_fd_no_transport(self, fd): try: transport = self._transports[fd] except KeyError: pass else: raise RuntimeError( 'File descriptor {!r} is used by transport {!r}'.format( fd, transport)) def add_reader(self, fd, callback, *args): """Add a reader callback.""" self._ensure_fd_no_transport(fd) return self._add_reader(fd, callback, *args) def remove_reader(self, fd): """Remove a reader callback.""" self._ensure_fd_no_transport(fd) return self._remove_reader(fd) def add_writer(self, fd, callback, *args): """Add a writer callback..""" self._ensure_fd_no_transport(fd) return self._add_writer(fd, callback, *args) def remove_writer(self, fd): """Remove a writer callback.""" self._ensure_fd_no_transport(fd) return self._remove_writer(fd) def reset_counters(self): self.remove_reader_count = collections.defaultdict(int) self.remove_writer_count = collections.defaultdict(int) def _run_once(self): super()._run_once() for when in self._timers: advance = self._gen.send(when) self.advance_time(advance) self._timers = [] def call_at(self, when, callback, *args): self._timers.append(when) return super().call_at(when, callback, *args) def _process_events(self, event_list): return def _write_to_self(self): pass def MockCallback(**kwargs): return mock.Mock(spec=['__call__'], **kwargs) class MockPattern(str): """A regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) """ def __eq__(self, other): return bool(re.search(str(self), other, re.S)) def get_function_source(func): source = events._get_function_source(func) if source is None: raise ValueError("unable to get the source of %r" % (func,)) return source class TestCase(unittest.TestCase): def set_event_loop(self, loop, *, cleanup=True): assert loop is not None # ensure that the event loop is passed explicitly in asyncio events.set_event_loop(None) if cleanup: self.addCleanup(loop.close) def new_test_loop(self, gen=None): loop = TestLoop(gen) self.set_event_loop(loop) return loop def unpatch_get_running_loop(self): events._get_running_loop = self._get_running_loop def setUp(self): self._get_running_loop = events._get_running_loop events._get_running_loop = lambda: None self._thread_cleanup = support.threading_setup() def tearDown(self): self.unpatch_get_running_loop() events.set_event_loop(None) # Detect CPython bug #23353: ensure that yield/yield-from is not used # in an except block of a generator self.assertEqual(sys.exc_info(), (None, None, None)) self.doCleanups() support.threading_cleanup(*self._thread_cleanup) support.reap_children() if not compat.PY34: # Python 3.3 compatibility def subTest(self, *args, **kwargs): class EmptyCM: def __enter__(self): pass def __exit__(self, *exc): pass return EmptyCM() @contextlib.contextmanager def disable_logger(): """Context manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. """ old_level = logger.level try: logger.setLevel(logging.CRITICAL+1) yield finally: logger.setLevel(old_level) def mock_nonblocking_socket(proto=socket.IPPROTO_TCP, type=socket.SOCK_STREAM, family=socket.AF_INET): """Create a mock of a non-blocking socket.""" sock = mock.MagicMock(socket.socket) sock.proto = proto sock.type = type sock.family = family sock.gettimeout.return_value = 0.0 return sock def force_legacy_ssl_support(): return mock.patch('asyncio.sslproto._is_sslproto_available', return_value=False) PK!3cc)__pycache__/__init__.cpython-35.opt-1.pycnu[ Yf@sdZddlZyddlmZWnek rFddlZYnXejdkryddlmZWnek rddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkrqddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorswin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsrr5/opt/alt/python35/lib64/python3.5/asyncio/__init__.pys8              E   PK!b*__pycache__/selector_events.cpython-35.pycnu[ Yf @sdZdgZddlZddlZddlZddlZddlZddlZyddlZWne k rdZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZeedrLddZn ddZGddde jZGdddejejZGdddeZGdddeZ GdddeZ!dS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc CsAy|j|}Wntk r+dSYnXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyrZd?d@Z edAdBZ!dCdDZ"dEdFZ#dGdHZ$dIdJZ%dKdLZ&dMdNZ'dOdPZ(S)QrzJSelector event loop. See events.EventLoop for API specification. Ncsatj|dkr%tj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)r!rrr<s     zBaseSelectorEventLoop.__init__extraservercCst||||||S)N)_SelectorSocketTransport)r(rprotocolwaiterr)r*rrr_make_socket_transportFsz,BaseSelectorEventLoop._make_socket_transport server_sideFserver_hostnamec Cs{tjs:|j||||d|d|d|d|Stj||||||} t||| d|d|| jS)Nr/r0r)r*)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr+Z_app_transport) r(rawsockr, sslcontextr-r/r0r)r*Z ssl_protocolrrr_make_ssl_transportKs     z)BaseSelectorEventLoop._make_ssl_transportc Cs"t||||||||| S)N)_SelectorSslTransport) r(r2r,r3r-r/r0r)r*rrrr1Zsz0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r(rr,addressr-r)rrr_make_datagram_transportds z.BaseSelectorEventLoop._make_datagram_transportcsh|jrtd|jr(dS|jtj|jdk rd|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser#)r()r!rrr<is      zBaseSelectorEventLoop.closecCs tdS)N)NotImplementedError)r(rrr _socketpairtsz!BaseSelectorEventLoop._socketpaircCsU|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor<_csock _internal_fds)r(rrrr;ws     z&BaseSelectorEventLoop._close_self_pipecCsg|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r>r@rB setblockingrC _add_readerrA_read_from_self)r(rrrr$s z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r(datarrr_process_self_datasz(BaseSelectorEventLoop._process_self_datac Cs_xXy*|jjd}|sP|j|Wqtk rDwYqtk rVPYqXqWdS)Ni)r@recvrHInterruptedErrorBlockingIOError)r(rGrrrrFs  z%BaseSelectorEventLoop._read_from_selfc Cs[|j}|dk rWy|jdWn.tk rV|jrRtjdddYnXdS)Nsz3Fail to write a null byte into the self-pipe socketexc_infoT)rBsendOSError_debugr r )r(Zcsockrrr_write_to_selfs     z$BaseSelectorEventLoop._write_to_selfdcCs,|j|j|j|||||dS)N)rErA_accept_connection)r(protocol_factoryrr3r*backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cs[xTt|D]F}yB|j\}}|jrGtjd||||jdWntttfk rvdSYq t k r} z| j t j t j t j t jfkr |jddd| d|i|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFmessagez&socket.accept() out of system resource exceptionrpeername)rangeacceptrOr r rDrKrJConnectionAbortedErrorrNerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr?rAZ call_laterrZACCEPT_RETRY_DELAYrU_accept_connection2Z create_task) r(rSrr3r*rT_connaddrexcr)rZrrrrRs4         z(BaseSelectorEventLoop._accept_connectionc cs$d}d}y|}|j}|rZ|j|||d|ddd|d|}n$|j||d|d|d|}y |EdHWn|jYnXWnytk r} zY|jr ddd| i} |dk r|| d <|dk r|| d <|j| WYdd} ~ XnXdS) Nr-r/Tr)r*rVz3Error on transport creation for incoming connectionrWr, transport) create_futurer4r.r< ExceptionrOr]) r(rSr`r)r3r*r,rcr-rbcontextrrrr^s4            z)BaseSelectorEventLoop._accept_connection2c CsNy|j|}Wntk r%Yn%X|jsJtdj||dS)Nz.File descriptor {!r} is used by transport {!r})r'r is_closingr9format)r(rrcrrr_ensure_fd_no_transports  z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tj|dfYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandler#rrregisterr EVENT_READrGmodifycancel) r(rcallbackargshandlermaskreaderwriterrrrrEs    z!BaseSelectorEventLoop._add_readerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r:r#rrrrGr rm unregisterrnro)r(rrrsrtrurrrr?s     z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tjd|fYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rjrrkr#rrrlr EVENT_WRITErGrnro) r(rrprqrrrrsrtrurrr _add_writer(s    z!BaseSelectorEventLoop._add_writerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r:r#rrrrGr rwrvrnro)r(rrrsrtrurrr_remove_writer7s     z$BaseSelectorEventLoop._remove_writercGs |j||j|||S)zAdd a reader callback.)rirE)r(rrprqrrr add_readerNs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rir?)r(rrrr remove_readerSs z#BaseSelectorEventLoop.remove_readercGs |j||j|||S)zAdd a writer callback..)rirx)r(rrprqrrr add_writerXs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)riry)r(rrrr remove_writer]s z#BaseSelectorEventLoop.remove_writercCsM|jr'|jdkr'td|j}|j|d|||S)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. This method is a coroutine. rzthe socket must be non-blockingF)rO gettimeout ValueErrorrd _sock_recv)r(rnfutrrr sock_recvbs   zBaseSelectorEventLoop.sock_recvcCs|j}|r|j||jr/dSy|j|}Wnhttfk r{|j||j|d||Yn?tk r}z|j |WYdd}~XnX|j |dS)NT) rAr{ cancelledrIrKrJrzrre set_exception set_result)r(r registeredrrrrGrbrrrrqs   # z BaseSelectorEventLoop._sock_recvcCsc|jr'|jdkr'td|j}|rR|j|d||n |jd|S)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. This method is a coroutine. rzthe socket must be non-blockingFN)rOr~rrd _sock_sendallr)r(rrGrrrr sock_sendalls    z"BaseSelectorEventLoop.sock_sendallcCs|j}|r|j||jr/dSy|j|}WnSttfk rbd}Yn6tk r}z|j|dSWYdd}~XnX|t|kr|j dn5|r||d}|j ||j |d||dS)NrT) rAr}rrMrKrJrerlenrr|r)r(rrrrGrrrbrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr'|jdkr'tdttd sI|jtjkrtj|d|jd|j d|}|j s|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIXrrloopN)rOr~rhasattrrrrrZ_ensure_resolvedrdoneresultrd _sock_connect)r(rr7Zresolvedr_rrrr sock_connects "!   z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnttfk ro|jtj|j||j||j |||Yn?t k r}z|j |WYdd}~XnX|j ddS)N) rAZconnectrKrJZadd_done_callback functoolspartial_sock_connect_doner|_sock_connect_cbrerr)r(rrr7rrbrrrrs   z#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)r})r(rrrrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jrdSy>|jtjtj}|dkrMt|d|fWnIttfk rhYn?tk r}z|j |WYdd}~XnX|j ddS)NrzConnect call failed %s) rZ getsockoptrZ SOL_SOCKETZSO_ERRORrNrKrJrerr)r(rrr7errrbrrrrs   z&BaseSelectorEventLoop._sock_connect_cbcCsJ|jr'|jdkr'td|j}|j|d||S)a|Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. This method is a coroutine. rzthe socket must be non-blockingF)rOr~rrd _sock_accept)r(rrrrr sock_accepts   z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr/dSy#|j\}}|jdWnettfk r|j||j|d|YnEt k r}z|j |WYdd}~XnX|j ||fdS)NFT) rAr{rrZrDrKrJrzrrerr)r(rrrrr`r7rbrrrrs     z"BaseSelectorEventLoop._sock_acceptcCsx|D]\}}|j|j}\}}|tj@rk|dk rk|jr^|j|n |j||tj@r|dk r|jr|j|q|j|qWdS)N) fileobjrGr rmZ _cancelledr?Z _add_callbackrwry)r(Z event_listrrsrrtrurrr_process_events s   z%BaseSelectorEventLoop._process_eventscCs!|j|j|jdS)N)r?rAr<)r(rrrr _stop_servingsz#BaseSelectorEventLoop._stop_serving))r" __module__ __qualname____doc__rr.r4r1r8r<r>r;r$rHrFrPrUrRr r^rirEr?rxryrzr{r|r}rrrrrrrrrrrrrr)r!rr6sV          (#                  cseZdZdZeZdZddfddZddZdd Z d d Z d d Z ddZ ddZ ejrddZdddZddZddZddZS)_SelectorTransportiNc stj||||jd<|j|jdz<%s> )r!r"rappendrr_loopr:rr#r rmrwget_write_buffer_sizejoin)r(inforstatebufsizerrr__repr__>s*        z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r(rrrabortZsz_SelectorTransport.abortcCs ||_dS)N)r)r(r,rrr set_protocol]sz_SelectorTransport.set_protocolcCs|jS)N)r)r(rrr get_protocol`sz_SelectorTransport.get_protocolcCs|jS)N)r)r(rrrrgcsz_SelectorTransport.is_closingcCsn|jr dSd|_|jj|j|jsj|jd7_|jj|j|jj|jddS)NTr) rrr?rrrry call_soon_call_connection_lost)r(rrrr<fs   z_SelectorTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningr<)r(rrr__del__tsz_SelectorTransport.__del__zFatal error on transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srLTrVrWrcr,) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr r r]rr)r(rbrVrrr _fatal_errorys z_SelectorTransport._fatal_errorcCs|jr dS|jr6|jj|jj|j|js[d|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrryrrr?rr)r(rbrrrrs     z_SelectorTransport._force_closec Csuz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rp|jd|_XdS)N)rrZconnection_lostrr<rrZ_detach)r(rbr*rrrrs        z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r(rrrrsz(_SelectorTransport.get_write_buffer_sizei)r"rrmax_size bytearrayrrrrrrrrgr<rZPY34rrrrrrr)r!rrs         rcseZdZdddfddZddZddZdd Zd d Zd d ZddZ ddZ S)r+Ncstj|||||d|_d|_t|j|jj|jj ||jj|jj |j |j |dk r|jjt j|ddS)NF)rr_eof_pausedrrrrrconnection_maderEr _read_readyr_set_result_unless_cancelled)r(rrr,r-r)r*)r!rrrs    z!_SelectorSocketTransport.__init__cCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr9rrr?rrr r )r(rrr pause_readings     z&_SelectorSocketTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr9rrrErrrr r )r(rrrresume_readings    z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnLttfk r@Yntk rt}z|j|dWYdd}~XnnX|r|jj |nT|j j rt j d||jj}|r|j j|jn |jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrIrrKrJrerr data_receivedrrr r eof_receivedr?rr<)r(rGrb keep_openrrrrs  #z$_SelectorSocketTransport._read_readycCsNt|tttfs1tdt|j|jrFtd|sPdS|j r|j t j krxt j d|j d7_ dS|js0y|jj|}WnPttfk rYnStk r}z|j|ddSWYdd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrorrr"rr9rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrMrKrJrerrrxr _write_readyextend_maybe_pause_protocol)r(rGrrbrrrwrites4     z_SelectorSocketTransport.writecCs|jstd|jr"dSy|jj|j}Wnlttfk rUYntk r}z5|jj |j |jj |j |dWYdd}~XnrX|r|jd|=|j |js|jj |j |jr|jdn|jr|jjtjdS)NzData should not be emptyz%Fatal write error on socket transport)rAssertionErrorrrrMrKrJrerryrrr_maybe_resume_protocolrrrshutdownrSHUT_WR)r(rrbrrrr s(  #    z%_SelectorSocketTransport._write_readycCs6|jr dSd|_|js2|jjtjdS)NT)rrrrrr)r(rrr write_eof"s    z"_SelectorSocketTransport.write_eofcCsdS)NTr)r(rrr can_write_eof)sz&_SelectorSocketTransport.can_write_eof) r"rrrrrrrrrrrr)r!rr+s   #  r+cseZdZeZdddddfddZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ S)r5NFc stdkrtd|s0tj||}d|ddi} |rY| rY|| d<|j|| } tj|| ||| d|_||_||_ ||_ d|_ |j j d||jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availabler/Zdo_handshake_on_connectFr0r3z%r starts SSL handshake)sslr9r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr r time _on_handshake) r(rr2r,r3r-r/r0r)r*Z wrap_kwargsZsslsock start_time)r!rrr1s*          z_SelectorSslTransport.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)rrrr)r(rbrrr_wakeup_waiterUs z$_SelectorSslTransport._wakeup_waiterc%Csy|jjWntjk rH|jj|j|j|dSYntjk r||jj |j|j|dSYnt k r}z|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnhtk r}zH|jj rt j d|dd|jj|j|dSWYdd}~XnX|jjd|d|jjd|jjd |jd |_d |_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r|jj&|}t j'd ||d dS) Nz%r: SSL handshake failedrLTZcheck_hostnamez1%r: SSL handshake failed on matching the hostnamepeercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrrErrSSLWantWriteErrorrx BaseExceptionrr rr?ryr<rrreZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr )r(rrbrZdtrrrr_sb               z#_SelectorSslTransport._on_handshakecCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr9rrr?rrr r )r(rrrrs     z#_SelectorSslTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr9rrrErrrr r )r(rrrrs    z$_SelectorSslTransport.resume_readingcCsr|jr dS|jrKd|_|j|jrK|jj|j|jy|jj|j }Wnt t t j fk rYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnmX|r|jj|nSzE|jjr=tjd||jj}|r_tjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrxrrrIrrKrJrrrrr?rerrrrr r rrr<)r(rGrbrrrrrs4      #z!_SelectorSslTransport._read_readycCs|jr dS|jrTd|_|j|jp8|jsT|jj|j|j|jrAy|j j |j}Wnt t t jfk rd}Ynt jk rd}|jj|jd|_YnYtk r*}z9|jj|j|jj|j|ddSWYdd}~XnX|rA|jd|=|j|js}|jj|j|jr}|jddS)NFrTz"Fatal write error on SSL transport)rrrrrrrErrrrMrKrJrrrryrrerrrr)r(rrbrrrrs8           z"_SelectorSslTransport._write_readycCst|tttfs1tdt|j|s;dS|jrv|jtj krct j d|jd7_dS|j s|j j|j|j|j j||jdS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)rrrrrrr"rrrr rrrrxrrrr)r(rGrrrrs   z_SelectorSslTransport.writecCsdS)NFr)r(rrrrsz#_SelectorSslTransport.can_write_eof)r"rrrrrrrrrrrrrrr)r!rr5-s " ?  " # r5csgeZdZejZdddfddZddZddZddd Z d d Z S) r6Ncstj||||||_|jj|jj||jj|jj|j|j |dk r|jjt j |ddS)N) rr_addressrrrrrErrrr)r(rrr,r7r-r))r!rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss!|]\}}t|VqdS)N)r).0rGr_rrr 'szC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r(rrrr&sz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnttfk rFYn|tk rz}z|jj|WYdd}~XnHt k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrKrJrNrerror_receivedrerZdatagram_received)r(rGrarbrrrr)s "#z&_SelectorDatagramTransport._read_readycCst|tttfs1tdt|j|s;dS|jro|d|jfkrotd|jf|j r|jr|j t j krt j d|j d7_ dS|jsy7|jr|jj|n|jj||dSWnttfk r&|jj|j|jYnqtk r^}z|jj|dSWYdd}~Xn9tk r}z|j|ddSWYdd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrr"rrrrrr rrrrMsendtorKrJrrxr _sendto_readyrNrrrerrr)r(rGrarbrrrr7s<    z!_SelectorDatagramTransport.sendtocCs:x|jr|jj\}}y3|jr@|jj|n|jj||Wqttfk r|jj||fPYqt k r}z|j j |dSWYdd}~Xqt k r}z|j |ddSWYdd}~XqXqW|j|js6|jj|j|jr6|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrMrrKrJ appendleftrNrrrerrrryrrr)r(rGrarbrrrr^s*      z(_SelectorDatagramTransport._sendto_ready) r"rr collectionsdequerrrrrrrr)r!rr6s    'r6)"r__all__rr\rrrr%r ImportErrorrrrrrr r r Z coroutinesr logr rrrZ BaseEventLooprZ_FlowControlMixinZ Transportrr+r5r6rrrrs@            PK!5&&(__pycache__/futures.cpython-35.opt-2.pycnu[ ]D@sHddddddgZddlZddlZddlZddlZddlZdd lmZdd lm Z d Z d Z d Z ej jjZej jZej jZejdZGdddeZGdddZddZGdddZddZddZddZddZddddZdS)CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN)compat)eventsPENDING CANCELLEDFINISHEDc@seZdZdS)rN)__name__ __module__ __qualname__rr,/opt/alt/python35/lib64/python3.5/futures.pyrs c@sFeZdZdZddZddZd d Zd d Zd S)_TracebackLoggerloopsource_tracebackexctbcCs.|j|_|j|_||_d|_dS)N)_loopr_source_tracebackrrr)selffuturerrrr__init__Us   z_TracebackLogger.__init__cCs@|j}|dk r<d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivate[s    z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclearbs z_TracebackLogger.clearcCs|jrd}|jrQdjtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstriprcall_exception_handler)rmsgsrcrrr__del__fs   z_TracebackLogger.__del__N)rrrr)rrr __slots__rr!r"r+rrrrr!s 2   rcCst|jdo|jdk S)N_asyncio_future_blocking)hasattrrr-)objrrrrqsc@seZdZeZdZdZdZdZdZ dZ dZ ddddZ ddZ dd Zd d Zejrd d ZddZddZddZddZddZddZddZddZddZd d!Zd"d#ZejreZdS)$rNFrcCs^|dkrtj|_n ||_g|_|jjrZtjtjd|_ dS)Nr) r get_event_loopr _callbacksZ get_debugr extract_stacksys _getframer)rrrrrrs    zFuture.__init__cCs|j}t|}|s!d}dd}|dkrL||d}nn|dkrdj||d||d}n9|dkrdj||d|d||d }d |S) Nr#cSstj|fS)N)r Z_format_callback_source)callbackrrr format_cbsz,Future.__format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])r1lenformat)rcbsizer6rrrZ__format_callbackss     ) zFuture.__format_callbackscCs|jjg}|jtkrt|jdk rL|jdj|jn(tj|j}|jdj||j r|j|j |j r|j d}|jd|d|df|S)Nzexception={!r}z result={}rzcreated at %s:%srr8) _statelower _FINISHED _exceptionappendr:reprlibrepr_resultr1_Future__format_callbacksr)rinforesultframerrr _repr_infos   zFuture._repr_infocCs)|j}d|jjdj|fS)Nz<%s %s> )rIrrr%)rrFrrr__repr__s zFuture.__repr__cCsb|js dS|j}dd|jjd|d|i}|jrN|j|d<|jj|dS)Nr$z %s exception was never retrieved exceptionrr)_log_tracebackr@rrrrr()rrcontextrrrr+s      zFuture.__del__cCs3d|_|jtkrdSt|_|jdS)NFT)rMr=_PENDING _CANCELLED_schedule_callbacks)rrrrcancels    z Future.cancelcCsX|jdd}|sdSg|jddNs z/Future.remove_done_callback..)r1r9)rrWZfiltered_callbacksZ removed_countr)rWrremove_done_callbackIs zFuture.remove_done_callbackcCsJ|jtkr*tdj|j|||_t|_|jdS)Nz{}: {!r})r=rOrr:rDr?rQ)rrGrrr set_resultVs   zFuture.set_resultcCs|jtkr*tdj|j|t|trB|}t|tkr`td||_t |_|j t j rd|_ n(t|||_|jj|jjdS)Nz{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureT)r=rOrr: isinstancetype StopIteration TypeErrorr@r?rQr PY34rMrrVrrSr!)rrLrrr set_exceptionbs       zFuture.set_exceptionccs$|jsd|_|V|jS)NT)rUr-rG)rrrr__iter__zs  zFuture.__iter__) rrrrOr=rDr@rrr-rMrVrrErIrKr rbr+rRrQrTrUrGrLrXr\r]rcrdZPY35 __await__rrrrr|s6                 cCs!|jrdS|j|dS)N)rTr])ZfutrGrrr_set_result_unless_cancelleds rfcCsk|jr|j|js&dS|j}|dk rN|j|n|j}|j|dS)N)rTrRset_running_or_notify_cancelrLrcrGr]) concurrentsourcerLrGrrr_set_concurrent_future_states      rjcCsn|jrdS|jr)|jnA|j}|dk rQ|j|n|j}|j|dS)N)rTrRrLrcrGr])ridestrLrGrrr_copy_future_states      rlcst r/ttjj r/tdt r^ttjj r^tdtrsjndtrjndddfdd}fdd}j|j|dS) Nz(A future is required for source argumentz-A future is required for destination argumentcSs-t|rt||n t||dS)N)rrlrj)rotherrrr _set_states z!_chain_future.._set_statecsE|jrAdks$kr1jnjjdS)N)rTrRcall_soon_threadsafe) destination) dest_loopri source_looprr_call_check_cancels  z)_chain_future.._call_check_cancelcs?dkskr(|nj|dS)N)ro)ri)rnrqrprrrr_call_set_statesz&_chain_future.._call_set_state)rr^rhfuturesrrarrX)rirprsrtr)rnrqrprirrr _chain_futures    rvrcCsEt|r|S|dkr(tj}|j}t|||S)N)rr r0Z create_futurerv)rrZ new_futurerrrrs     )__all__concurrent.futures._baserhloggingrBr3rr#r r rOrPr?ru_baseErrorrrDEBUGZ STACK_DEBUGrrrrrfrjrlrvrrrrrs4        P     'PK!6QQ"__pycache__/streams.cpython-35.pycnu[ Yf^ @sdZdddddddgZdd lZeed rOejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d#Z GdddeZGdddeZe d d dd de ddZe d d dd de ddZeed rze d dd de dd Ze d dd de dd ZGddde jZGd ddee jZGd!ddZGd"ddZd S)$zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs6tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__4/opt/alt/python35/lib64/python3.5/asyncio/streams.pyr s  zIncompleteReadError.__init__)__name__ __module__ __qualname____doc__rrr)rrrs cs(eZdZdZfddZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager!)rrrr-szLimitOverrunError.__init__)rrrr rrr)rrr's looplimitc +s|dkrtj}td|d|}t|d||jfdd|||EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) Nr$r#csS)Nrr)protocolrrKsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr#r$kwdsreader transport_writerr)r%rr2s  )c+sKdkrtjfdd}j||||EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncs.tdd}t|d}|S)Nr$r#)rr)r+r%)client_connected_cbr$r#rrfactoryks  zstart_server..factory)rr'Z create_server)r/r(r)r#r$r*r0r)r/r$r#rrPs  c+s|dkrtj}td|d|}t|d||jfdd||EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.Nr$r#csS)Nrr)r%rrr&sz&open_unix_connection..)rr'rrZcreate_unix_connectionr)pathr#r$r*r+r,r-r.r)r%rr ws  &c+sHdkrtjfdd}j|||EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncs.tdd}t|d}|S)Nr$r#)rr)r+r%)r/r$r#rrr0s  z"start_unix_server..factory)rr'Zcreate_unix_server)r/r1r#r$r*r0r)r/r$r#rr s  c@s[eZdZdZdddZddZddZd d Zed d Z dS) FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCsF|dkrtj|_n ||_d|_d|_d|_dS)NF)rr'_loop_paused _drain_waiter_connection_lost)rr#rrrrs     zFlowControlMixin.__init__cCs<|j std|_|jjr8tjd|dS)NTz%r pauses writing)r4AssertionErrorr3 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCsr|jstd|_|jjr7tjd||j}|dk rnd|_|jsn|jddS)NFz%r resumes writing) r4r7r3r8rr9r5done set_result)rwaiterrrrresume_writings     zFlowControlMixin.resume_writingcCsud|_|jsdS|j}|dkr/dSd|_|jrHdS|dkrd|jdn |j|dS)NT)r6r4r5r;r< set_exception)rexcr=rrrconnection_losts       z FlowControlMixin.connection_lostccsn|jrtd|js"dS|j}|dksI|jsIt|jj}||_|EdHdS)NzConnection lost)r6ConnectionResetErrorr4r5 cancelledr7r3 create_future)rr=rrr _drain_helpers     zFlowControlMixin._drain_helper) rrrr rr:r>rArrErrrrr2s   r2csdeZdZdZddfddZddZfddZd d Zd d ZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs;tjd|||_d|_||_d|_dS)Nr#F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr/r#)rrrrs    zStreamReaderProtocol.__init__cCs|jj||jddk |_|jdk rt|||j|j|_|j|j|j}tj |r|jj |dS)NZ sslcontext) rF set_transportget_extra_inforIrHrr3rGr Z iscoroutineZ create_task)rr,resrrrconnection_mades   z$StreamReaderProtocol.connection_madecsa|jdk r;|dkr+|jjn|jj|tj|d|_d|_dS)N)rFfeed_eofr?rrArG)rr@)rrrrAs  z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rF feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rFrNrI)rrrr eof_receiveds  z!StreamReaderProtocol.eof_received) rrrr rrMrArQrRrr)rrrs   c@seZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCsI||_||_|dks3t|ts3t||_||_dS)N) _transport _protocol isinstancerr7_readerr3)rr,r%r+r#rrrrs   ! zStreamWriter.__init__cCsM|jjd|jg}|jdk r<|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrSrVappendjoin)rinforrr__repr__szStreamWriter.__repr__cCs|jS)N)rS)rrrrr,!szStreamWriter.transportcCs|jj|dS)N)rSwrite)rrPrrrr\%szStreamWriter.writecCs|jj|dS)N)rS writelines)rrPrrrr](szStreamWriter.writelinescCs |jjS)N)rS write_eof)rrrrr^+szStreamWriter.write_eofcCs |jjS)N)rS can_write_eof)rrrrr_.szStreamWriter.can_write_eofcCs |jjS)N)rSclose)rrrrr`1szStreamWriter.closeNcCs|jj||S)N)rSrK)rnamedefaultrrrrK4szStreamWriter.get_extra_infoccsi|jdk r0|jj}|dk r0||jdk rS|jjrSdV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rV exceptionrSZ is_closingrTrE)rr@rrrdrain7s  zStreamWriter.drain)rrrr rr[propertyr,r\r]r^r_r`rKrrdrrrrr s        c@s0eZdZedddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZedddZed'ddZed d!Zejred"d#Zed$d%Zejr,d&d#ZdS)(rNcCs|dkrtd||_|dkr?tj|_n ||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr'r3 bytearray_buffer_eof_waiter _exceptionrSr4)rr$r#rrrrRs          zStreamReader.__init__cCsdg}|jr,|jdt|j|jrB|jd|jtkre|jd|j|jr|jd|j|jr|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rW) rirXrrjrg_DEFAULT_LIMITrkrlrSr4rY)rrZrrrr[es          zStreamReader.__repr__cCs|jS)N)rl)rrrrrcwszStreamReader.exceptioncCsD||_|j}|dk r@d|_|js@|j|dS)N)rlrkrCr?)rr@r=rrrr?zs      zStreamReader.set_exceptioncCs;|j}|dk r7d|_|js7|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rkrCr<)rr=rrr_wakeup_waiters     zStreamReader._wakeup_waitercCs(|jdkstd||_dS)NzTransport already set)rSr7)rr,rrrrJszStreamReader.set_transportcCs;|jr7t|j|jkr7d|_|jjdS)NF)r4rrirgrSresume_reading)rrrr_maybe_resume_transports! z$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rjro)rrrrrNs zStreamReader.feed_eofcCs|jo|j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rjri)rrrrat_eofszStreamReader.at_eofc Cs|j std|s dS|jj||j|jdk r|j rt|jd|jkry|jj Wnt k rd|_Yn Xd|_dS)Nzfeed_data after feed_eofrT) rjr7riextendrorSr4rrgZ pause_readingNotImplementedError)rrPrrrrOs   zStreamReader.feed_datac cs|jdk rtd||j s5td|jrTd|_|jj|jj|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzH%s() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF) rk RuntimeErrorrjr7r4rSrpr3rD)rZ func_namerrr_wait_for_datas     zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rX}z |jSWYdd}~Xntk r}za|jj||jr|jd|j|=n |jj|j t |j dWYdd}~XnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. s Nr) r readuntilrrrri startswithr!clearrqrfargs)rsepseplenlineerrrreadlines   &zStreamReader.readlines ccsYt|}|dkr$td|jdk r<|jd}xt|j}|||kr|jj||}|dkrP|d|}||jkrtd||jrt|j}|jj t |d|j dEdHqEW||jkrtd||jd||}|jd||=|j t|S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrwz2Separator is found, but chunk is longer than limit) rrfrlrifindrgrrjbytesryrrvrq)rZ separatorr|offsetZbuflenZisepchunkrrrrws:          zStreamReader.readuntilr ccs|jdk r|j|dkr(dS|dkryg}x/|j|jEdH}|s[P|j|q=Wdj|S|j r|j r|jdEdHt|jd|}|jd|=|j |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrread) rlrrgrXrYrirjrvrrq)rnZblocksblockrPrrrrJs$     zStreamReader.readccs |dkrtd|jdk r0|j|dkr@dSx_t|j|kr|jrt|j}|jjt|||jdEdHqCWt|j|krt|j}|jjn)t|jd|}|jd|=|j |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rfrlrrirjrryrrvrq)rrZ incompleterPrrrr}s&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs'|jEdH}|dkr#t|S)Nr)rStopAsyncIteration)rvalrrr __anext__s zStreamReader.__anext__cCs|S)Nr)rrrrrsr)rrrrnrr[rcr?rorJrqrNrrrOrrvrrwrrr ZPY35rrZPY352rrrrrPs,          [2*  i)r __all__Zsockethasattrrsr r rrrlogrrnEOFErrorr Exceptionrrrr r ZProtocolr2rrrrrrrsB      " B3GPK!"q??"__pycache__/futures.cpython-35.pycnu[ YfD@sNdZddddddgZddlZddlZddlZddlZddlZd d lm Z d d lm Z d Z d Z dZ ejjjZejjZejjZejd ZGdddeZGdddZddZGdddZddZddZddZddZddddZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN)compat)eventsZPENDINGZ CANCELLEDZFINISHEDc@seZdZdZdS)rz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__rr4/opt/alt/python35/lib64/python3.5/asyncio/futures.pyrs c@sLeZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs.|j|_|j|_||_d|_dS)N)_loopr_source_tracebackrrr)selffuturerrrr__init__Us   z_TracebackLogger.__init__cCs@|j}|dk r<d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivate[s    z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclearbs z_TracebackLogger.clearcCs|jrd}|jrQdjtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstriprcall_exception_handler)rmsgsrcrrr__del__fs   z_TracebackLogger.__del__N)rrrr) r r r r __slots__rrr r)rrrrr!s 0   rcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattrrr+)objrrrrqsc@s$eZdZdZeZdZdZdZdZ dZ dZ dZ ddddZ ddZd d Zd d Zejrd dZddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zejr eZ dS)%raThis class is *almost* compatible with concurrent.futures.Future. Differences: - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon_threadsafe(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFrcCs^|dkrtj|_n ||_g|_|jjrZtjtjd|_ dS)zInitialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r get_event_loopr _callbacksZ get_debugr extract_stacksys _getframer)rrrrrrs    zFuture.__init__cCs|j}t|}|s!d}dd}|dkrL||d}nn|dkrdj||d||d}n9|dkrdj||d|d||d }d |S) Nr!cSstj|fS)N)r Z_format_callback_source)callbackrrr format_cbsz,Future.__format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])r/lenformat)rcbsizer4rrrZ__format_callbackss     ) zFuture.__format_callbackscCs|jjg}|jtkrt|jdk rL|jdj|jn(tj|j}|jdj||j r|j|j |j r|j d}|jd|d|df|S)Nzexception={!r}z result={}rzcreated at %s:%srr6) _statelower _FINISHED _exceptionappendr8reprlibrepr_resultr/_Future__format_callbacksr)rinforesultframerrr _repr_infos   zFuture._repr_infocCs)|j}d|jjdj|fS)Nz<%s %s> )rGrr r#)rrDrrr__repr__s zFuture.__repr__cCsb|js dS|j}dd|jjd|d|i}|jrN|j|d<|jj|dS)Nr"z %s exception was never retrieved exceptionrr)_log_tracebackr>rr rrr&)rrcontextrrrr)s      zFuture.__del__cCs3d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)rKr;_PENDING _CANCELLED_schedule_callbacks)rrrrcancels    z Future.cancelcCsX|jdd}|sdSg|jddrB)rrrrrEs     z Future.resultcCse|jtkrt|jtkr0tdd|_|jdk r^|jjd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.FN) r;rNrr=rrKrTr r>)rrrrrJ)s    zFuture.exceptioncCs9|jtkr%|jj||n|jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r;rMrrQr/r?)rfnrrradd_done_callback;szFuture.add_done_callbackcsRfdd|jD}t|jt|}|rN||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs"g|]}|kr|qSrr).0f)rUrr Ns z/Future.remove_done_callback..N)r/r7)rrUZfiltered_callbacksZ removed_countr)rUrremove_done_callbackIs zFuture.remove_done_callbackcCsJ|jtkr*tdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r;rMrr8rBr=rO)rrErrr set_resultVs   zFuture.set_resultcCs|jtkr*tdj|j|t|trB|}t|tkr`td||_t |_|j t j rd|_ n(t|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r;rMrr8 isinstancetype StopIteration TypeErrorr>r=rOr PY34rKrrTrrQr)rrJrrr set_exceptionbs       zFuture.set_exceptionccs<|jsd|_|V|js2td|jS)NTz"yield from wasn't used with future)rSr+AssertionErrorrE)rrrr__iter__zs   zFuture.__iter__)!r r r rrMr;rBr>rrr+rKrTrrCrGrIr r`r)rPrOrRrSrErJrVrZr[rarcZPY35 __await__rrrrr|s8                 cCs!|jrdS|j|dS)z?Helper setting the result only if the future was not cancelled.N)rRr[)ZfutrErrr_set_result_unless_cancelleds recCs}|jst|jr(|j|js8dS|j}|dk r`|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N) rSrbrRrPZset_running_or_notify_cancelrJrarEr[) concurrentsourcerJrErrr_set_concurrent_future_states      rhcCs|jst|jr"dS|j s5t|jrN|jnA|j}|dk rv|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rSrbrRrPrJrarEr[)rgdestrJrErrr_copy_future_states      rjcst r/ttjj r/tdt r^ttjj r^tdtrsjndtrjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs-t|rt||n t||dS)N)rrjrh)rotherrrr _set_states z!_chain_future.._set_statecsE|jrAdks$kr1jnjjdS)N)rRrPcall_soon_threadsafe) destination) dest_looprg source_looprr_call_check_cancels  z)_chain_future.._call_check_cancelcs?dkskr(|nj|dS)N)rm)rg)rlrornrprr_call_set_statesz&_chain_future.._call_set_state)rr\rffuturesrr_rrV)rgrnrqrrr)rlrornrgrpr _chain_futures    rtrcCsot|r|St|tjjs:tdj||dkrRtj}|j }t |||S)z&Wrap concurrent.futures.Future object.z/concurrent.futures.Future is expected, got {!r}N) rr\rfrsrrbr8r r.Z create_futurert)rrZ new_futurerrrrs     )r__all__Zconcurrent.futures._baserfZloggingr@r1rr!r r rMrNr=rsZ_baseErrorrrDEBUGZ STACK_DEBUGrrrrrerhrjrtrrrrrs6        P     'PK!Ek@@0__pycache__/selector_events.cpython-35.opt-1.pycnu[ Yf @sdZdgZddlZddlZddlZddlZddlZddlZyddlZWne k rdZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZeedrLddZn ddZGddde jZGdddejejZGdddeZGdddeZ GdddeZ!dS)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc CsAy|j|}Wntk r+dSYnXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyrZd?d@Z edAdBZ!dCdDZ"dEdFZ#dGdHZ$dIdJZ%dKdLZ&dMdNZ'dOdPZ(S)QrzJSelector event loop. See events.EventLoop for API specification. Ncsatj|dkr%tj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)r!rrr<s     zBaseSelectorEventLoop.__init__extraservercCst||||||S)N)_SelectorSocketTransport)r(rprotocolwaiterr)r*rrr_make_socket_transportFsz,BaseSelectorEventLoop._make_socket_transport server_sideFserver_hostnamec Cs{tjs:|j||||d|d|d|d|Stj||||||} t||| d|d|| jS)Nr/r0r)r*)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr+Z_app_transport) r(rawsockr, sslcontextr-r/r0r)r*Z ssl_protocolrrr_make_ssl_transportKs     z)BaseSelectorEventLoop._make_ssl_transportc Cs"t||||||||| S)N)_SelectorSslTransport) r(r2r,r3r-r/r0r)r*rrrr1Zsz0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r(rr,addressr-r)rrr_make_datagram_transportds z.BaseSelectorEventLoop._make_datagram_transportcsh|jrtd|jr(dS|jtj|jdk rd|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser#)r()r!rrr<is      zBaseSelectorEventLoop.closecCs tdS)N)NotImplementedError)r(rrr _socketpairtsz!BaseSelectorEventLoop._socketpaircCsU|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor<_csock _internal_fds)r(rrrr;ws     z&BaseSelectorEventLoop._close_self_pipecCsg|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r>r@rB setblockingrC _add_readerrA_read_from_self)r(rrrr$s z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r(datarrr_process_self_datasz(BaseSelectorEventLoop._process_self_datac Cs_xXy*|jjd}|sP|j|Wqtk rDwYqtk rVPYqXqWdS)Ni)r@recvrHInterruptedErrorBlockingIOError)r(rGrrrrFs  z%BaseSelectorEventLoop._read_from_selfc Cs[|j}|dk rWy|jdWn.tk rV|jrRtjdddYnXdS)Nsz3Fail to write a null byte into the self-pipe socketexc_infoT)rBsendOSError_debugr r )r(Zcsockrrr_write_to_selfs     z$BaseSelectorEventLoop._write_to_selfdcCs,|j|j|j|||||dS)N)rErA_accept_connection)r(protocol_factoryrr3r*backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cs[xTt|D]F}yB|j\}}|jrGtjd||||jdWntttfk rvdSYq t k r} z| j t j t j t j t jfkr |jddd| d|i|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFmessagez&socket.accept() out of system resource exceptionrpeername)rangeacceptrOr r rDrKrJConnectionAbortedErrorrNerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr?rAZ call_laterrZACCEPT_RETRY_DELAYrU_accept_connection2Z create_task) r(rSrr3r*rT_connaddrexcr)rZrrrrRs4         z(BaseSelectorEventLoop._accept_connectionc cs$d}d}y|}|j}|rZ|j|||d|ddd|d|}n$|j||d|d|d|}y |EdHWn|jYnXWnytk r} zY|jr ddd| i} |dk r|| d <|dk r|| d <|j| WYdd} ~ XnXdS) Nr-r/Tr)r*rVz3Error on transport creation for incoming connectionrWr, transport) create_futurer4r.r< ExceptionrOr]) r(rSr`r)r3r*r,rcr-rbcontextrrrr^s4            z)BaseSelectorEventLoop._accept_connection2c CsNy|j|}Wntk r%Yn%X|jsJtdj||dS)Nz.File descriptor {!r} is used by transport {!r})r'r is_closingr9format)r(rrcrrr_ensure_fd_no_transports  z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tj|dfYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandler#rrregisterr EVENT_READrGmodifycancel) r(rcallbackargshandlermaskreaderwriterrrrrEs    z!BaseSelectorEventLoop._add_readerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r:r#rrrrGr rm unregisterrnro)r(rrrsrtrurrrr?s     z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tjd|fYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rjrrkr#rrrlr EVENT_WRITErGrnro) r(rrprqrrrrsrtrurrr _add_writer(s    z!BaseSelectorEventLoop._add_writerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r:r#rrrrGr rwrvrnro)r(rrrsrtrurrr_remove_writer7s     z$BaseSelectorEventLoop._remove_writercGs |j||j|||S)zAdd a reader callback.)rirE)r(rrprqrrr add_readerNs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rir?)r(rrrr remove_readerSs z#BaseSelectorEventLoop.remove_readercGs |j||j|||S)zAdd a writer callback..)rirx)r(rrprqrrr add_writerXs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)riry)r(rrrr remove_writer]s z#BaseSelectorEventLoop.remove_writercCsM|jr'|jdkr'td|j}|j|d|||S)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. This method is a coroutine. rzthe socket must be non-blockingF)rO gettimeout ValueErrorrd _sock_recv)r(rnfutrrr sock_recvbs   zBaseSelectorEventLoop.sock_recvcCs|j}|r|j||jr/dSy|j|}Wnhttfk r{|j||j|d||Yn?tk r}z|j |WYdd}~XnX|j |dS)NT) rAr{ cancelledrIrKrJrzrre set_exception set_result)r(r registeredrrrrGrbrrrrqs   # z BaseSelectorEventLoop._sock_recvcCsc|jr'|jdkr'td|j}|rR|j|d||n |jd|S)aSend data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. This method is a coroutine. rzthe socket must be non-blockingFN)rOr~rrd _sock_sendallr)r(rrGrrrr sock_sendalls    z"BaseSelectorEventLoop.sock_sendallcCs|j}|r|j||jr/dSy|j|}WnSttfk rbd}Yn6tk r}z|j|dSWYdd}~XnX|t|kr|j dn5|r||d}|j ||j |d||dS)NrT) rAr}rrMrKrJrerlenrr|r)r(rrrrGrrrbrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr'|jdkr'tdttd sI|jtjkrtj|d|jd|j d|}|j s|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIXrrloopN)rOr~rhasattrrrrrZ_ensure_resolvedrdoneresultrd _sock_connect)r(rr7Zresolvedr_rrrr sock_connects "!   z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnttfk ro|jtj|j||j||j |||Yn?t k r}z|j |WYdd}~XnX|j ddS)N) rAZconnectrKrJZadd_done_callback functoolspartial_sock_connect_doner|_sock_connect_cbrerr)r(rrr7rrbrrrrs   z#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)r})r(rrrrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jrdSy>|jtjtj}|dkrMt|d|fWnIttfk rhYn?tk r}z|j |WYdd}~XnX|j ddS)NrzConnect call failed %s) rZ getsockoptrZ SOL_SOCKETZSO_ERRORrNrKrJrerr)r(rrr7errrbrrrrs   z&BaseSelectorEventLoop._sock_connect_cbcCsJ|jr'|jdkr'td|j}|j|d||S)a|Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. This method is a coroutine. rzthe socket must be non-blockingF)rOr~rrd _sock_accept)r(rrrrr sock_accepts   z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr/dSy#|j\}}|jdWnettfk r|j||j|d|YnEt k r}z|j |WYdd}~XnX|j ||fdS)NFT) rAr{rrZrDrKrJrzrrerr)r(rrrrr`r7rbrrrrs     z"BaseSelectorEventLoop._sock_acceptcCsx|D]\}}|j|j}\}}|tj@rk|dk rk|jr^|j|n |j||tj@r|dk r|jr|j|q|j|qWdS)N) fileobjrGr rmZ _cancelledr?Z _add_callbackrwry)r(Z event_listrrsrrtrurrr_process_events s   z%BaseSelectorEventLoop._process_eventscCs!|j|j|jdS)N)r?rAr<)r(rrrr _stop_servingsz#BaseSelectorEventLoop._stop_serving))r" __module__ __qualname____doc__rr.r4r1r8r<r>r;r$rHrFrPrUrRr r^rirEr?rxryrzr{r|r}rrrrrrrrrrrrrr)r!rr6sV          (#                  cseZdZdZeZdZddfddZddZdd Z d d Z d d Z ddZ ddZ ejrddZdddZddZddZddZS)_SelectorTransportiNc stj||||jd<|j|jdz<%s> )r!r"rappendrr_loopr:rr#r rmrwget_write_buffer_sizejoin)r(inforstatebufsizerrr__repr__>s*        z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r(rrrabortZsz_SelectorTransport.abortcCs ||_dS)N)r)r(r,rrr set_protocol]sz_SelectorTransport.set_protocolcCs|jS)N)r)r(rrr get_protocol`sz_SelectorTransport.get_protocolcCs|jS)N)r)r(rrrrgcsz_SelectorTransport.is_closingcCsn|jr dSd|_|jj|j|jsj|jd7_|jj|j|jj|jddS)NTr) rrr?rrrry call_soon_call_connection_lost)r(rrrr<fs   z_SelectorTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningr<)r(rrr__del__tsz_SelectorTransport.__del__zFatal error on transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srLTrVrWrcr,) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr r r]rr)r(rbrVrrr _fatal_errorys z_SelectorTransport._fatal_errorcCs|jr dS|jr6|jj|jj|j|js[d|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrryrrr?rr)r(rbrrrrs     z_SelectorTransport._force_closec Csuz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rp|jd|_XdS)N)rrZconnection_lostrr<rrZ_detach)r(rbr*rrrrs        z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r(rrrrsz(_SelectorTransport.get_write_buffer_sizei)r"rrmax_size bytearrayrrrrrrrrgr<rZPY34rrrrrrr)r!rrs         rcseZdZdddfddZddZddZdd Zd d Zd d ZddZ ddZ S)r+Ncstj|||||d|_d|_t|j|jj|jj ||jj|jj |j |j |dk r|jjt j|ddS)NF)rr_eof_pausedrrrrrconnection_maderEr _read_readyr_set_result_unless_cancelled)r(rrr,r-r)r*)r!rrrs    z!_SelectorSocketTransport.__init__cCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr9rrr?rrr r )r(rrr pause_readings     z&_SelectorSocketTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr9rrrErrrr r )r(rrrresume_readings    z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnLttfk r@Yntk rt}z|j|dWYdd}~XnnX|r|jj |nT|j j rt j d||jj}|r|j j|jn |jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrIrrKrJrerr data_receivedrrr r eof_receivedr?rr<)r(rGrb keep_openrrrrs  #z$_SelectorSocketTransport._read_readycCsNt|tttfs1tdt|j|jrFtd|sPdS|j r|j t j krxt j d|j d7_ dS|js0y|jj|}WnPttfk rYnStk r}z|j|ddSWYdd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrorrr"rr9rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrMrKrJrerrrxr _write_readyextend_maybe_pause_protocol)r(rGrrbrrrwrites4     z_SelectorSocketTransport.writecCs |jr dSy|jj|j}Wnlttfk r@Yntk r}z5|jj|j |jj |j |dWYdd}~XnrX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrMrrKrJrerryrrr_maybe_resume_protocolrrrshutdownrSHUT_WR)r(rrbrrrr s&  #    z%_SelectorSocketTransport._write_readycCs6|jr dSd|_|js2|jjtjdS)NT)rrrrrr)r(rrr write_eof"s    z"_SelectorSocketTransport.write_eofcCsdS)NTr)r(rrr can_write_eof)sz&_SelectorSocketTransport.can_write_eof) r"rrrrrrrrrrrr)r!rr+s   #  r+cseZdZeZdddddfddZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ S)r5NFc stdkrtd|s0tj||}d|ddi} |rY| rY|| d<|j|| } tj|| ||| d|_||_||_ ||_ d|_ |j j d||jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availabler/Zdo_handshake_on_connectFr0r3z%r starts SSL handshake)sslr9r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr r time _on_handshake) r(rr2r,r3r-r/r0r)r*Z wrap_kwargsZsslsock start_time)r!rrr1s*          z_SelectorSslTransport.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)rrrr)r(rbrrr_wakeup_waiterUs z$_SelectorSslTransport._wakeup_waiterc%Csy|jjWntjk rH|jj|j|j|dSYntjk r||jj |j|j|dSYnt k r}z|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnhtk r}zH|jj rt j d|dd|jj|j|dSWYdd}~XnX|jjd|d|jjd|jjd |jd |_d |_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r|jj&|}t j'd ||d dS) Nz%r: SSL handshake failedrLTZcheck_hostnamez1%r: SSL handshake failed on matching the hostnamepeercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrrErrSSLWantWriteErrorrx BaseExceptionrr rr?ryr<rrreZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr )r(rrbrZdtrrrr_sb               z#_SelectorSslTransport._on_handshakecCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr9rrr?rrr r )r(rrrrs     z#_SelectorSslTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr9rrrErrrr r )r(rrrrs    z$_SelectorSslTransport.resume_readingcCsr|jr dS|jrKd|_|j|jrK|jj|j|jy|jj|j }Wnt t t j fk rYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnmX|r|jj|nSzE|jjr=tjd||jj}|r_tjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrxrrrIrrKrJrrrrr?rerrrrr r rrr<)r(rGrbrrrrrs4      #z!_SelectorSslTransport._read_readycCs|jr dS|jrTd|_|j|jp8|jsT|jj|j|j|jrAy|j j |j}Wnt t t jfk rd}Ynt jk rd}|jj|jd|_YnYtk r*}z9|jj|j|jj|j|ddSWYdd}~XnX|rA|jd|=|j|js}|jj|j|jr}|jddS)NFrTz"Fatal write error on SSL transport)rrrrrrrErrrrMrKrJrrrryrrerrrr)r(rrbrrrrs8           z"_SelectorSslTransport._write_readycCst|tttfs1tdt|j|s;dS|jrv|jtj krct j d|jd7_dS|j s|j j|j|j|j j||jdS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)rrrrrrr"rrrr rrrrxrrrr)r(rGrrrrs   z_SelectorSslTransport.writecCsdS)NFr)r(rrrrsz#_SelectorSslTransport.can_write_eof)r"rrrrrrrrrrrrrrr)r!rr5-s " ?  " # r5csgeZdZejZdddfddZddZddZddd Z d d Z S) r6Ncstj||||||_|jj|jj||jj|jj|j|j |dk r|jjt j |ddS)N) rr_addressrrrrrErrrr)r(rrr,r7r-r))r!rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss!|]\}}t|VqdS)N)r).0rGr_rrr 'szC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r(rrrr&sz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnttfk rFYn|tk rz}z|jj|WYdd}~XnHt k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrKrJrNrerror_receivedrerZdatagram_received)r(rGrarbrrrr)s "#z&_SelectorDatagramTransport._read_readycCst|tttfs1tdt|j|s;dS|jro|d|jfkrotd|jf|j r|jr|j t j krt j d|j d7_ dS|jsy7|jr|jj|n|jj||dSWnttfk r&|jj|j|jYnqtk r^}z|jj|dSWYdd}~Xn9tk r}z|j|ddSWYdd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrr"rrrrrr rrrrMsendtorKrJrrxr _sendto_readyrNrrrerrr)r(rGrarbrrrr7s<    z!_SelectorDatagramTransport.sendtocCs:x|jr|jj\}}y3|jr@|jj|n|jj||Wqttfk r|jj||fPYqt k r}z|j j |dSWYdd}~Xqt k r}z|j |ddSWYdd}~XqXqW|j|js6|jj|j|jr6|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrMrrKrJ appendleftrNrrrerrrryrrr)r(rGrarbrrrr^s*      z(_SelectorDatagramTransport._sendto_ready) r"rr collectionsdequerrrrrrrr)r!rr6s    'r6)"r__all__rr\rrrr%r ImportErrorrrrrrr r r Z coroutinesr logr rrrZ BaseEventLooprZ_FlowControlMixinZ Transportrr+r5r6rrrrs@            PK!fJ'J'*__pycache__/base_subprocess.cpython-35.pycnu[ Yf]#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercsEeZdZddfddZddZddZdd Zd d Zd d ZddZ e j rddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZS)0BaseSubprocessTransportNc  stj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkrd|j d<|tjkrd|j d<|tjkrd|j d ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,      z BaseSubprocessTransport.__repr__cKs tdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x3|jjD]"}|dkr;q&|jjq&W|jdk r|jdkr|jjdkr|jj rt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs%||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transportsz*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procsz#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rJr send_signal)r)signalr/r/r0rKs z#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rJr terminate)r)r/r/r0rMs z!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rJrr?)r)r/r/r0r?s zBaseSubprocessTransport.killc #syLj}j}|jdk r]|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<jdk st |j j j x'jD]\}}|j ||q"Wd_WnKt k r}z+|dk r|j r|j|WYdd}~Xn'X|dk r|j r|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rOsrcs tdS)Nr )rPr/)r)r/r0rOsr )rrr Zconnect_write_piperr Zconnect_read_piperrAssertionError call_soonrconnection_made Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s8       z&BaseSubprocessTransport._connect_pipescGs?|jdk r(|jj||fn|jj||dS)N)rr4rrR)r)cbrZr/r/r0_callszBaseSubprocessTransport._callcCs'|j|jj|||jdS)N)r]rZpipe_connection_lost _try_finish)r)rHr[r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r]rZpipe_data_received)r)rHrZr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|dk st||jdks6t|j|jjrXtjd||||_|jjdkr||j_|j|j j |j x*|j D]}|j s|j|qWd|_ dS)Nz%r exited with return code %r)rQrrr#rr8r returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0_process_exiteds      z'BaseSubprocessTransport._process_exitedccs>|jdk r|jS|jj}|jj||EdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr4)r)r,r/r/r0_waits zBaseSubprocessTransport._waitcCse|j st|jdkr#dStdd|jjDrad|_|j|jddS)Ncss$|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rrQrallrr>r]_call_connection_lost)r)r/r/r0r^s  z#BaseSubprocessTransport._try_finishc Cs7z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r[r/r/r0ris   z-BaseSubprocessTransport._call_connection_lost)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rErFrGrIrJrKrMr?rr(r]r_r`rbrcr^rir/r/)r.r0r s0 )               %     rc@sXeZdZddZddZddZddZd d Zd d Zd S)rNcCs(||_||_d|_d|_dS)NF)rWrHr6rd)r)rWrHr/r/r0rs   z!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rS sz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rHr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs,d|_|jj|j|d|_dS)NT)rdrWr_rH)r)r[r/r/r0rjs z(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rWr pause_writing)r)r/r/r0rmsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rWrresume_writing)r)r/r/r0rnsz'WriteSubprocessPipeProto.resume_writingN) r3rkrlrrSr9rjrmrnr/r/r/r0rNs      rNc@seZdZddZdS)rPcCs|jj|j|dS)N)rWr`rH)r)rZr/r/r0 data_received#sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlror/r/r/r0rP s rP)rrrBrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrNZProtocolrPr/r/r/r0s   PK!+4%4%&__pycache__/locks.cpython-35.opt-2.pycnu[ ]:@sdddddgZddlZddlmZdd lmZdd lmZdd lmZGd d d ZGdddZ Gddde Z GdddZ Gddde Z Gddde Z Gddde ZdS)LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s4eZdZddZddZddZdS)_ContextManagercCs ||_dS)N)_lock)selflockr*/opt/alt/python35/lib64/python3.5/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gs"z|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname__rrrrrrrr s   r c@sseZdZddZddZeddZejroddZ ed d Z ed d Z d S)_ContextManagerMixincCstddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs|jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rrr#rrrrr+s     rcsjeZdZddddZfddZddZed d Zd d Zd dZ S)rloopNcCsCtj|_d|_|dk r0||_ntj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr$rrrrs    z Lock.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r(r'formatlen)rresextra) __class__rrr/s  z Lock.__repr__cCs|jS)N)r()rrrrr+sz Lock.lockedccs|j r3tdd|jDr3d|_dS|jj}|jj|zLy|EdHd|_dSWn+tjk r|js|jYnXWd|jj |XdS)Ncss|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..T) r(allr'r) create_futureappendr CancelledError_wake_up_firstremove)rfutrrrrs&      z Lock.acquirecCs/|jrd|_|jn tddS)NFzLock is not acquired.)r(r=r)rrrrrs   z Lock.releasecCs2x+|jD] }|js |jdPq WdS)NT)r'done set_result)rr?rrrr=s  zLock._wake_up_first) rrrrr/r+r rrr=rr)r4rrYs 6  csjeZdZddddZfddZddZd d Zd d Zed dZ S)rr$NcCsCtj|_d|_|dk r0||_ntj|_dS)NF)r%r&r'_valuer)r r*)rr$rrrrs    zEvent.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr-)r.r/rBr'r0r1)rr2r3)r4rrr/s  zEvent.__repr__cCs|jS)N)rB)rrrris_setsz Event.is_setcCsC|js?d|_x*|jD]}|js|jdqWdS)NT)rBr'r@rA)rr?rrrrCs    z Event.setcCs d|_dS)NF)rB)rrrrclearsz Event.clearc csU|jr dS|jj}|jj|z|EdHdSWd|jj|XdS)NT)rBr)r:r'r;r>)rr?rrrwaits  z Event.wait) rrrrr/rDrCrEr rFrr)r4rrs   csveZdZdddddZfddZeddZed d Zd d d ZddZ S)rNr$cCs|dk r||_ntj|_|dkrHtd|j}n|j|jk rftd||_|j|_|j|_|j|_t j |_ dS)Nr$z"loop argument must agree with lock) r)r r*r ValueErrorr r+rrr%r&r')rrr$rrrrs        zCondition.__init__csetj}|jr!dnd}|jrKdj|t|j}dj|dd|S)Nr+r,z {},waiters:{}z <{} [{}]>rr-)r.r/r+r'r0r1)rr2r3)r4rrr/2s  zCondition.__repr__ccs|jstd|jzH|jj}|jj|z|EdHdSWd|jj|XWdx0y|jEdHPWqpt j k rYqpXqpWXdS)Nzcannot wait on un-acquired lockT) r+rrr)r:r'r;r>rr r<)rr?rrrrF9s    zCondition.waitccs2|}x"|s-|jEdH|}q W|S)N)rF)r predicateresultrrrwait_for[s    zCondition.wait_forrcCsf|jstdd}xA|jD]6}||kr;P|js(|d7}|jdq(WdS)Nz!cannot notify on un-acquired lockrrF)r+rr'r@rA)rnidxr?rrrnotifyis     zCondition.notifycCs|jt|jdS)N)rMr1r')rrrr notify_allszCondition.notify_all) rrrrr/r rFrJrMrNrr)r4rrs "csmeZdZdddddZfddZdd Zd d Zed d ZddZ S)rrr$NcCs[|dkrtd||_tj|_|dk rH||_ntj|_dS)Nrz$Semaphore initial value must be >= 0)rGrBr%r&r'r)r r*)rvaluer$rrrrs     zSemaphore.__init__csqtj}|jr!dndj|j}|jrWdj|t|j}dj|dd|S)Nr+zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr-)r.r/r+r0rBr'r1)rr2r3)r4rrr/s   zSemaphore.__repr__cCs@x9|jr;|jj}|js|jddSqWdS)N)r'popleftr@rA)rwaiterrrr _wake_up_nexts    zSemaphore._wake_up_nextcCs |jdkS)Nr)rB)rrrrr+szSemaphore.lockedc csx}|jdkr|jj}|jj|y |EdHWq|j|jdkrt|j rt|jYqXqW|jd8_dS)NrrT)rBr)r:r'r;cancelr5rR)rr?rrrrs     zSemaphore.acquirecCs|jd7_|jdS)Nr)rBrR)rrrrrszSemaphore.release) rrrrr/rRr+r rrrr)r4rrs    cs=eZdZdddfddZfddZS)rrr$Ncs#||_tj|d|dS)Nr$) _bound_valuer.r)rrOr$)r4rrrs zBoundedSemaphore.__init__cs/|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rBrTrGr.r)r)r4rrrs zBoundedSemaphore.release)rrrrrrr)r4rrs )__all__r%rr r Z coroutinesr r rrrrrrrrrrs .zBuMPK! .__pycache__/windows_utils.cpython-35.opt-1.pycnu[ Yf@sJdZddlZejdkr-edddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdd dZd d ddde ddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces Nwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Csk|tjkrd}n$|tjkr0d}n td|tjkrWtd|dkrotdtj|||}z|j|df|jd|jdd \}}tj|||}yb|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r:/opt/alt/python35/lib64/python3.5/asyncio/windows_utils.pyr%s8            duplexF overlappedTbufsizec Cstjddtjttf}|rWtj}tjtj B}||}}ntj }tj }d|}}|tj O}|dr|tj O}|drtj }nd}d} } ytj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fSWn=| dk rftj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.prefixz\\.\pipe\python-pipe-%d-%d-rrNrT)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@                 c@seZdZdZddZddZeddZdd Zd e j d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs9|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r# __class____name__)r$r%rrr__repr__szPipeHandle.__repr__cCs|jS)N)r#)r$rrrr%szPipeHandle.handlecCs"|jdkrtd|jS)NzI/O operatioon on closed pipe)r#r )r$rrrfilenos zPipeHandle.filenor!cCs)|jdk r%||jd|_dS)N)r#)r$r!rrrrs zPipeHandle.closecCs1|jdk r-tjd|t|jdS)Nz unclosed %r)r#warningswarnResourceWarningr)r$rrr__del__szPipeHandle.__del__cCs|S)Nr)r$rrr __enter__szPipeHandle.__enter__cCs|jdS)N)r)r$tvtbrrr__exit__szPipeHandle.__exit__N)r) __module__ __qualname____doc__r&r*propertyr%r+r r!rr/r0r4rrrrrs      cs1eZdZdZdddfddZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc sd}}}d} } } |tkr[tdd dd\} } tj| tj}n|}|tkrtdd \} } tj| d}n|}|tkrtdd \} }tj|d}n|tkr|}n|}zy)tj|d|d|d||Wn>x0| | | fD]}|dk r0t j |q0WYnRX| dk rvt | |_ | dk rt | |_ | dk rt | |_Wd|tkrtj||tkrtj||tkrtj|XdS) NrFTrrstdinstdoutstderr)FT)TF)TF)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr&r r!rr9r:r;r)r$argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r(rrr&sH              zPopen.__init__)r)r5r6r7r&rr)r(rrs )TT)r7sysplatform ImportErrorr itertoolsr<rr subprocessrr,__all__ZBUFSIZErr>countrhasattrrr r rrrrrrrs,              .0,PK!c&__pycache__/unix_events.cpython-35.pycnu[ Yf @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkrbedddZy ejZWnek rddZYnXGdddejZ e!edrddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%r>ej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python35/lib64/python3.5/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.src seZdZdZdfddZddZfddZd d Zd d Zd dZ ddZ ddZ ddddZ ddddZ edddZddZeddddddddZedddd d!ddd"d#ZS)$_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7sz_UnixSelectorEventLoop.__init__cCs tjS)N)socketZ socketpair)r rrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs8tjx$t|jD]}|j|qWdS)N)rcloselistrremove_signal_handler)r sig)r"rrr%>s z_UnixSelectorEventLoop.closecCs+x$|D]}|sq|j|qWdS)N)_handle_signal)r datarrrr_process_self_dataCs z)_UnixSelectorEventLoop._process_self_datac+Gstj|stj|r*td|j||jytj|jj Wn=t t fk r}zt t |WYdd}~XnXtj|||}||j|rrrr)ws   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y|j|=Wntk r3dSYnX|tjkrOtj}n tj}ytj||WnRtk r}z2|jtj krt dj |nWYdd}~XnX|jsytj dWn;t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr,)r.rKeyErrorr/SIGINTdefault_int_handlerSIG_DFLr3r8r9r4r:r0r2rr7)r r(Zhandlerr=rrrr's(      #z,_UnixSelectorEventLoop.remove_signal_handlercCsbt|ts$tdj|d|ko>tjkns^tdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr-r:r/NSIGr2)r r(rrrr.s z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)r pipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)r rIrJrKrLrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||d| d|| } | j| j|j| y | EdHWn+tk r} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)NrKrL) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)r rJr<shellstdinstdoutstderrbufsizerLkwargswatcherrKtranspr=errrrr_make_subprocess_transports$        z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)r pid returncoder\rrrrSsz._UnixSelectorEventLoop._child_watcher_callbacksslsockserver_hostnamec csc|dks!t|ts!t|rB|dkrZtdn|dk rZtd|dk r|dk r~tdtjtjtjd}y&|jd|j||EdHWq6|j Yq6Xn\|dkrtd|j tjkst j | r)tdj ||jd|j||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r})rEr5AssertionErrorr2r#AF_UNIX SOCK_STREAM setblockingZ sock_connectr%familyr_is_stream_socketr:Z_create_connection_transport)r protocol_factoryrrarbrc transportrJrrrcreate_unix_connections:!              z-_UnixSelectorEventLoop.create_unix_connectionbacklogdc !Cst|trtd|dk r|dk r?tdt|}tjtjtj}|dd kry,tj t j|j rt j |WnIt k rYn8tk r}ztjd||WYdd}~XnXy|j|Wqtk ri}zK|j|jtjkrTdj|}ttj|dnWYdd}~Xq|jYqXnO|dkrtd|jtjkstj| rtdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rro)rEboolr-r2_fspathr#rerfstatS_ISSOCKosst_moderemoveFileNotFoundErrorr3rerrorZbindr%r8Z EADDRINUSEr:rhrriZServerZlistenrgZ_start_serving) r rjrrbrmrar]r=msgZserverrrrcreate_unix_serversP      &        z)_UnixSelectorEventLoop.create_unix_server)__name__ __module__ __qualname____doc__rr$r%r+r?r)r'r.rMrOr r^rSrlrzrr)r"rr1s,    -   %r set_blockingcCstj|ddS)NF)rtr)fdrrr_set_nonblocking9srcCs<tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrt O_NONBLOCKZF_SETFL)rflagsrrrr>s cseZdZdZddfddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrddZdddZddZddZS) rHiNcs*tj|||jd<||_||_|j|_||_d|_t j |jj }t j |pt j|pt j|sd|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r&|jjtj|ddS)NrIFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper1_fileno _protocol_closingrtfstatrurrS_ISFIFOrsS_ISCHRr2r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r looprIrJrKrLmode)r"rrrHs,           z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn,|jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r"r{rappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)r r7r!rrrr__repr__es$   z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnLttfk r6Yntk rj}z|j|dWYdd}~XnX|r|jj |ng|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rtreadrmax_sizeBlockingIOErrorInterruptedErrorr3 _fatal_errorrZ data_receivedr get_debugrr7r_remove_readerrZ eof_received_call_connection_lost)r r*r=rrrr{s# z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)r rrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)r rrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)r rJrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)r rrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)r rrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)r rrrr%s z_UnixReadPipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningr%)r rrr__del__sz_UnixReadPipeTransport.__del__zFatal error on pipe transportc Cst|trL|jtjkrL|jjrwtjd||ddn+|jjd|d|d|d|j i|j |dS)Nz%r: %sexc_infoTmessage exceptionrkrJ) rEr3r8ZEIOrrrdebugcall_exception_handlerrr)r r=rrrrrs! z#_UnixReadPipeTransport._fatal_errorcCs6d|_|jj|j|jj|j|dS)NT)rrrrrr)r r=rrrrs z_UnixReadPipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)r r=rrrrs    z,_UnixReadPipeTransport._call_connection_losti)r{r|r}rrrrrrrrrr%rPY34rrrrrr)r"rrHDs            rHcseZdZddfddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejrddZddZddd Zdd!d"Zd#d$ZS)%rNNc sjtj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |p|p| sd|_d|_d|_tdt|j|jj|jj|| s|rAtjjd rA|jj|jj|j|j|dk rf|jjtj|ddS)NrIrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr1rr bytearray_buffer _conn_lostrrtrrurrrrrsr2rrrrsysplatform startswithrrr r) r rrIrJrKrLrZis_charZis_fifoZ is_socket)r"rrrs2            z _UnixWritePipeTransport.__init__cCs#|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n,|jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r"r{rrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)r r7r!rrYrrrrs(     z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)r rrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCsI|jjrtjd||jr;|jtn |jdS)Nz%r was closed by peer)rrrr7rrBrokenPipeError)r rrrr s  z#_UnixWritePipeTransport._read_readycCst|tttfs*tt|t|trEt|}|sOdS|jsa|jr|jtj krt j d|jd7_dS|j snyt j|j|}Wnettfk rd}YnHtk r}z(|jd7_|j|ddSWYdd}~XnX|t|kr3dS|dkrUt||d}|jj|j|j|j |7_ |jdS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rEbytesr memoryviewrdreprrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrtwriterrrrTrrrZ _add_writer _write_readyZ_maybe_pause_protocol)r r*nr=rrrrs4*     z_UnixWritePipeTransport.writecCs;|jstdytj|j|j}Wn{ttfk rKYntk r}zD|jj|j d7_ |j j |j|j |dWYdd}~XnX|t |jkr|jj|j j |j|j|jr|j j|j|jddS|dkr7|jd|=dS)NzData should not be emptyrz#Fatal write error on pipe transportr)rrdrtrrrrrTclearrr_remove_writerrrZ_maybe_resume_protocolrrr)r rr=rrrr4s( #     z$_UnixWritePipeTransport._write_readycCsdS)NTr)r rrr can_write_eofNsz%_UnixWritePipeTransport.can_write_eofcCs[|jr dS|jstd|_|jsW|jj|j|jj|jddS)NT) rrrdrrrrrr)r rrr write_eofQs   z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)r rJrrrrZsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)r rrrr]sz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)r rrrr`sz"_UnixWritePipeTransport.is_closingcCs'|jdk r#|j r#|jdS)N)rrr)r rrrr%csz_UnixWritePipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rrrrr%)r rrrrlsz_UnixWritePipeTransport.__del__cCs|jddS)N)r)r rrrabortqsz_UnixWritePipeTransport.abortzFatal error on pipe transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srTrrrkrJ) rErZ_FATAL_ERROR_IGNORErrrrrrr)r r=rrrrrts z$_UnixWritePipeTransport._fatal_errorcCs_d|_|jr%|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrrrrr)r r=rrrrs    z_UnixWritePipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)r r=rrrrs    z-_UnixWritePipeTransport._call_connection_lost)r{r|r}rrrrrrrrrrrr%rrrrrrrrr)r"rrNs$ %   !         rNset_inheritablecCsittdd}tj|tj}|sJtj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables rc@seZdZddZdS)rQc Ksd}|tjkr=|jj\}}t|jdtj|d|d|d|d|ddd|||_|dk r|jt |j dd ||j_ dS) NFrUrVrWrXZuniversal_newlinesrYwb buffering) subprocessPIPErr$rr1Popen_procr%rdetachrV) r r<rUrVrWrXrYrZZstdin_wrrr_starts  z_UnixSubprocessTransport._startN)r{r|r}rrrrrrQs rQc@s^eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)r r_r;r<rrrrRs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)r r_rrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)r rrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)r rrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)r rrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)r abcrrr__exit__szAbstractChildWatcher.__exit__N) r{r|r}r~rRrrr%rrrrrrrs    c@sdeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)r rrrrs zBaseChildWatcher.__init__cCs|jddS)N)r)r rrrr% szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpid szBaseChildWatcher._do_waitpidcCs tdS)N)r)r rrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs|dks$t|tjs$t|jdk rX|dkrX|jrXtjdt|jdk rz|jj t j ||_|dk r|j t j |j |jdS)NzCA loop is being detached from a child watcher with pending handlers)rErZAbstractEventLooprdrrrrRuntimeWarningr'r/SIGCHLDr? _sig_chldr)r rrrrrs$$  zBaseChildWatcher.attach_loopcCsVy|jWnAtk rQ}z!|jjddd|iWYdd}~XnXdS)Nrz$Unknown exception in SIGCHLD handlerr)rrTrr)r r=rrrr&s  zBaseChildWatcher._sig_chldcCsAtj|rtj| Stj|r9tj|S|SdS)N)rt WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)r statusrrr_compute_returncode2s  z$BaseChildWatcher._compute_returncodeN) r{r|r}rr%rrrrrrrrrrs       rcspeZdZdZfddZddZddZdd Zd d Zd d Z ddZ S)rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cs|jjtjdS)N)rrrr%)r )r"rrr%Ks zSafeChildWatcher.closecCs|S)Nr)r rrrrOszSafeChildWatcher.__enter__cCsdS)Nr)r rrrrrrrRszSafeChildWatcher.__exit__cGs?|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr4rr)r r_r;r<rrrrRUs  z"SafeChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)rrA)r r_rrrr`s   z%SafeChildWatcher.remove_child_handlercCs+x$t|jD]}|j|qWdS)N)r&rr)r r_rrrrgsz SafeChildWatcher._do_waitpid_allcCs |dkstytj|tj\}}Wn.tk ra|}d}tjd|YnBX|dkrrdS|j|}|jj rtj d||y|j j |\}}Wn7t k r|jj rtjd|ddYnX||||dS)Nrz8Unknown child process pid %d, will report returncode 255z$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rrT)rdrtwaitpidWNOHANGChildProcessErrorrrrrrrrpoprA)r rr_rr`r;r<rrrrls,       zSafeChildWatcher._do_waitpid) r{r|r}r~r%rrrRrrrrr)r"rr@s     csveZdZdZfddZfddZddZdd Zd d Zd d Z ddZ S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs2tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r )r"rrrs  zFastChildWatcher.__init__cs+|jj|jjtjdS)N)rrrrr%)r )r"rrr%s  zFastChildWatcher.closec Cs(|j|jd7_|SWdQRXdS)Nr)rr)r rrrrs zFastChildWatcher.__enter__c Csg|jG|jd8_|js,|j r0dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr5rrr)r rrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGs|jstd|jdkr0td|jGy|jj|}Wn)tk r{||f|j| %dr,)rtrrrrrrrrArrrrrrr)r r_rr`r;r<rrrrs6             z FastChildWatcher._do_waitpid_all) r{r|r}r~rr%rrrRrrrr)r"rrs     csdeZdZdZeZfddZddZfddZdd Z d d Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r )r"rrrs z$_UnixDefaultEventLoopPolicy.__init__c Cs^tjN|jdkrSt|_ttjtjrS|jj|j j WdQRXdS)N) rrrrrErcurrent_thread _MainThreadr_localr)r rrr _init_watchers     z)_UnixDefaultEventLoopPolicy._init_watchercsKtj||jdk rGttjtjrG|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrErrrr)r r)r"rrr sz*_UnixDefaultEventLoopPolicy.set_event_loopcCs |jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)r rrrrPs z-_UnixDefaultEventLoopPolicy.get_child_watchercCsJ|dks!t|ts!t|jdk r=|jj||_dS)z$Set the watcher for child processes.N)rErrdrr%)r r[rrrset_child_watcher%s! z-_UnixDefaultEventLoopPolicy.set_child_watcher) r{r|r}r~rZ _loop_factoryrrrrPrrr)r"rrs   r)5r~r8rtr/r#rrrrrrrrrrrrr r r r r logr__all__r ImportErrorrZfspathrqAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrHZ_FlowControlMixinZWriteTransportrNrrZBaseSubprocessTransportrQrrrrZBaseDefaultEventLoopPolicyrrrrrrrsh                    F=On2PK!浀8oo,__pycache__/unix_events.cpython-35.opt-2.pycnu[ ] @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZdddddgZejdkr\edddZy ejZWnek rddZYnXGdddejZe edrddZ!nddl"Z"ddZ!Gd d!d!ej#Z$Gd"d#d#ej%ej&Z'e ed$r8ej(Z)nddl"Z"d%d&Z)Gd'd(d(e j*Z+Gd)ddZ,Gd*d+d+e,Z-Gd,dde-Z.Gd-dde-Z/Gd.d/d/ej0Z1eZ2e1Z3dS)0N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on WindowscCsdS)N)signumframerr0/opt/alt/python35/lib64/python3.5/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.src seZdZdfddZddZfddZdd Zd d Zd d ZddZ ddZ ddddZ ddddZ e dddZddZe ddddddddZe ddddd ddd!d"ZS)#_UnixSelectorEventLoopNcstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7sz_UnixSelectorEventLoop.__init__cCs tjS)N)socket socketpair)r rrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs8tjx$t|jD]}|j|qWdS)N)rcloselistrremove_signal_handler)r sig)r"rrr&>s z_UnixSelectorEventLoop.closecCs+x$|D]}|sq|j|qWdS)N)_handle_signal)r datarrrr_process_self_dataCs z)_UnixSelectorEventLoop._process_self_datac+Gstj|stj|r*td|j||jytj|jj Wn=t t fk r}zt t |WYdd}~XnXtj|||}||j|tjkns^tdj|tjdS)Nzsig must be an int, not {!r}rzsig {} out of range(1, {})) isinstanceintr.r<r1NSIGr4)r r)rrrr/s z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)r pipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)r rLrMrNrOrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||d| d|| } | j| j|j| y | EdHWn+tk r} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)NrNrO) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr&_wait)r rMr>shellstdinstdoutstderrbufsizerOkwargswatcherrNtranspr?errrrr_make_subprocess_transports$        z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)r pid returncoder`rrrrVsz._UnixSelectorEventLoop._child_watcher_callbacksslsockserver_hostnamec csB|r!|dkr9tdn|dk r9td|dk r|dk r]tdtjtjtjd}y&|jd|j||EdHWq|jYqXn\|dkrtd|jtjkstj | rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r4r#AF_UNIX SOCK_STREAM setblockingZ sock_connectr&familyr_is_stream_socketr<Z_create_connection_transport)r protocol_factoryrrerfrg transportrMrrrcreate_unix_connections8              z-_UnixSelectorEventLoop.create_unix_connectionbacklogdc !Cst|trtd|dk r|dk r?tdt|}tjtjtj}|dd kry,tj t j|j rt j |WnIt k rYn8tk r}ztjd||WYdd}~XnXy|j|Wqtk ri}zK|j|jtjkrTdj|}ttj|dnWYdd}~Xq|jYqXnO|dkrtd|jtjkstj| rtdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrr)rHboolr.r4_fspathr#rhristatS_ISSOCKosst_moderemoveFileNotFoundErrorr5rerrorbindr&r:Z EADDRINUSEr<rkrrlZServerlistenrjZ_start_serving) r rmrrfrprerar?msgZserverrrrcreate_unix_serversP      &        z)_UnixSelectorEventLoop.create_unix_server)__name__ __module__ __qualname__rr%r&r,rAr*r(r/rPrRr rbrVrorrr)r"rr1s*    -   %r set_blockingcCstj|ddS)NF)rwr)fdrrr_set_nonblocking9srcCs<tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrw O_NONBLOCKZF_SETFL)rflagsrrrr>s cseZdZdZddfddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrddZdddZddZddZS) rKiNcs*tj|||jd<||_||_|j|_||_d|_t j |jj }t j |pt j|pt j|sd|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r&|jjtj|ddS)NrLFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper3_fileno _protocol_closingrwfstatrxruS_ISFIFOrvS_ISCHRr4r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r looprLrMrNrOmode)r"rrrHs,           z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn,|jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r"rrappendrrgetattrrr _test_selector_eventr EVENT_READjoin)r r9r!rrrr__repr__es$   z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnLttfk r6Yntk rj}z|j|dWYdd}~XnX|r|jj |ng|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rwreadrmax_sizeBlockingIOErrorInterruptedErrorr5 _fatal_errorrZ data_receivedr get_debugrr9r_remove_readerrZ eof_received_call_connection_lost)r r+r?rrrr{s# z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)r rrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)r rrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)r rMrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)r rrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)r rrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)r rrrr&s z_UnixReadPipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningr&)r rrr__del__sz_UnixReadPipeTransport.__del__zFatal error on pipe transportc Cst|trL|jtjkrL|jjrwtjd||ddn+|jjd|d|d|d|j i|j |dS)Nz%r: %sexc_infoTmessage exceptionrnrM) rHr5r:ZEIOrrrdebugcall_exception_handlerrr)r r?rrrrrs! z#_UnixReadPipeTransport._fatal_errorcCs6d|_|jj|j|jj|j|dS)NT)rrrrrr)r r?rrrrs z_UnixReadPipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr&r)r r?rrrrs    z,_UnixReadPipeTransport._call_connection_losti)rrrrrrrrrrrrr&rPY34rrrrrr)r"rrKDs            rKcseZdZddfddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejrddZddZddd Zdd!d"Zd#d$ZS)%rQNc sjtj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |p|p| sd|_d|_d|_tdt|j|jj|jj|| s|rAtjjd rA|jj|jj|j|j|dk rf|jjtj|ddS)NrLrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr3rr bytearray_buffer _conn_lostrrwrrxrurrrvr4rrrrsysplatform startswithrrr r) r rrLrMrNrOrZis_charZis_fifoZ is_socket)r"rrrs2            z _UnixWritePipeTransport.__init__cCs#|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n,|jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r"rrrrrrrr rr EVENT_WRITEget_write_buffer_sizer)r r9r!rr]rrrrs(     z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)r rrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCsI|jjrtjd||jr;|jtn |jdS)Nz%r was closed by peer)rrrr9rrBrokenPipeError)r rrrr s  z#_UnixWritePipeTransport._read_readycCsat|trt|}|s%dS|js7|jri|jtjkrVtjd|jd7_dS|j sDyt j |j |}Wnet tfk rd}YnHtk r}z(|jd7_|j|ddSWYdd}~XnX|t|kr dS|dkr+t||d}|jj|j |j|j |7_ |jdS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rHr memoryviewrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrwwriterrrrWrrrZ _add_writer _write_readyZ_maybe_pause_protocol)r r+nr?rrrrs2     z_UnixWritePipeTransport.writecCs&ytj|j|j}Wn{ttfk r6Yntk r}zD|jj|jd7_|j j |j|j |dWYdd}~XnX|t |jkr|jj|j j |j|j |jr|j j|j|jddS|dkr"|jd|=dS)Nrz#Fatal write error on pipe transportr)rwrrrrrrWclearrr_remove_writerrrZ_maybe_resume_protocolrrr)r rr?rrrr4s& #     z$_UnixWritePipeTransport._write_readycCsdS)NTr)r rrr can_write_eofNsz%_UnixWritePipeTransport.can_write_eofcCsL|jr dSd|_|jsH|jj|j|jj|jddS)NT)rrrrrrr)r rrr write_eofQs    z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)r rMrrrrZsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)r rrrr]sz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)r rrrr`sz"_UnixWritePipeTransport.is_closingcCs'|jdk r#|j r#|jdS)N)rrr)r rrrr&csz_UnixWritePipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rrrrr&)r rrrrlsz_UnixWritePipeTransport.__del__cCs|jddS)N)r)r rrrabortqsz_UnixWritePipeTransport.abortzFatal error on pipe transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srTrrrnrM) rHrZ_FATAL_ERROR_IGNORErrrrrrr)r r?rrrrrts z$_UnixWritePipeTransport._fatal_errorcCs_d|_|jr%|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrrrrr)r r?rrrrs    z_UnixWritePipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rrrr&r)r r?rrrrs    z-_UnixWritePipeTransport._call_connection_lost)rrrrrrrrrrrrrrr&rrrrrrrrr)r"rrQs$ %   !         rQset_inheritablecCsittdd}tj|tj}|sJtj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)r inheritableZ cloexec_flagoldrrr_set_inheritables rc@seZdZddZdS)rTc Ksd}|tjkr=|jj\}}t|jdtj|d|d|d|d|ddd|||_|dk r|jt |j dd ||j_ dS) NFrYrZr[r\universal_newlinesr]wb buffering) subprocessPIPErr%rr3Popen_procr&rdetachrZ) r r>rYrZr[r\r]r^Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrTs rTc@sXeZdZddZddZddZddZd d Zd d Zd S)rcGs tdS)N)NotImplementedError)r rcr=r>rrrrUs z&AbstractChildWatcher.add_child_handlercCs tdS)N)r)r rcrrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)N)r)r rrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)N)r)r rrrr&szAbstractChildWatcher.closecCs tdS)N)r)r rrr __enter__szAbstractChildWatcher.__enter__cCs tdS)N)r)r abcrrr__exit__szAbstractChildWatcher.__exit__N) rrrrUrrr&rrrrrrrs    c@sdeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)r rrrrs zBaseChildWatcher.__init__cCs|jddS)N)r)r rrrr& szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpid szBaseChildWatcher._do_waitpidcCs tdS)N)r)r rrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs|jdk r4|dkr4|jr4tjdt|jdk rV|jjtj||_|dk r|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrrrRuntimeWarningr(r1SIGCHLDrA _sig_chldr)r rrrrrs$  zBaseChildWatcher.attach_loopcCsVy|jWnAtk rQ}z!|jjddd|iWYdd}~XnXdS)Nrz$Unknown exception in SIGCHLD handlerr)rrWrr)r r?rrrr&s  zBaseChildWatcher._sig_chldcCsAtj|rtj| Stj|r9tj|S|SdS)N)rw WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)r statusrrr_compute_returncode2s  z$BaseChildWatcher._compute_returncodeN) rrrrr&rrrrrrrrrrs       rcsjeZdZfddZddZddZddZd d Zd d Zd dZ S)rcs|jjtjdS)N)rrrr&)r )r"rrr&Ks zSafeChildWatcher.closecCs|S)Nr)r rrrrOszSafeChildWatcher.__enter__cCsdS)Nr)r rrrrrrrRszSafeChildWatcher.__exit__cGs?|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr6rr)r rcr=r>rrrrUUs  z"SafeChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)rrC)r rcrrrr`s   z%SafeChildWatcher.remove_child_handlercCs+x$t|jD]}|j|qWdS)N)r'rr)r rcrrrrgsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn.tk rO|}d}tjd|YnBX|dkr`dS|j|}|jjrtj d||y|j j |\}}Wn7t k r|jjrtjd|ddYnX||||dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rrT) rwwaitpidWNOHANGChildProcessErrorrrrrrrrpoprC)r rrcrrdr=r>rrrrls*       zSafeChildWatcher._do_waitpid) rrrr&rrrUrrrrr)r"rr@s     cspeZdZfddZfddZddZddZd d Zd d Zd dZ S)rcs2tjtj|_i|_d|_dS)Nr)rr threadingLock_lock_zombies_forks)r )r"rrrs  zFastChildWatcher.__init__cs+|jj|jjtjdS)N)rrrrr&)r )r"rrr&s  zFastChildWatcher.closec Cs(|j|jd7_|SWdQRXdS)Nr)rr)r rrrrs zFastChildWatcher.__enter__c Csg|jG|jd8_|js,|j r0dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr7rrr)r rrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGs|jdkrtd|jGy|jj|}Wn)tk rf||f|j|rdrrrrUs   z"FastChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)rrC)r rcrrrrs   z%FastChildWatcher.remove_child_handlercCs9x2ytjdtj\}}Wntk r:dSYn X|dkrKdS|j|}|jy|jj|\}}WnStk r|j r||j |<|j j rt jd||wd}Yn#X|j j rt jd||WdQRX|dkr!t jd||q||||qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr-)rwrrrrrrrrCrrrrrrr)r rcrrdr=r>rrrrs6             z FastChildWatcher._do_waitpid_all) rrrrr&rrrUrrrr)r"rrs     cs^eZdZeZfddZddZfddZddZd d Z S) _UnixDefaultEventLoopPolicycstjd|_dS)N)rr_watcher)r )r"rrrs z$_UnixDefaultEventLoopPolicy.__init__c Cs^tjN|jdkrSt|_ttjtjrS|jj|j j WdQRXdS)N) rrrrrHrcurrent_thread _MainThreadr_localr)r rrr _init_watchers     z)_UnixDefaultEventLoopPolicy._init_watchercsKtj||jdk rGttjtjrG|jj|dS)N)rset_event_looprrHrrrr)r r)r"rrr sz*_UnixDefaultEventLoopPolicy.set_event_loopcCs |jdkr|j|jS)N)rr)r rrrrSs z-_UnixDefaultEventLoopPolicy.get_child_watchercCs)|jdk r|jj||_dS)N)rr&)r r_rrrset_child_watcher%s z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrZ _loop_factoryrrrrSr rr)r"rrs   r)4r:rwr1r#rurrrrrrrrrrr r r r r logr__all__r ImportErrorrZfspathrtAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrKZ_FlowControlMixinZWriteTransportrQrrZBaseSubprocessTransportrTrrrrZBaseDefaultEventLoopPolicyrrrrrrrsf                    F=On2PK!Vv1&__pycache__/base_events.cpython-35.pycnu[ Yf @sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddde j'ddddddZ(d d!Z)Gd"d#d#ej*Z+Gd$d d ej,Z-dS)%aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?cCsH|j}tj|r:t|jtjr:t|jSt|SdS)N) Z _callbackinspectZismethod isinstance__self__rTaskreprstr)handlecbr8/opt/alt/python35/lib64/python3.5/asyncio/base_events.py_format_handle:s $ rcCs4|tjkrdS|tjkr&dSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeCs rc Cs`ttdstdn>y|jtjtjdWntk r[tdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportLs  r$cCs|jtj@tjkS)N)typer SOCK_STREAM)r#rrr_is_stream_socketWsr'cCs|jtj@tjkS)N)r%r SOCK_DGRAM)r#rrr_is_dgram_socket^sr)cCsttdsdS|dtjtjhks:|dkr>dS|tjkrYtj}n|tjkrttj}ndS|dkrd}nwt|tr|dkrd}nSt|tr|dkrd}n/yt |}Wnt t fk rdSYnX|tj krAtj g}ttdrJ|jtjn |g}t|trh|jd}d|krxdSxP|D]H}y-tj|||||d||ffSWqtk rYqXqWdS)N inet_ptonrAF_INET6Zidna%)rrZ IPPROTO_TCPZ IPPROTO_UDPr&r(r bytesrint TypeErrorr AF_UNSPECZAF_INETappendr-decoder*r")hostportfamilyr%protoZafsafrrr _ipaddr_infoesH              r:r7r%r8flagsc Cs|dd\}}t|||||}|dk rZ|j} | j|g| S|j||d|d|d|d|SdS)Nr7r%r8r;)r: create_future set_result getaddrinfo) addressr7r%r8r;loopr5r6infofutrrr_ensure_resolveds  rDcCs=|j}t|tr,t|t r,dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rCexcrrr_run_until_complete_cbs  rJc@sjeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs(||_||_d|_g|_dS)Nr)rGsockets _active_count_waiters)selfrArLrrr__init__s   zServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rL)rOrrr__repr__szServer.__repr__cCs(|jdk st|jd7_dS)Nr)rLAssertionErrorrM)rOrrr_attachszServer._attachcCsP|jdkst|jd8_|jdkrL|jdkrL|jdS)Nrr)rMrTrL_wakeup)rOrrr_detachszServer._detachcCs`|j}|dkrdSd|_x|D]}|jj|q)W|jdkr\|jdS)Nr)rLrGZ _stop_servingrMrV)rOrLr#rrrcloses    z Server.closecCs@|j}d|_x'|D]}|js|j|qWdS)N)rNdoner>)rOwaiterswaiterrrrrVs     zServer._wakeupccsN|jdks|jdkr"dS|jj}|jj||EdHdS)N)rLrNrGr=r3)rOr[rrr wait_closeds zServer.wait_closedN) rR __module__ __qualname__rPrSrUrWrXrVrr\rrrrrKs      rKc@seZdZddZddZddZddZd d Zd d Zd dd dd ddZ d dddd dd dd ddZ d d d ddZ d d ddZ d d ddZ ed ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zejrd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPdQdPdRdPdSdPdTdUZ*dPdVdWZ+ed d dXd dOdPdRdPdSdPdYd dZd dd d[d\Z,edd]d^Z-ed d dOdPdRdPdSdPd_d d`d dad dYd dbdcZ.edddeZ/ed d dOe0j1dSe0j2dYd dfdgdXd d_d d`d dhdiZ3edXd djdkZ4edldmZ5edndoZ6dpdqZ7edre8j9dse8j9dte8j9duddvdwdxdPdydzZ:edre8j9dse8j9dte8j9duddvddxdPd{d|Z;d}d~Z<ddZ=ddZ>ddZ?ddZ@ddZAddZBddZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj ottjjdd|_d|_d|_d|_ttdrtj|_n d|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysr;ignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rOrrrrPs(             zBaseEventLoop.__init__cCs,d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rQrR is_running is_closed get_debug)rOrrrrS szBaseEventLoop.__repr__cCstjd|S)z,Create a Future object attached to the loop.rA)rZFuture)rOrrrr=szBaseEventLoop.create_futurecCsZ|j|jdkrDtj|d|}|jrV|jd=n|j||}|S)zDSchedule a coroutine object. Return a task object. NrAr) _check_closedrvrr_source_traceback)rOcoroZtaskrrr create_tasks   zBaseEventLoop.create_taskcCs2|dk r%t| r%td||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler1rv)rOfactoryrrrset_task_factory#s  zBaseEventLoop.set_task_factorycCs|jS)zs z4BaseEventLoop.shutdown_asyncgens..Zreturn_exceptionsrAmessagez?an error occurred during closing of asynchronous generator {!r} exceptionZasyncgen) r{rzlenlistclearrgatherzipr rFcall_exception_handlerr)rOZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgensxs"     z BaseEventLoop.shutdown_asyncgensc Cs|j|jr"tdtjdk r@td|j|jtj|_ |j dk rt j }t j d|jd|jz,tj|x|j|jrPqWWdd|_d|_ tjd|jd|j dk r t j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is runningZ firstiterZ finalizerF)rr|rrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrirzrnr`Zset_asyncgen_hooksrrZ_set_running_loop _run_oncerc)rOZold_agen_hooksrrr run_forevers0              zBaseEventLoop.run_forevercCs|jtj| }tj|d|}|r>d|_|jtzIy|jWn4|r|j r|j r|j YnXWd|j tX|j st d|jS)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. rAFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrJrrYZ cancelledrZremove_done_callbackrr)rOZfutureZnew_taskrrrrun_until_completes       z BaseEventLoop.run_until_completecCs d|_dS)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rc)rOrrrrHszBaseEventLoop.stopcCs|jrtd|jr%dS|jr>tjd|d|_|jj|jj|j }|dk rd|_ |j dddS)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTwaitF) r|rrbrr debugrfrrgrhZshutdown)rOexecutorrrrrXs          zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rb)rOrrrr}szBaseEventLoop.is_closedcCs:|js6tjd|t|js6|jdS)Nzunclosed event loop %r)r}rrrr|rX)rOrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)ri)rOrrrr|szBaseEventLoop.is_runningcCs tjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rjr_)rOrrrrjszBaseEventLoop.timecGs6|j|j|||}|jr2|jd=|S)a8Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrjr)rOZdelaycallbackrtimerrrr call_laters  zBaseEventLoop.call_latercGsx|j|jr-|j|j|dtj||||}|jrX|jd=tj|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. rrTr) rr _check_thread_check_callbackr TimerHandlerheapqheappushrg)rOwhenrrrrrrr#s      zBaseEventLoop.call_atcGsV|j|jr-|j|j|d|j||}|jrR|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonrr)rrrr _call_soonr)rOrrrrrrr3s     zBaseEventLoop.call_sooncCs[tj|stj|r3tdj|t|sWtdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr1rr)rOrmethodrrrrFs zBaseEventLoop._check_callbackcCs<tj|||}|jr(|jd=|jj||S)Nrr)rHandlerrfr3)rOrrrrrrrQs   zBaseEventLoop._call_sooncCs>|jdkrdStj}||jkr:tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rirrr)rOZ thread_idrrrrXs  zBaseEventLoop._check_threadcGsV|j|jr#|j|d|j||}|jrH|jd=|j|S)z"Like call_soon(), but thread-safe.call_soon_threadsaferr)rrrrrr)rOrrrrrrris     z"BaseEventLoop.call_soon_threadsafecGs{|j|jr#|j|d|dkr\|j}|dkr\tjj}||_tj|j||d|S)Nrun_in_executorrA) rrrrh concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rOrfuncrrrrrts      zBaseEventLoop.run_in_executorcCs ||_dS)N)rh)rOrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r*|jd||rA|jd||rX|jd||ro|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r3joinr rrjrr?rtrB) rOr5r6r7r%r8r;msgt0Zaddrinfodtrrr_getaddrinfo_debugs(  z BaseEventLoop._getaddrinfo_debugr7rr%r8r;c CsW|jr.|jd|j||||||S|jdtj||||||SdS)N)rrrrr?)rOr5r6r7r%r8r;rrrr?s  zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rOZsockaddrr;rrrrszBaseEventLoop.getnameinfosslr# local_addrc#s#| dk r| rtd| dkrI|rI|sCtd|} |dk sa|dk r|dk rytdt||fd|dtjd|d|d |} | g} | dk rt| d|dtjd|d|d |} | j| nd} tj| d |EdH| j}|s:td | dk rd| j}|sdtd g}xU|D]\}}}}}y tjd|d|d|}|j d | dk rax|D]\}}}}}y|j |PWqtk rI}z9t|j d j ||j j}|j|WYdd}~XqXqW|jd}wq|jr}tjd |||j||EdHWnhtk r}z(|dk r|j|j|WYdd}~Xqq|dk r|jYqqXPqqWt|dkr"|dqt|dtfdd|Dr[|dtdj djdd|Dn9|dkrtdt|stdj ||j|||| EdH\}}|jr|jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same timer7r%r8r;rAz!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s!|]}t|kVqdS)N)r)rrI)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrIrrrrsz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}rz%r connected to %s:%r: (%r, %r))rrDrr&r3rrrr" setblockingbinderrnorstrerrorlowerrXrr r sock_connectrrallrr'_create_connection_transportget_extra_info)rOprotocol_factoryr5r6rr7r8r;r#rrf1fsf2infosZ laddr_infos exceptionsr%Zcnamer@_ZladdrrI transportrr)rrcreate_connections                $         %     zBaseEventLoop.create_connectionc cs|jd|}|j}|rjt|tr=dn|}|j||||d|d|} n|j|||} y |EdHWn| jYnX| |fS)NFrr)rr=r rprrrX) rOr#rrrrrr[rrrrrr+s     z*BaseEventLoop._create_connection_transport reuse_address reuse_portallow_broadcastc#s| dk rt| s-tdj| s]s]|s]|s]|s]|s]|s]| rtddd|d|d|d|d |d | } d jd d | jD} tdj| | jdd} nps|dkrtd||fdff}n<tj}xdfdffD]\}}|dk rDt |t r}t |dkst dt |d|dtjd|d|d|EdH}|stdxS|D]K\}}}}}||f}||krddg||<||||.zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrr<z2-tuple is expectedr%rAz!getaddrinfo() returned empty listcsNg|]D\}}r(|ddkp;o;|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrxs z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)$r)rrdictritemsrrd OrderedDictr tuplerrTrDrr(r"rqnamernplatformr r! SO_REUSEADDRr$Z SO_BROADCASTrrrXr3r=rrr rBr)rOrrrr7r8r;rrrr#ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZpror@rrZ local_addressZremote_addressrIrr[rr)rrrcreate_datagram_endpointCs            % $    "                    z&BaseEventLoop.create_datagram_endpointc csQt||fd|dtjd|d|EdH}|sMtdj||S)Nr7r%r;rAz%getaddrinfo({!r}) returned empty list)rDrr&r"r)rOr5r6r7r;rrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfobacklogr c #sdt|trtd|dk s3dk r|dk rKtdttdd} | dkrtjdkotj dk} g} |dkrdg} n4t|t st|t j  r|g} n|} fd d | D}t j|d EdH}ttjj|}d }zWxJ|D]B}|\}}}}}ytj|||}Wn=tjk rjrtjd |||ddw=YnX| j|| r|jtjtjd| rt||| kr!ttdr!|jtjtjdy|j|Wq=t k r~}z*t |j!d||j"j#fWYdd}~Xq=Xq=Wd}Wd|sx| D]}|j$qWXnB|dkrtdt%|stdj&||g} t'| }xA| D]9}|j(||j)d j*|||||q Wjr`tj+d||S)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timer-rrrr,c s.g|]$}j|ddqS)r7r;)r)rr5)r7r;r6rOrrrs z/BaseEventLoop.create_server..rAFz:create_server() failed to create socket.socket(%r, %r, %r)exc_infoT IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving),r rpr1rgetattrrrqrrnrrrdIterablerrset itertoolschain from_iterableerrorrr warningr3r r!rr$rrZ IPV6_V6ONLYrr"rrrrXr'rrKZlistenrZ_start_servingrB)rOrr5r6r7r;r#rrrrr-rLZhostsrrZ completedresr9Zsocktyper8Z canonnameZsaerrrr)r7r;r6rOr create_servers               0          zBaseEventLoop.create_serverccst|s!tdj||j|||dddEdH\}}|jrx|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r,rTNrz%r handled: (%r, %r))r'rrrrrr r)rOrr#rrrrrrconnect_accepted_socket.s # z%BaseEventLoop.connect_accepted_socketc cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz Read pipe %r connected: (%r, %r))r=rrXrr rfileno)rOrrrr[rrrrconnect_read_pipeEs      zBaseEventLoop.connect_read_pipec cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))r=rrXrr rr)rOrrrr[rrrrconnect_write_pipeVs      z BaseEventLoop.connect_write_pipecCs|g}|dk r,|jdt||dk ra|tjkra|jdt|nF|dk r|jdt||dk r|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r3rrrr rr)rOrrrrrBrrr_log_subprocessgs    zBaseEventLoop._log_subprocessrrruniversal_newlinesrTrc kst|ttfs!td|r3td|sEtd|dkr]td|} |jrd|} |j| ||||j| |d||||| EdH} |jrtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) r r/rrrrrr rB) rOrcmdrrrrrrrr debug_logrrrrsubprocess_shellts"        # zBaseEventLoop.subprocess_shellc os |rtd|r$td|dkr<td|f| } x<| D]4} t| ttfsPtdt| jqPW|} |jrd|}|j|||||j | | d||||| EdH}|jrt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) rr rr/r1r%rRrrrr rB)rOrZprogramrrrrrrrrZ popen_argsargrrrrrrsubprocess_execs*          zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rl)rOrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs;|dk r.t| r.tdj|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})rr1rrl)rOZhandlerrrrset_exception_handlers   z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk rQt|||jf}nd}d|kr|jdk r|jjr|jj|d<|g}xt|D]}|dkrq||}|dkrdjtj|}d }||j 7}nI|dkr=djtj|}d }||j 7}n t |}|j d j ||qWt jd j|d |dS)a@Default exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr,z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} r>rr)rsr% __traceback__rursortedr traceback format_listrstriprr3rr r) rOcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6          z'BaseEventLoop.default_exception_handlercCs|jdkrKy|j|Wqtk rGtjdddYqXny|j||Wnptk r}zPy#|jddd|d|iWn%tk rtjd ddYnXWYdd}~XnXdS) aCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerrTrz$Unhandled error in exception handlerrr'zeException in default exception handler while handling an unexpected error in custom exception handler)rlr*rFr r)rOr'rIrrrrs"    z$BaseEventLoop.call_exception_handlercCsXt|tjstd|jr+dSt|tj sDt|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)r rrrT _cancelledrrfr3)rOrrrr _add_callbacks  zBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r,r)rOrrrr_add_callback_signalsafe's z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rgra)rOrrrr_timer_handle_cancelled,s z%BaseEventLoop._timer_handle_cancelledc Cslt|j}|tkr|j|tkrg}x3|jD](}|jrYd|_q>|j|q>Wtj|||_d|_nJxG|jr|jdjr|jd8_tj |j}d|_qWd}|j s|j rd}n2|jr)|jdj }t d||j}|jr|dkr|j}|jj|}|j|}|dkrtj} n tj} t|} |dkrtj| d|d| q+| rtj| d|d|d| q+|dkr+tj| d |d|dn|jj|}|j||j|j} xU|jr|jd}|j | krtPtj |j}d|_|j j|qNWt|j } xt| D]} |j j}|jrq|jrTz[||_|j}|j|j|}||jkrCtjd t||Wdd|_Xq|jqWd}dS) zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds) rrg_MIN_SCHEDULED_TIMER_HANDLESra%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr+r3rheapifyheappoprfrcZ_whenmaxrjrZ _selectorZselectloggingINFODEBUGr logrrkrangepopleftruZ_runrtrr)rOZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrr1s                                zBaseEventLoop._run_oncec Csytj}tj}Wntk r.dSYnXt|}|j|krNdStj}|}|r|d|fkrtj d|t q||d|_n<|d|fkrtj d|t n|dd|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF) rnset_coroutine_wrapperget_coroutine_wrapperAttributeErrorrprwrZ debug_wrapperrrRuntimeWarning)rOenabledZ set_wrapperZ get_wrapperwrapperZcurrent_wrapperrrrrs.          z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r)rOrrrr~szBaseEventLoop.get_debugcCs&||_|jr"|j|dS)N)rr|r)rOr@rrrrms  zBaseEventLoop.set_debug)GrRr]r^rPrSr=rrrrrrrrrrrrrrrrrrrHrXr}rZPY34rr|rjrrrrrrrrrrr?rrrrrrr2Z AI_PASSIVErrrrrrrrrrr r*rr,r-r.rrr~rmrrrrr s  !            %             !   u    _     , 2    c ! ).__doc__rdZconcurrent.futuresrrr r r4rqrrrrjr$rnrrxr,rrrrrrr7r __all__r/r0BrokenPipeErrorConnectionResetErrorConnectionAbortedErrorZ_FATAL_ERROR_IGNORErrr$r'r)r:r&rDrJZAbstractServerrKZAbstractEventLoopr rrrrsL                    = /PK!/>>'__pycache__/queues.cpython-35.opt-2.pycnu[ ]@sdddddgZddlZddlZddlmZdd lmZdd lmZdd lmZGd dde Z Gd dde Z GdddZ Gddde Z Gddde Zejse ZejddS)Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdS)rN)__name__ __module__ __qualname__rr+/opt/alt/python35/lib64/python3.5/queues.pyrs c@seZdZdS)rN)r r rrrrrrs c@s eZdZdddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ e ddZ ddZddZeddZddZed d!Zd"d#Zd$d%Zed&d'ZdS)(rrloopNcCs|dkrtj|_n ||_||_tj|_tj|_d|_t j d|j|_ |j j |j |dS)Nrr)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr Event _finishedset_init)selfmaxsizerrrr__init__(s     zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs7x0|r2|j}|js|jdPqWdS)N)r!done set_result)rwaiterswaiterrrr _wakeup_nextEs     zQueue._wakeup_nextcCs(djt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r+r,r r.)rrrr__str__Qsz Queue.__str__cCsdj|j}t|ddr@|djt|j7}|jre|djt|j7}|jr|djt|j7}|jr|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r+rgetattrlistr rlenrr)rresultrrrr.Ts   z Queue._formatcCs t|jS)N)r3r )rrrrqsize`sz Queue.qsizecCs|jS)N)r)rrrrrdsz Queue.maxsizecCs|j S)N)r )rrrremptyisz Queue.emptycCs*|jdkrdS|j|jkSdS)NrF)rr5)rrrrfullmsz Queue.fullc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|j|S)N) r7r create_futurerr#cancel cancelledr* put_nowait)rr$Zputterrrrputxs    z Queue.putcCsO|jrt|j||jd7_|jj|j|jdS)Nr)r7rr%rrclearr*r)rr$rrrr;s    zQueue.put_nowaitc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|jS)N) r6rr8rr#r9r:r* get_nowait)rgetterrrrgets   z Queue.getcCs2|jrt|j}|j|j|S)N)r6rr"r*r)rr$rrrr>s   zQueue.get_nowaitcCsJ|jdkrtd|jd8_|jdkrF|jjdS)Nrz!task_done() called too many timesr)r ValueErrorrr)rrrr task_dones  zQueue.task_doneccs%|jdkr!|jjEdHdS)Nr)rrwait)rrrrjoins z Queue.join)r r rrrr"r%r*r/r0r.r5propertyrr6r7r r<r;r@r>rBrDrrrrrs$            c@s@eZdZddZejddZejddZdS)rcCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrheapqrFr%rGr"rrrrrs  c@s4eZdZddZddZddZdS)rcCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrr%r"rrrrrs    JoinableQueue)__all__rrHrr r Z coroutinesr ExceptionrrrrrZPY35rJr#rrrrs   PK!sHH'__pycache__/events.cpython-35.opt-2.pycnu[ ]TY@sdddddddddd d d d d gZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddZ ddZ dddZddZGdddZGdddeZGdddZGdddZGdddZGdd d eZdaejZGd!d"d"ejZeZd#d Zd$d Zd%d&Zd'dZd(dZ d)dZ!d*dZ"d+d Z#d,d Z$d-d Z%dS).AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compatcCstjrtj|}nt|dr3|j}tj|r[|j}|j|j fSt |t j rzt |jStjrt |t jrt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder+/opt/alt/python35/lib64/python3.5/events.pyrs     rcCsag}|r&|jdd|D|rL|jdd|jDddj|dS)Ncss|]}tj|VqdS)N)reprlibrepr).0argrrr 0sz*_format_args_and_kwargs..css0|]&\}}dj|tj|VqdS)z{}={}N)formatr r!)r"kvrrrr$2s(z, ))extenditemsjoin)argskwargsr+rrr_format_args_and_kwargs(sr/cCst|tjrAt|||}t|j|j|j|St|drbt |d}n-t|drt |d}n t |}|t||7}|r||7}|S)N __qualname____name__) rrrr/_format_callbackrr-keywordsrgetattrr!)rr-r.suffix func_reprrrrr37s  r3cCs6t||d}t|}|r2|d|7}|S)Nz at %s:%s)r3r)rr-r7sourcerrr_format_callback_sourceHs  r9c@sReZdZdZdd Zd d Zd d ZddZddZdS)r _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsg||_||_||_d|_d|_|jjrZtjtj d|_ n d|_ dS)NF) r=r:r;r<r? get_debug traceback extract_stacksys _getframer>)selfcallbackr-looprrr__init__Vs     zHandle.__init__cCs|jjg}|jr%|jd|jdk rP|jt|j|j|jr|jd}|jd|d|df|S)N cancelledrAzcreated at %s:%sr) __class__r2r<appendr:r9r;r>)rGinfoframerrr _repr_infoas    zHandle._repr_infocCs3|jdk r|jS|j}ddj|S)Nz<%s> )r?rQr,)rGrOrrr__repr__ls zHandle.__repr__cCsF|jsBd|_|jjr0t||_d|_d|_dS)NT)r<r=rBr!r?r:r;)rGrrrcancelrs    z Handle.cancelcCsy|j|jWntk r}zgt|j|j}dj|}d|d|d|i}|jr{|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {}message exceptionhandleZsource_traceback)r:r; Exceptionr9r%r>r=call_exception_handler)rGexccbmsgcontextrrr_run}s   #z Handle._runN)r:r;r<r=r>r?r@) r2 __module__r1 __slots__rJrQrSrTr^rrrrrPs   cseZdZddgZfddZfddZddZd d Zd d Zd dZ ddZ ddZ ddZ fddZ S)r _scheduled_whencs?tj||||jr)|jd=||_d|_dS)NrAFrL)superrJr>rbra)rGwhenrHr-rI)rMrrrJs    zTimerHandle.__init__cs?tj}|jrdnd}|j|d|j|S)NrAzwhen=%s)rcrQr<insertrb)rGrOpos)rMrrrQszTimerHandle._repr_infocCs t|jS)N)hashrb)rGrrr__hash__szTimerHandle.__hash__cCs|j|jkS)N)rb)rGotherrrr__lt__szTimerHandle.__lt__cCs#|j|jkrdS|j|S)NT)rb__eq__)rGrjrrr__le__szTimerHandle.__le__cCs|j|jkS)N)rb)rGrjrrr__gt__szTimerHandle.__gt__cCs#|j|jkrdS|j|S)NT)rbrl)rGrjrrr__ge__szTimerHandle.__ge__cCsYt|trU|j|jkoT|j|jkoT|j|jkoT|j|jkStS)N)rrrbr:r;r<NotImplemented)rGrjrrrrls zTimerHandle.__eq__cCs$|j|}|tkrtS| S)N)rlrp)rGrjZequalrrr__ne__szTimerHandle.__ne__cs*|js|jj|tjdS)N)r<r=_timer_handle_cancelledrcrT)rG)rMrrrTs zTimerHandle.cancel)r2r_r1r`rJrQrirkrmrnrorlrqrTrr)rMrrs         c@s(eZdZddZddZdS)rcCstS)N)rp)rGrrrcloseszAbstractServer.closecCstS)N)rp)rGrrr wait_closedszAbstractServer.wait_closedN)r2r_r1rsrtrrrrrs  c@sCeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$d%d$d&d$d'd$d(d)Zd$d*d+Zd,d,d-d,d#d$d&d$d'd$d.d,d/d,d0d,d1d2Zd,d,d#ejd'ejd.d,d3d4d-d,d5d,d6d,d7d8Zd-d,d.d,d0d,d9d:Zd.d,d3d4d-d,d;d<Zd,d,d#d$d&d$d'd$d5d,d6d,d=d,d.d,d>d?Zd@dAZdBdCZdDe j!dEe j!dFe j!dGdHZ"dDe j!dEe j!dFe j!dIdJZ#dKdLZ$dMdNZ%dOdPZ&dQdRZ'dSdTZ(dUdVZ)dWdXZ*dYdZZ+d[d\Z,d]d^Z-d_d`Z.dadbZ/dcddZ0dedfZ1dgdhZ2didjZ3dkdlZ4dmdnZ5d,S)orcCs tdS)N)NotImplementedError)rGrrr run_foreverszAbstractEventLoop.run_forevercCs tdS)N)ru)rGfuturerrrrun_until_completesz$AbstractEventLoop.run_until_completecCs tdS)N)ru)rGrrrstopszAbstractEventLoop.stopcCs tdS)N)ru)rGrrr is_runningszAbstractEventLoop.is_runningcCs tdS)N)ru)rGrrr is_closedszAbstractEventLoop.is_closedcCs tdS)N)ru)rGrrrrss zAbstractEventLoop.closecCs tdS)N)ru)rGrrrshutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCs tdS)N)ru)rGrWrrrrrsz)AbstractEventLoop._timer_handle_cancelledcGs|jd||S)Nr) call_later)rGrHr-rrr call_soonszAbstractEventLoop.call_sooncGs tdS)N)ru)rGdelayrHr-rrrr} szAbstractEventLoop.call_latercGs tdS)N)ru)rGrdrHr-rrrcall_at szAbstractEventLoop.call_atcCs tdS)N)ru)rGrrrtimeszAbstractEventLoop.timecCs tdS)N)ru)rGrrr create_futureszAbstractEventLoop.create_futurecCs tdS)N)ru)rGcororrr create_taskszAbstractEventLoop.create_taskcGs tdS)N)ru)rGrHr-rrrcall_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGs tdS)N)ru)rGexecutorrr-rrrrun_in_executor sz!AbstractEventLoop.run_in_executorcCs tdS)N)ru)rGrrrrset_default_executor#sz&AbstractEventLoop.set_default_executorfamilyrtypeprotoflagscCs tdS)N)ru)rGhostportrrrrrrr getaddrinfo(szAbstractEventLoop.getaddrinfocCs tdS)N)ru)rGZsockaddrrrrr getnameinfo+szAbstractEventLoop.getnameinfoNsslsock local_addrserver_hostnamec Cs tdS)N)ru) rGprotocol_factoryrrrrrrrrrrrrcreate_connection.sz#AbstractEventLoop.create_connectionbacklogd reuse_address reuse_portc Cs tdS)N)ru) rGrrrrrrrrrrrrr create_server3s'zAbstractEventLoop.create_servercCs tdS)N)ru)rGrpathrrrrrrcreate_unix_connection\sz(AbstractEventLoop.create_unix_connectioncCs tdS)N)ru)rGrrrrrrrrcreate_unix_serverasz$AbstractEventLoop.create_unix_serverallow_broadcastc Cs tdS)N)ru) rGrrZ remote_addrrrrrrrrrrrcreate_datagram_endpointvs!z*AbstractEventLoop.create_datagram_endpointcCs tdS)N)ru)rGrpiperrrconnect_read_pipes z#AbstractEventLoop.connect_read_pipecCs tdS)N)ru)rGrrrrrconnect_write_pipes z$AbstractEventLoop.connect_write_pipestdinstdoutstderrcKs tdS)N)ru)rGrcmdrrrr.rrrsubprocess_shellsz"AbstractEventLoop.subprocess_shellcOs tdS)N)ru)rGrrrrr-r.rrrsubprocess_execsz!AbstractEventLoop.subprocess_execcGs tdS)N)ru)rGfdrHr-rrr add_readerszAbstractEventLoop.add_readercCs tdS)N)ru)rGrrrr remove_readerszAbstractEventLoop.remove_readercGs tdS)N)ru)rGrrHr-rrr add_writerszAbstractEventLoop.add_writercCs tdS)N)ru)rGrrrr remove_writerszAbstractEventLoop.remove_writercCs tdS)N)ru)rGrnbytesrrr sock_recvszAbstractEventLoop.sock_recvcCs tdS)N)ru)rGrdatarrr sock_sendallszAbstractEventLoop.sock_sendallcCs tdS)N)ru)rGraddressrrr sock_connectszAbstractEventLoop.sock_connectcCs tdS)N)ru)rGrrrr sock_acceptszAbstractEventLoop.sock_acceptcGs tdS)N)ru)rGsigrHr-rrradd_signal_handlersz$AbstractEventLoop.add_signal_handlercCs tdS)N)ru)rGrrrrremove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCs tdS)N)ru)rGfactoryrrrset_task_factorysz"AbstractEventLoop.set_task_factorycCs tdS)N)ru)rGrrrget_task_factorysz"AbstractEventLoop.get_task_factorycCs tdS)N)ru)rGrrrget_exception_handlersz'AbstractEventLoop.get_exception_handlercCs tdS)N)ru)rGhandlerrrrset_exception_handlersz'AbstractEventLoop.set_exception_handlercCs tdS)N)ru)rGr]rrrdefault_exception_handlersz+AbstractEventLoop.default_exception_handlercCs tdS)N)ru)rGr]rrrrYsz(AbstractEventLoop.call_exception_handlercCs tdS)N)ru)rGrrrrBszAbstractEventLoop.get_debugcCs tdS)N)ru)rGZenabledrrr set_debugszAbstractEventLoop.set_debug)6r2r_r1rvrxryrzr{rsr|rrr~r}rrrrrrrrrrsocket AF_UNSPEC AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrYrBrrrrrrsv                 $  &   !                   c@sLeZdZddZddZddZddZd d Zd S) rcCs tdS)N)ru)rGrrrrsz&AbstractEventLoopPolicy.get_event_loopcCs tdS)N)ru)rGrIrrrr sz&AbstractEventLoopPolicy.set_event_loopcCs tdS)N)ru)rGrrrr sz&AbstractEventLoopPolicy.new_event_loopcCs tdS)N)ru)rGrrrr sz)AbstractEventLoopPolicy.get_child_watchercCs tdS)N)ru)rGwatcherrrrr "sz)AbstractEventLoopPolicy.set_child_watcherN)r2r_r1rr r r r rrrrrs    c@s_eZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r2r_r1r= _set_calledrrrr_Local6s rcCs|j|_dS)N)r_local)rGrrrrJ:sz#BaseDefaultEventLoopPolicy.__init__cCs|jjdkrJ|jj rJttjtjrJ|j|j|jjdkrut dtjj |jjS)Nz,There is no current event loop in thread %r.) rr=rr threadingcurrent_thread _MainThreadr r RuntimeErrorname)rGrrrr=s z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)NT)rrr=)rGrIrrrr Ks z)BaseDefaultEventLoopPolicy.set_event_loopcCs |jS)N) _loop_factory)rGrrrr Qsz)BaseDefaultEventLoopPolicy.new_event_loop) r2r_r1rrlocalrrJrr r rrrrr's    rc@seZdZdZdZdS) _RunningLoopN)r2r_r1r=_pidrrrrres rcCs2tj}|dk r.tjtjkr.|SdS)N) _running_loopr=rosgetpid)Z running_looprrrrms !cCstjt_|t_dS)N)rrrrr=)rIrrrr xsc Cs7t*tdkr,ddlm}|aWdQRXdS)NrA)DefaultEventLoopPolicy)_lock_event_loop_policyr0r)rrrr_init_event_loop_policys rcCstdkrttS)N)rrrrrrrs cCs |adS)N)r)ZpolicyrrrrscCs&t}|dk r|StjS)N)rrr)Z current_looprrrrs  cCstj|dS)N)rr )rIrrrr scCs tjS)N)rr rrrrr scCs tjS)N)rr rrrrr scCstj|S)N)rr )rrrrr s)&__all__rrrr rrrErrCZasynciorrr/r3r9rrrrrrrLockrrrrrr rrrrr r r r rrrrsR              >8 4"7        PK!Ѥ*__pycache__/protocols.cpython-35.opt-1.pycnu[ Yf@sqdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@sFeZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr6/opt/alt/python35/lib64/python3.5/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs    c@s.eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>s  c@s.eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgs  c@s:eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrts   N)r__all__rrrrrrrrs   7) PK!|sCC0__pycache__/proactor_events.cpython-35.opt-2.pycnu[ ]N@sYdgZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z Gd d d e j e j ZGd ddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdddfddZddZddZdd Zd d Zd d ZddZ e j rddZ dddZ ddZddZddZS)_ProactorBasePipeTransportNcstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk r|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__4/opt/alt/python35/lib64/python3.5/proactor_events.pyr s$             z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr.|jdn|jrD|jd|jdk rm|jd|jj|jdk r|jd|j|jdk r|jd|j|jrt |j}|jd||j r|jddd j |S) Nclosedclosingzfd=%szread=%szwrite=%rzwrite_bufsize=%sz EOF writtenz<%s> ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"     z#_ProactorBasePipeTransport.__repr__cCs||jdr) rUrVrWrrr[ ExceptionrBrr\r)rrnrDr#r#r$rs    z(BaseProactorEventLoop._loop_self_readingcCs|jjddS)Ns)rrl)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs5dfddjdS)Ncsy|dk r|j\}}jr@tjd||}dk rj||dddd|idn"j||dd|idjrdSjj}Wnt k rL}zbj dkrj dd d |d ij njr:tjd d dWYdd}~Xn?t jk rjj Yn!X|jj <|jdS)Nz#%r got a new connection from %r: %rrTr r|r!rr=zAccept failed on a socketr>rHzAccept failed on socket %rr<)rUZ_debugr rArrrrVrrZr*rBr7rr[rr\)rnconnaddrrrD)rprotocol_factoryrr!rrr#r$rs>            z2BaseProactorEventLoop._start_serving..loop)r)rrrrr!backlogr#)rrrr!rrr$_start_servings$$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_eventssz%BaseProactorEventLoop._process_eventscCs5x!|jjD]}|jqW|jjdS)N)rvaluesr6clear)rfuturer#r#r$rsz*BaseProactorEventLoop._stop_accept_futurescCs(|j|jj||jdS)N)rrV _stop_servingr7)rrr#r#r$r#s z#BaseProactorEventLoop._stop_serving)r(rLrMr rrrrrr7rrrrrrrrrrrrrr#r#)r"r$r{s4           (  )__all__rHr8rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrNZWriteTransportr_rrZ Transportryr{Z BaseEventLooprr#r#r#r$s.     M T  PK!Ƿ00%__pycache__/transports.cpython-35.pycnu[ YfR'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sdeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkri}||_dS)N)_extra)selfextrar 7/opt/alt/python35/lib64/python3.5/asyncio/transports.py__init__ s zBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCs tdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCs tdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCs tdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCs tdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s.eZdZdZddZddZdS)rz#Interface for read-only transports.cCs tdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCs tdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-s  c@speZdZdZddddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCs tdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCs tdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCs tdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCs tj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineseszWriteTransport.writelinescCs tdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCs tdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCs tdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort) rrrrr!r"r$r%r&r'r(r r r r rAs    c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rs c@s1eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCs tdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCs tdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)rrrrr)r(r r r r rs  c@sXeZdZddZddZddZddZd d Zd d Zd S)rcCs tdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCs tdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCs tdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCs tdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCs tdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCs tdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs      cseZdZdZddfddZddZddZd d Zddd d Zddd dZ ddZ S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. NcsBtj||dk s"t||_d|_|jdS)NF)superrAssertionError_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs   z_FlowControlMixin.__init__cCs|j}||jkrdS|jsd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NTmessagezprotocol.pause_writing() failed exception transportr)r" _high_waterr6 _protocolZ pause_writing Exceptionr5call_exception_handler)r sizeexcr r r _maybe_pause_protocols    z'_FlowControlMixin._maybe_pause_protocolcCs|jr|j|jkrd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NFr9z protocol.resume_writing() failedr:r;r)r6r" _low_waterr=Zresume_writingr>r5r?)r rAr r r _maybe_resume_protocols   z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rCr<)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCs|dkr+|dkr!d}n d|}|dkrA|d}||koXdknsstd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr<rC)r rr r r r r7s       z*_FlowControlMixin._set_write_buffer_limitscCs$|jd|d||jdS)Nrr )r7rB)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCs tdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size) rrrrrrBrDrEr7r!r"r r )r8r r2s    r2N) rZasyncior__all__rrrrrrr2r r r r s #D4PK!m>e'__pycache__/compat.cpython-35.opt-2.pycnu[ ]@sIddlZejdkZejd kZejd kZddZdS) NcCs&tsdd|D}dj|S)Ncss0|]&}t|tr$t|n|VqdS)N) isinstance memoryviewbytes).0datar +/opt/alt/python35/lib64/python3.5/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes s  r)rr)rr)rrr)sys version_inforZPY35ZPY352rr r r r s PK!wS8S8&__pycache__/tasks.cpython-35.opt-2.pycnu[ ]g @s=dddddddddd d d d g Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZGddde jZej jZej jZej jZedddddeddZddZeddddZeddZddddddZedddd dZddd!d"ZeedCs z!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks;s  zTask.all_tasksrcsktjd||jr&|jd=||_d|_d|_|jj|j|j j j |dS)NrrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r!add)selfcoror)r,rrr%Es     z Task.__init__cCsg|jtjkrS|jrSd|ddi}|jrC|j|d<|jj|tjj|dS)Ntaskmessagez%Task was destroyed but it is pending!Zsource_traceback) _staterZ_PENDING_log_destroy_pendingr&rZcall_exception_handlerFuture__del__)r.contextrrrr5Ts   z Task.__del__csrtj}|jr"d|dz wait_for=%r)r$ _repr_infor)rZ_format_coroutiner'insertr()r.infor/)r,rrr8_s  zTask._repr_infolimitc Cs g}y|jj}Wntk r6|jj}YnX|dk rxI|dk r|dk ru|dkrkP|d8}|j||j}qFW|jnj|jdk r|jj}xL|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) r'cr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)r.r;Zframesftbrrr get_stackms0             zTask.get_stackfilec Cs]g}t}x|jd|D]}|j}|j}|j}|j} ||krr|j|tj|tj |||j } |j ||| | fq"W|j } |st d|d|n7| dk rt d|d|nt d|d|tj|d|| dk rYx3tj| j| D]} t | d|ddq9WdS)Nr;zNo stack for %rrIz)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):end)setrHf_linenof_code co_filenameco_namer- linecache checkcachegetline f_globalsr?rBprint traceback print_listformat_exception_onlyr,) r.r;rIextracted_listZcheckedrFlinenocofilenamenamelineexcrrr print_stacks0               zTask.print_stackcCsHd|_|jrdS|jdk r;|jjr;dSd|_dS)NFT)Z_log_tracebackdoner(cancelr))r.rrrrbs   z Task.cancelcs|jr0t|tjs'tj}d|_|j}d|_||jj|j.)risfuturer iscoroutine TypeErrortyperx ValueErrorrrrrprrrL_wait)fsrr~rr)rrrLs   cGs|js|jddS)N)rarj)waiterargsrrr_release_waiterls rccs |dkrtj}|dkr-|EdHS|j}|j|t|}tjt|}t|d|}|j|z|y |EdHWn/t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)Nr)rr create_future call_laterr functoolspartialr rqrreremove_done_callbackrbraru TimeoutError)futr~rrtimeout_handlecbrrrrqs,             c #s|jd|dk r3|j|tt|fdd}x|D]}|j|qaWz EdHWddk rjXtt}}xD|D]<}|j||jr|j |q|j |qW||fS)Ncsd8dksMtksMtkr||j r||jdk r|dk rcjjs|jddS)Nrr)rr cancelled exceptionrbrarj)rF)counterrrrrr_on_completions      z_wait.._on_completion) rrrlenrqrbrLrrar-)rr~rrrrFrapendingr)rrrrrrs&          rc#sLtj|stj|r7tdt|jdk rIn tjfddt |Dddl m }|ddfdd}fd d t fd d }xD]}|j qWr#|dk r#j||x"ttD]}|Vq6WdS) Nz expect a list of futures, not %scs"h|]}t|dqS)r)r )rrF)rrrr s zas_completed..r)Queuercs9x(D] }|jjdqWjdS)N)r put_nowaitclear)rF)rratodorr _on_timeouts  z!as_completed.._on_timeoutcsEs dSj|j| rAdk rAjdS)N)removerrb)rF)rarrrrrs   z$as_completed.._on_completionc3s0jEdH}|dkr&tj|jS)N)rrrru)rF)rarr _wait_for_ones  z#as_completed.._wait_for_one)rrrrrrrxrrrLqueuesrrrqrranger)rrr~rrrrF_r)rrarrrrrs  c csv|dkrdV|S|dkr-tj}|j}|jj|tj||}z |EdHSWd|jXdS)Nr)rrrrrrZ_set_result_unless_cancelledrb)delayrurrwhrrrrs       cCs&tjdtddt|d|S)Nz;asyncio.async() function is deprecated, use ensure_future() stacklevelr7r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_s rcCstj|r:|dk r6||jk r6td|Stj|r|dkratj}|j|}|j r|j d=|St j rt j |rtt|d|StddS)Nz$loop argument must agree with Futurerrz:An asyncio.Future, a coroutine or an awaitable is requiredr#)rrrrrrrrZ create_taskr&rZPY35rsZ isawaitabler _wrap_awaitabler)rrr0rrrr +s     ccs|jEdHS)N) __await__)Z awaitablerrrrBsrcs4eZdZddfddZddZS)_GatheringFuturerNcs tjd|||_dS)Nr)r$r% _children)r.childrenr)r,rrr%Tsz_GatheringFuture.__init__cCs@|jrdSd}x#|jD]}|jr d}q W|S)NFT)rarrb)r.retZchildrrrrbXs   z_GatheringFuture.cancel)rxryrzr%rbrr)r,rrLs rreturn_exceptionsFcs|s;|dkrtj}|jjgSixt|D]}tj|st|d|}|dkr|j}d|_ n9|}|dkr|j}n|j|k rt d||s zgather..rcsjr&|js"|jdS|jrXtj}sj|dSn>|jdk r|j}sj|dSn |j}||<d7krjdS)Nr) rarrrrerirB_resultrj)irres) nchildren nfinishedouterresultsrrr_done_callbacks&            zgather.._done_callback)rrrrjrLrrr rr3rrr enumeraterqrr)rrZcoros_or_futuresrrrrrr)rrrrrrrr bs8            csZt|d|}|jr"|S|j}|jfdd}|j|S)Nrcs~jr&|js"|jdS|jr?jn;|j}|dk rgj|nj|jdS)N)rrrbrirjru)innerr_)rrrrs       zshield.._done_callback)r rarrrq)rrrrr)rrr s    csStjstdtjjfdd}j|S)NzA coroutine object is requiredcshy tjtdWnAtk rc}z!jrNj|WYdd}~XnXdS)Nr)rZ _chain_futurer rlset_running_or_notify_cancelri)r_)r/rwrrrcallbacks    z*run_coroutine_threadsafe..callback)rrr concurrentrr4Zcall_soon_threadsafe)r/rrr)r/rwrrr s   )#__all__concurrent.futuresrrrsrQrVrr{rKrrrrrr4rrrrrrrrrrrglobalsrxr rrr r r rrrrsN        0    --8   T5PK!_~r88+__pycache__/subprocess.cpython-35.opt-1.pycnu[ Yf @s ddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejddZedddddddddejddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercspeZdZdZfddZddZddZdd Zd d Zd d Z ddZ S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csRtjd|||_d|_|_|_d|_d|_g|_dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__7/opt/alt/python35/lib64/python3.5/asyncio/subprocess.pyrs    z!SubprocessStreamProtocol.__init__cCs|jjg}|jdk r2|jd|j|jdk rU|jd|j|jdk rx|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__sz!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk retjd|jd|j|_|jj||jj d|jd}|dk rtjd|jd|j|_ |j j||jj d|jd}|dk rtj |d|ddd|j|_ dS)Nrrr rprotocolreader) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&     z(SubprocessStreamProtocol.connection_madecCsS|dkr|j}n|dkr0|j}nd}|dk rO|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@s     z+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr<|j}|dk r+|j|j|dS|dkrT|j}n|dkrl|j}nd}|dkr|dkr|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$             z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedas z'SubprocessStreamProtocol.process_exitedcCs8t|jdkr4|jr4|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/rr)rrr s    r c@seZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCsR||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrls      zProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr<szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr>szProcess.terminatecCs|jjdS)N)rkill)rrrrr?sz Process.killccs|jj}|jj||r>tjd|t|y|jjEdHWnDtt fk r}z|rtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrBr0rrr _feed_stdins &zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr*|j}n |j}|jjrm|dkrTdnd}tjd|||jEdH}|jjr|dkrdnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&r@r rBreadr-)rr*r(streamnameoutputrrr _read_streams    zProcess._read_streamNccs|dk r|j|}n |j}|jdk rK|jd}n |j}|jdk rx|jd}n |j}tj|||d|jEdH\}}}|jEdH||fS)Nrr!r ) rFrGrrLrrZgatherr&r;)rrErrrrrr communicates    zProcess.communicate)rr5r6rr propertyr:r r;r<r>r?rFrGrLrMrrrrr8ks     r8c +sodkrtjfdd}j||d|d|d||EdH\}} t|| S)NcstddS)Nrr )r r)rr rrs z)create_subprocess_shell..rrr)rget_event_loopZsubprocess_shellr8) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs  rrrr rc /srdkrtjfdd}j|||d|d|d||EdH\} } t| | S)NcstddS)Nrr )r r)rr rrrOs z(create_subprocess_exec..rrr)rrPZsubprocess_execr8) Zprogramrrrr rargsrRrSr(r"r)rr rrs    )__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r8Z_DEFAULT_LIMITrrrrrrs(      X]    PK!&>>(__pycache__/futures.cpython-35.opt-1.pycnu[ YfD@sNdZddddddgZddlZddlZddlZddlZddlZd d lm Z d d lm Z d Z d Z dZ ejjjZejjZejjZejd ZGdddeZGdddZddZGdddZddZddZddZddZddddZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN)compat)eventsZPENDINGZ CANCELLEDZFINISHEDc@seZdZdZdS)rz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__rr4/opt/alt/python35/lib64/python3.5/asyncio/futures.pyrs c@sLeZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs.|j|_|j|_||_d|_dS)N)_loopr_source_tracebackrrr)selffuturerrrr__init__Us   z_TracebackLogger.__init__cCs@|j}|dk r<d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivate[s    z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclearbs z_TracebackLogger.clearcCs|jrd}|jrQdjtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstriprcall_exception_handler)rmsgsrcrrr__del__fs   z_TracebackLogger.__del__N)rrrr) r r r r __slots__rrr r)rrrrr!s 0   rcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattrrr+)objrrrrqsc@s$eZdZdZeZdZdZdZdZ dZ dZ dZ ddddZ ddZd d Zd d Zejrd dZddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zejr eZ dS)%raThis class is *almost* compatible with concurrent.futures.Future. Differences: - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon_threadsafe(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFrcCs^|dkrtj|_n ||_g|_|jjrZtjtjd|_ dS)zInitialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r get_event_loopr _callbacksZ get_debugr extract_stacksys _getframer)rrrrrrs    zFuture.__init__cCs|j}t|}|s!d}dd}|dkrL||d}nn|dkrdj||d||d}n9|dkrdj||d|d||d }d |S) Nr!cSstj|fS)N)r Z_format_callback_source)callbackrrr format_cbsz,Future.__format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])r/lenformat)rcbsizer4rrrZ__format_callbackss     ) zFuture.__format_callbackscCs|jjg}|jtkrt|jdk rL|jdj|jn(tj|j}|jdj||j r|j|j |j r|j d}|jd|d|df|S)Nzexception={!r}z result={}rzcreated at %s:%srr6) _statelower _FINISHED _exceptionappendr8reprlibrepr_resultr/_Future__format_callbacksr)rinforesultframerrr _repr_infos   zFuture._repr_infocCs)|j}d|jjdj|fS)Nz<%s %s> )rGrr r#)rrDrrr__repr__s zFuture.__repr__cCsb|js dS|j}dd|jjd|d|i}|jrN|j|d<|jj|dS)Nr"z %s exception was never retrieved exceptionrr)_log_tracebackr>rr rrr&)rrcontextrrrr)s      zFuture.__del__cCs3d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)rKr;_PENDING _CANCELLED_schedule_callbacks)rrrrcancels    z Future.cancelcCsX|jdd}|sdSg|jddrB)rrrrrEs     z Future.resultcCse|jtkrt|jtkr0tdd|_|jdk r^|jjd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.FN) r;rNrr=rrKrTr r>)rrrrrJ)s    zFuture.exceptioncCs9|jtkr%|jj||n|jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r;rMrrQr/r?)rfnrrradd_done_callback;szFuture.add_done_callbackcsRfdd|jD}t|jt|}|rN||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs"g|]}|kr|qSrr).0f)rUrr Ns z/Future.remove_done_callback..N)r/r7)rrUZfiltered_callbacksZ removed_countr)rUrremove_done_callbackIs zFuture.remove_done_callbackcCsJ|jtkr*tdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r;rMrr8rBr=rO)rrErrr set_resultVs   zFuture.set_resultcCs|jtkr*tdj|j|t|trB|}t|tkr`td||_t |_|j t j rd|_ n(t|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r;rMrr8 isinstancetype StopIteration TypeErrorr>r=rOr PY34rKrrTrrQr)rrJrrr set_exceptionbs       zFuture.set_exceptionccs$|jsd|_|V|jS)NT)rSr+rE)rrrr__iter__zs  zFuture.__iter__)!r r r rrMr;rBr>rrr+rKrTrrCrGrIr r`r)rPrOrRrSrErJrVrZr[rarbZPY35 __await__rrrrr|s8                 cCs!|jrdS|j|dS)z?Helper setting the result only if the future was not cancelled.N)rRr[)ZfutrErrr_set_result_unless_cancelleds rdcCsk|jr|j|js&dS|j}|dk rN|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N)rRrPZset_running_or_notify_cancelrJrarEr[) concurrentsourcerJrErrr_set_concurrent_future_states      rgcCsn|jrdS|jr)|jnA|j}|dk rQ|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rRrPrJrarEr[)rfdestrJrErrr_copy_future_states      ricst r/ttjj r/tdt r^ttjj r^tdtrsjndtrjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs-t|rt||n t||dS)N)rrirg)rotherrrr _set_states z!_chain_future.._set_statecsE|jrAdks$kr1jnjjdS)N)rRrPcall_soon_threadsafe) destination) dest_looprf source_looprr_call_check_cancels  z)_chain_future.._call_check_cancelcs?dkskr(|nj|dS)N)rl)rf)rkrnrmrorr_call_set_statesz&_chain_future.._call_set_state)rr\refuturesrr_rrV)rfrmrprqr)rkrnrmrfror _chain_futures    rsrcCsEt|r|S|dkr(tj}|j}t|||S)z&Wrap concurrent.futures.Future object.N)rr r.Z create_futurers)rrZ new_futurerrrrs     )r__all__Zconcurrent.futures._basereZloggingr@r1rr!r r rMrNr=rrZ_baseErrorrrDEBUGZ STACK_DEBUGrrrrrdrgrirsrrrrrs6        P     'PK!3cc#__pycache__/__init__.cpython-35.pycnu[ Yf@sdZddlZyddlmZWnek rFddlZYnXejdkryddlmZWnek rddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkrqddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorswin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsrr5/opt/alt/python35/lib64/python3.5/asyncio/__init__.pys8              E   PK!X(__pycache__/windows_utils.cpython-35.pycnu[ Yf@sJdZddlZejdkr-edddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdd dZd d ddde ddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces Nwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Csk|tjkrd}n$|tjkr0d}n td|tjkrWtd|dkrotdtj|||}z|j|df|jd|jdd \}}tj|||}yb|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r:/opt/alt/python35/lib64/python3.5/asyncio/windows_utils.pyr%s8            duplexF overlappedTbufsizec Cstjddtjttf}|rWtj}tjtj B}||}}ntj }tj }d|}}|tj O}|dr|tj O}|drtj }nd}d} } ytj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fSWn=| dk rftj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.prefixz\\.\pipe\python-pipe-%d-%d-rrNrT)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@                 c@seZdZdZddZddZeddZdd Zd e j d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs9|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r# __class____name__)r$r%rrr__repr__szPipeHandle.__repr__cCs|jS)N)r#)r$rrrr%szPipeHandle.handlecCs"|jdkrtd|jS)NzI/O operatioon on closed pipe)r#r )r$rrrfilenos zPipeHandle.filenor!cCs)|jdk r%||jd|_dS)N)r#)r$r!rrrrs zPipeHandle.closecCs1|jdk r-tjd|t|jdS)Nz unclosed %r)r#warningswarnResourceWarningr)r$rrr__del__szPipeHandle.__del__cCs|S)Nr)r$rrr __enter__szPipeHandle.__enter__cCs|jdS)N)r)r$tvtbrrr__exit__szPipeHandle.__exit__N)r) __module__ __qualname____doc__r&r*propertyr%r+r r!rr/r0r4rrrrrs      cs1eZdZdZdddfddZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s4|jd st|jdddks4td}}}d} } } |tkrtdd dd\} } tj| tj}n|}|tkrtdd \} } tj| d}n|}|tkrtdd \} }tj|d}n|tkr|}n|}zy)t j |d|d |d ||Wn>x0| | | fD]}|dk rdt j |qdWYnRX| dk rt | |_| dk rt | |_| dk rt | |_Wd|tkrtj||tkrtj||tkr/tj|XdS)NZuniversal_newlinesrrrFTrstdinstdoutstderr)FT)TF)TF)getAssertionErrorrrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr&r r!rr9r:r;r)r$argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r(rrr&sL              zPopen.__init__)r)r5r6r7r&rr)r(rrs )TT)r7sysplatform ImportErrorr itertoolsr>rr subprocessrr,__all__ZBUFSIZErr@countrhasattrrr r rrrrrrrs,              .0,PK!0ѬTT#__pycache__/sslproto.cpython-35.pycnu[ Yf]e @sddlZddlZyddlZWnek rBdZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCs|rtdttdr?tj}|sd|_nLtjtj}|jtjO_|jtj O_|j tj |_ |S)Nz(Server side SSL needs a valid SSLContextcreate_default_contextF) ValueErrorhasattrsslrcheck_hostnameZ SSLContextZPROTOCOL_SSLv23ZoptionsZ OP_NO_SSLv2Z OP_NO_SSLv3Zset_default_verify_pathsZ CERT_REQUIRED verify_mode) server_sideserver_hostname sslcontextr5/opt/alt/python35/lib64/python3.5/asyncio/sslproto.py_create_transport_contexts     rcCs ttdS)N MemoryBIO)r r rrrr_is_sslproto_available%srZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@seZdZdZdZdddZeddZed d Zed d Z ed dZ dddZ dddZ ddZ dddZdddZdS)_SSLPipeaAn SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). iNcCsj||_||_||_t|_tj|_tj|_d|_ d|_ d|_ d|_ dS)a The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) _context _server_side_server_hostname _UNWRAPPED_stater r _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextrrrrr__init__Ds       z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r)r#rrrr$Zsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )r)r#rrr ssl_object_sz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake that is currently in progress.)r )r#rrr need_ssldatagsz_SSLPipe.need_ssldatacCs |jtkS)zj Whether a security layer is currently in effect. Return False during handshake. )r_WRAPPED)r#rrrwrappedmsz_SSLPipe.wrappedcCs|jtkrtd|jj|j|jd|jd|j|_ t |_||_ |j ddd\}}t |dkst|S)aLStart the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completedrronly_handshakeTr)rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr! feed_ssldatalenAssertionError)r#callbackssldataappdatarrr do_handshakevs      z_SSLPipe.do_handshakecCs|jtkrtd|jtkr6td|jttfksQtt|_||_|jd\}}|gks|dgkst|S)a1Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. zno security layer presentzshutdown in progressr*) rrr, _SHUTDOWNr(r-r0r"r.)r#r1r2r3rrrshutdowns     !z_SSLPipe.shutdowncCsG|jj|jd\}}|gksC|dgksCtdS)zSend a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. r*N)rZ write_eofr.r0)r#r2r3rrrfeed_eofs z_SSLPipe.feed_eofFcCs|jtkr1|r!|g}ng}g|fSd|_|rP|jj|g}g}y|jtkr|jjt|_|j r|j d|r||fS|jtkrx|jj |j }|j ||sPqWni|jt kr0|jjd|_t|_|jrU|jn%|jtkrU|j |jj Wntjtjfk r}zlt|ddtjtjtjfkr|jtkr|j r|j ||jtjk|_WYdd}~XnX|jjr|j |jj ||fS)aFeed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). FNerrno)rrr rwriter-rr4r(r!readmax_sizeappendr5Zunwrapr"r SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr8rpending)r#datar+r3r2chunkexcrrrr.sV                ( z_SSLPipe.feed_ssldatarcCsd|kot|kns(t|jtkru|t|kr_||dg}ng}|t|fSg}t|}xd|_y6|t|kr||jj||d7}Wn|tj k rG}zY|j dkrtj |_ |j tj tj tjfkr |j tj k|_WYdd}~XnX|jjrj|j|jj|t|ks|jrPqW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. rNFZPROTOCOL_IS_SHUTDOWN)r/r0rr memoryviewr rr9r r=reasonr@r8rArBrrCr<r:)r#rDoffsetr2ZviewrFrrr feed_appdatas4(  $  ( z_SSLPipe.feed_appdatai)__name__ __module__ __qualname____doc__r;r%propertyr$r&r'r)r4r6r7r.rJrrrrr0s   Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rlddZ ddZ ddZ ddddZddZddZddZddZdS)_SSLProtocolTransportcCs(||_||_||_d|_dS)NF)_loop _ssl_protocol _app_protocol_closed)r#loopZ ssl_protocol app_protocolrrrr%)s   z_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rR_get_extra_info)r#namedefaultrrrget_extra_info0sz$_SSLProtocolTransport.get_extra_infocCs ||_dS)N)rS)r#protocolrrr set_protocol4sz"_SSLProtocolTransport.set_protocolcCs|jS)N)rS)r#rrr get_protocol7sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rT)r#rrr is_closing:sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rTrR_start_shutdown)r#rrrclose=s z_SSLProtocolTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rTwarningswarnResourceWarningr`)r#rrr__del__Ls z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rR _transport pause_reading)r#rrrrfQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rRreresume_reading)r#rrrrgYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rRreset_write_buffer_limits)r#ZhighZlowrrrrhasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjjS)z,Return the current size of the write buffer.)rRreget_write_buffer_size)r#rrrrivsz+_SSLProtocolTransport.get_write_buffer_sizecCsTt|tttfs6tdjt|j|s@dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrG TypeErrorformattyperKrR_write_appdata)r#rDrrrr9zs  z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rR_abort)r#rrrabortsz_SSLProtocolTransport.abort)rKrLrMr%rZr\r]r^r`rZPY34rdrfrgrhrir9rqrsrrrrrP&s            rPc@seZdZdZdddddZdddZd d Zd d Zd dZddZ ddZ ddZ dddZ ddZ ddZddZddZdd Zd!d"d#Zd$d%Zd&d'ZdS)( SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|s-t||}||_|rO| rO||_n d|_||_td||_tj |_ d|_ ||_ ||_ ||_t|j ||j|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not availablerrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrQrSrP_app_transport_sslpipe_session_established _in_handshake _in_shutdownre_call_connection_made)r#rUrVrZwaiterrrZcall_connection_maderrrr%s.                 zSSLProtocol.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)r|Z cancelledZ set_exceptionZ set_result)r#rFrrr_wakeup_waiters zSSLProtocol._wakeup_waitercCs5||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rerrurrr~_start_handshake)r# transportrrrconnection_mades   zSSLProtocol.connection_madecCsN|jr+d|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)rrQ call_soonrSconnection_lostrer}r)r#rFrrrrs     zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rS pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rSresume_writing)r#rrrrszSSLProtocol.resume_writingcCsy|jj|\}}Wnatjk r}z>|jjr_tjd||j|j |j dSWYdd}~XnXx|D]}|j j |qWx2|D]*}|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. z%r: SSL error %s (reason %s)N)r~r.r r=rQ get_debugrwarningr8rHrrrer9rS data_receivedr_)r#rDr2r3erErrrrs     zSSLProtocol.data_receivedc Cspz[|jjr"tjd||jt|jsZ|jj}|rZtj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rQrrdebugrConnectionResetErrorrrS eof_receivedrrer`)r#Z keep_openrrrrs  zSSLProtocol.eof_receivedcCsD||jkr|j|S|jdk r<|jj||S|SdS)N)rwrerZ)r#rXrYrrrrWs  zSSLProtocol._get_extra_infocCs=|jr dS|jr#|jnd|_|jddS)NTr*)rrrrrp)r#rrrr_&s     zSSLProtocol._start_shutdowncCs9|jj|df|jt|7_|jdS)Nr)rzr<r{r/_process_write_backlog)r#rDrrrrp/szSSLProtocol._write_appdatacCsm|jjr4tjd||jj|_n d|_d|_|jjd|jj |j dS)Nz%r starts SSL handshakeTr*r)r*r) rQrrrtime_handshake_start_timerrzr<rr)r#rrrr4s  zSSLProtocol._start_handshakecCsd|_|jj}ye|dk r*||j}t|jdsy|jry|jjtj krytj ||jWnt k r!}z|j j rt|tjrtjd|ddntjd|dd|jjt|tr |j|dSWYdd}~XnX|j j r^|j j|j}tjd||d|jjd |d |jd |jd ||jr|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateexc_infoTz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@peercertcipher compressionr&)$rr~r&Z getpeercertr rurr r Z CERT_NONEZmatch_hostname BaseExceptionrQrrjr>rrrer` ExceptionrrrrrwupdaterrrrSrr}rrr)r#Z handshake_excZsslobjrrFZdtrrr_on_handshake_complete@sD               z"SSLProtocol._on_handshake_completecCs|jdkrdSy+x$tt|jD] }|jd\}}|ri|jj||\}}n?|r|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj st |jj r|jjP|jd=|jt|8_q,WWn`tk r}z@|jrl|j|n|j|dt|tsWYdd}~XnXdS)NrrzFatal error on SSL transport)reranger/rzr~rJr4rr6 _finalizer9r'r0Z_pausedrgr{rr _fatal_errorrjr)r#irDrIr2rErFrrrrts:        z"SSLProtocol._process_write_backlogzFatal error on transportc Cst|tjr=|jjrhtjd||ddn+|jjd|d|d|jd|i|jr|jj |dS)Nz%r: %srTmessageZ exceptionrr[) rjrZ_FATAL_ERROR_IGNORErQrrrZcall_exception_handlerreZ _force_close)r#rFrrrrrs    zSSLProtocol._fatal_errorcCs)d|_|jdk r%|jjdS)N)r~rer`)r#rrrrs zSSLProtocol._finalizec Cs2z |jdk r|jjWd|jXdS)N)rersr)r#rrrrrszSSLProtocol._abort)rKrLrMrNr%rrrrrrrrWr_rprrrrrrrrrrrrts& #       4 , rt)rxrar ImportErrorrrrrlogrrrrr-r(r5objectrZ_FlowControlMixinZ TransportrPZProtocolrtrrrrs(       nPK!ٕZeZe'__pycache__/events.cpython-35.opt-1.pycnu[ YfTY@s dZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddZ ddZdddZddZGdddZGdddeZGdddZGdddZGdddZGd d!d!eZdae jZGd"d#d#e jZeZd$dZd%d Zd&d'Zd(dZ d)dZ!d*dZ"d+d Z#d,d Z$d-d Z%d.d Z&dS)/z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compatcCstjrtj|}nt|dr3|j}tj|r[|j}|j|j fSt |t j rzt |jStjrt |t jrt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder3/opt/alt/python35/lib64/python3.5/asyncio/events.pyrs     rcCsag}|r&|jdd|D|rL|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argrrr 0sz*_format_args_and_kwargs..css0|]&\}}dj|tj|VqdS)z{}={}N)formatr r!)r"kvrrrr$2s(z, ))extenditemsjoin)argskwargsr+rrr_format_args_and_kwargs(sr/cCst|tjrAt|||}t|j|j|j|St|drbt |d}n-t|drt |d}n t |}|t||7}|r||7}|S)N __qualname____name__) rrrr/_format_callbackrr-keywordsrgetattrr!)rr-r.suffix func_reprrrrr37s  r3cCs6t||d}t|}|r2|d|7}|S)Nz at %s:%s)r3r)rr-r7sourcerrr_format_callback_sourceHs  r9c@sXeZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsg||_||_||_d|_d|_|jjrZtjtj d|_ n d|_ dS)NF) r=r:r;r<r? get_debug traceback extract_stacksys _getframer>)selfcallbackr-looprrr__init__Vs     zHandle.__init__cCs|jjg}|jr%|jd|jdk rP|jt|j|j|jr|jd}|jd|d|df|S)NZ cancelledrAzcreated at %s:%sr) __class__r2r<appendr:r9r;r>)rGinfoframerrr _repr_infoas    zHandle._repr_infocCs3|jdk r|jS|j}ddj|S)Nz<%s> )r?rPr,)rGrNrrr__repr__ls zHandle.__repr__cCsF|jsBd|_|jjr0t||_d|_d|_dS)NT)r<r=rBr!r?r:r;)rGrrrcancelrs    z Handle.cancelcCsy|j|jWntk r}zgt|j|j}dj|}d|d|d|i}|jr{|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {}messageZ exceptionhandleZsource_traceback)r:r; Exceptionr9r%r>r=call_exception_handler)rGexccbmsgcontextrrr_run}s   #z Handle._runN)r:r;r<r=r>r?r@) r2 __module__r1__doc__ __slots__rJrPrRrSr\rrrrrPs   cseZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZS)rz7Object returned by timed callback registration methods. _scheduled_whencs?tj||||jr)|jd=||_d|_dS)NrAFrK)superrJr>rar`)rGwhenrHr-rI)rLrrrJs    zTimerHandle.__init__cs?tj}|jrdnd}|j|d|j|S)NrAzwhen=%s)rbrPr<insertra)rGrNpos)rLrrrPszTimerHandle._repr_infocCs t|jS)N)hashra)rGrrr__hash__szTimerHandle.__hash__cCs|j|jkS)N)ra)rGotherrrr__lt__szTimerHandle.__lt__cCs#|j|jkrdS|j|S)NT)ra__eq__)rGrirrr__le__szTimerHandle.__le__cCs|j|jkS)N)ra)rGrirrr__gt__szTimerHandle.__gt__cCs#|j|jkrdS|j|S)NT)rark)rGrirrr__ge__szTimerHandle.__ge__cCsYt|trU|j|jkoT|j|jkoT|j|jkoT|j|jkStS)N)rrrar:r;r<NotImplemented)rGrirrrrks zTimerHandle.__eq__cCs$|j|}|tkrtS| S)N)rkro)rGriZequalrrr__ne__szTimerHandle.__ne__cs*|js|jj|tjdS)N)r<r=_timer_handle_cancelledrbrS)rG)rLrrrSs zTimerHandle.cancel)r2r]r1r^r_rJrPrhrjrlrmrnrkrprSrr)rLrrs         c@s.eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)ro)rGrrrcloseszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)ro)rGrrr wait_closedszAbstractServer.wait_closedN)r2r]r1r^rrrsrrrrrs  c@sIeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%d&d%d'd%d(d%d)d*Zd%d+d,Zd-d-d.d-d$d%d'd%d(d%d/d-d0d-d1d-d2d3Zd-d-d$ejd(ejd/d-d4d5d.d-d6d-d7d-d8d9Zd.d-d/d-d1d-d:d;Zd/d-d4d5d.d-d<d=Zd-d-d$d%d'd%d(d%d6d-d7d-d>d-d/d-d?d@ZdAdBZdCdDZ dEe!j"dFe!j"dGe!j"dHdIZ#dEe!j"dFe!j"dGe!j"dJdKZ$dLdMZ%dNdOZ&dPdQZ'dRdSZ(dTdUZ)dVdWZ*dXdYZ+dZd[Z,d\d]Z-d^d_Z.d`daZ/dbdcZ0dddeZ1dfdgZ2dhdiZ3djdkZ4dldmZ5dndoZ6d-S)przAbstract event loop.cCs tdS)z*Run the event loop until stop() is called.N)NotImplementedError)rGrrr run_foreverszAbstractEventLoop.run_forevercCs tdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)rt)rGZfuturerrrrun_until_completesz$AbstractEventLoop.run_until_completecCs tdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)rt)rGrrrstopszAbstractEventLoop.stopcCs tdS)z3Return whether the event loop is currently running.N)rt)rGrrr is_runningszAbstractEventLoop.is_runningcCs tdS)z*Returns True if the event loop was closed.N)rt)rGrrr is_closedszAbstractEventLoop.is_closedcCs tdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)rt)rGrrrrrs zAbstractEventLoop.closecCs tdS)z,Shutdown all active asynchronous generators.N)rt)rGrrrshutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCs tdS)z3Notification that a TimerHandle has been cancelled.N)rt)rGrUrrrrqsz)AbstractEventLoop._timer_handle_cancelledcGs|jd||S)Nr) call_later)rGrHr-rrr call_soonszAbstractEventLoop.call_sooncGs tdS)N)rt)rGZdelayrHr-rrrr{ szAbstractEventLoop.call_latercGs tdS)N)rt)rGrcrHr-rrrcall_at szAbstractEventLoop.call_atcCs tdS)N)rt)rGrrrtimeszAbstractEventLoop.timecCs tdS)N)rt)rGrrr create_futureszAbstractEventLoop.create_futurecCs tdS)N)rt)rGcororrr create_taskszAbstractEventLoop.create_taskcGs tdS)N)rt)rGrHr-rrrcall_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGs tdS)N)rt)rGexecutorrr-rrrrun_in_executor sz!AbstractEventLoop.run_in_executorcCs tdS)N)rt)rGrrrrset_default_executor#sz&AbstractEventLoop.set_default_executorfamilyrtypeprotoflagscCs tdS)N)rt)rGhostportrrrrrrr getaddrinfo(szAbstractEventLoop.getaddrinfocCs tdS)N)rt)rGZsockaddrrrrr getnameinfo+szAbstractEventLoop.getnameinfoNsslsock local_addrserver_hostnamec Cs tdS)N)rt) rGprotocol_factoryrrrrrrrrrrrrcreate_connection.sz#AbstractEventLoop.create_connectionbacklogd reuse_address reuse_portc Cs tdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)rt) rGrrrrrrrrrrrrr create_server3s'zAbstractEventLoop.create_servercCs tdS)N)rt)rGrpathrrrrrrcreate_unix_connection\sz(AbstractEventLoop.create_unix_connectioncCs tdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)rt)rGrrrrrrrrcreate_unix_serverasz$AbstractEventLoop.create_unix_serverallow_broadcastc Cs tdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)rt) rGrrZ remote_addrrrrrrrrrrrcreate_datagram_endpointvs!z*AbstractEventLoop.create_datagram_endpointcCs tdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)rt)rGrpiperrrconnect_read_pipes z#AbstractEventLoop.connect_read_pipecCs tdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)rt)rGrrrrrconnect_write_pipes z$AbstractEventLoop.connect_write_pipestdinstdoutstderrcKs tdS)N)rt)rGrcmdrrrr.rrrsubprocess_shellsz"AbstractEventLoop.subprocess_shellcOs tdS)N)rt)rGrrrrr-r.rrrsubprocess_execsz!AbstractEventLoop.subprocess_execcGs tdS)N)rt)rGfdrHr-rrr add_readerszAbstractEventLoop.add_readercCs tdS)N)rt)rGrrrr remove_readerszAbstractEventLoop.remove_readercGs tdS)N)rt)rGrrHr-rrr add_writerszAbstractEventLoop.add_writercCs tdS)N)rt)rGrrrr remove_writerszAbstractEventLoop.remove_writercCs tdS)N)rt)rGrnbytesrrr sock_recvszAbstractEventLoop.sock_recvcCs tdS)N)rt)rGrdatarrr sock_sendallszAbstractEventLoop.sock_sendallcCs tdS)N)rt)rGrZaddressrrr sock_connectszAbstractEventLoop.sock_connectcCs tdS)N)rt)rGrrrr sock_acceptszAbstractEventLoop.sock_acceptcGs tdS)N)rt)rGsigrHr-rrradd_signal_handlersz$AbstractEventLoop.add_signal_handlercCs tdS)N)rt)rGrrrrremove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCs tdS)N)rt)rGfactoryrrrset_task_factorysz"AbstractEventLoop.set_task_factorycCs tdS)N)rt)rGrrrget_task_factorysz"AbstractEventLoop.get_task_factorycCs tdS)N)rt)rGrrrget_exception_handlersz'AbstractEventLoop.get_exception_handlercCs tdS)N)rt)rGZhandlerrrrset_exception_handlersz'AbstractEventLoop.set_exception_handlercCs tdS)N)rt)rGr[rrrdefault_exception_handlersz+AbstractEventLoop.default_exception_handlercCs tdS)N)rt)rGr[rrrrWsz(AbstractEventLoop.call_exception_handlercCs tdS)N)rt)rGrrrrBszAbstractEventLoop.get_debugcCs tdS)N)rt)rGZenabledrrr set_debugszAbstractEventLoop.set_debug)7r2r]r1r^rurvrwrxryrrrzrqr|r{r}r~rrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrWrBrrrrrrsx                 $  &   !                   c@sReZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCs tdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)rt)rGrrrrsz&AbstractEventLoopPolicy.get_event_loopcCs tdS)z3Set the event loop for the current context to loop.N)rt)rGrIrrrr sz&AbstractEventLoopPolicy.set_event_loopcCs tdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)rt)rGrrrr sz&AbstractEventLoopPolicy.new_event_loopcCs tdS)z$Get the watcher for child processes.N)rt)rGrrrr sz)AbstractEventLoopPolicy.get_child_watchercCs tdS)z$Set the watcher for child processes.N)rt)rGwatcherrrrr "sz)AbstractEventLoopPolicy.set_child_watcherN) r2r]r1r^rr r r r rrrrrs    c@seeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r2r]r1r= _set_calledrrrr_Local6s rcCs|j|_dS)N)r_local)rGrrrrJ:sz#BaseDefaultEventLoopPolicy.__init__cCs|jjdkrJ|jj rJttjtjrJ|j|j|jjdkrut dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rr=rr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rGrrrr=s z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)rrr=)rGrIrrrr Ks z)BaseDefaultEventLoopPolicy.set_event_loopcCs |jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rGrrrr Qsz)BaseDefaultEventLoopPolicy.new_event_loop) r2r]r1r^rrlocalrrJrr r rrrrr's    rc@seZdZdZdZdS) _RunningLoopN)r2r]r1r=_pidrrrrres rcCs2tj}|dk r.tjtjkr.|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_loopr=rosgetpid)Z running_looprrrrms !cCstjt_|t_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrr=)rIrrrr xsc Cs7t*tdkr,ddlm}|aWdQRXdS)NrA)DefaultEventLoopPolicy)_lock_event_loop_policyr0r)rrrr_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrrrrrrs cCs |adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r)ZpolicyrrrrscCs&t}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_looprrrrs  cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rIrrrr scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr rrrrr scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr rrrrr scCstj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rrrrr s)'r^__all__rrrr rrrErrCZasynciorrr/r3r9rrrrrrrZLockrrrrrr rrrrr r r r rrrrsT              >8 4"7        PK!8ɣ,__pycache__/base_events.cpython-35.opt-1.pycnu[ Yf @sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddde j'ddddddZ(d d!Z)Gd"d#d#ej*Z+Gd$d d ej,Z-dS)%aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?cCsH|j}tj|r:t|jtjr:t|jSt|SdS)N) Z _callbackinspectZismethod isinstance__self__rTaskreprstr)handlecbr8/opt/alt/python35/lib64/python3.5/asyncio/base_events.py_format_handle:s $ rcCs4|tjkrdS|tjkr&dSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeCs rc Cs`ttdstdn>y|jtjtjdWntk r[tdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportLs  r$cCs|jtj@tjkS)N)typer SOCK_STREAM)r#rrr_is_stream_socketWsr'cCs|jtj@tjkS)N)r%r SOCK_DGRAM)r#rrr_is_dgram_socket^sr)cCsttdsdS|dtjtjhks:|dkr>dS|tjkrYtj}n|tjkrttj}ndS|dkrd}nwt|tr|dkrd}nSt|tr|dkrd}n/yt |}Wnt t fk rdSYnX|tj krAtj g}ttdrJ|jtjn |g}t|trh|jd}d|krxdSxP|D]H}y-tj|||||d||ffSWqtk rYqXqWdS)N inet_ptonrAF_INET6Zidna%)rrZ IPPROTO_TCPZ IPPROTO_UDPr&r(r bytesrint TypeErrorr AF_UNSPECZAF_INETappendr-decoder*r")hostportfamilyr%protoZafsafrrr _ipaddr_infoesH              r:r7r%r8flagsc Cs|dd\}}t|||||}|dk rZ|j} | j|g| S|j||d|d|d|d|SdS)Nr7r%r8r;)r: create_future set_result getaddrinfo) addressr7r%r8r;loopr5r6infofutrrr_ensure_resolveds  rDcCs=|j}t|tr,t|t r,dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rCexcrrr_run_until_complete_cbs  rJc@sjeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs(||_||_d|_g|_dS)Nr)rGsockets _active_count_waiters)selfrArLrrr__init__s   zServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rL)rOrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rM)rOrrr_attachszServer._attachcCs;|jd8_|jdkr7|jdkr7|jdS)Nrr)rMrL_wakeup)rOrrr_detachszServer._detachcCs`|j}|dkrdSd|_x|D]}|jj|q)W|jdkr\|jdS)Nr)rLrGZ _stop_servingrMrU)rOrLr#rrrcloses    z Server.closecCs@|j}d|_x'|D]}|js|j|qWdS)N)rNdoner>)rOwaiterswaiterrrrrUs     zServer._wakeupccsN|jdks|jdkr"dS|jj}|jj||EdHdS)N)rLrNrGr=r3)rOrZrrr wait_closeds zServer.wait_closedN) rR __module__ __qualname__rPrSrTrVrWrUrr[rrrrrKs      rKc@seZdZddZddZddZddZd d Zd d Zd dd dd ddZ d dddd dd dd ddZ d d d ddZ d d ddZ d d ddZ ed ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zejrd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPdQdPdRdPdSdPdTdUZ*dPdVdWZ+ed d dXd dOdPdRdPdSdPdYd dZd dd d[d\Z,edd]d^Z-ed d dOdPdRdPdSdPd_d d`d dad dYd dbdcZ.edddeZ/ed d dOe0j1dSe0j2dYd dfdgdXd d_d d`d dhdiZ3edXd djdkZ4edldmZ5edndoZ6dpdqZ7edre8j9dse8j9dte8j9duddvdwdxdPdydzZ:edre8j9dse8j9dte8j9duddvddxdPd{d|Z;d}d~Z<ddZ=ddZ>ddZ?ddZ@ddZAddZBddZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj ottjjdd|_d|_d|_d|_ttdrtj|_n d|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysr;ignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rOrrrrPs(             zBaseEventLoop.__init__cCs,d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rQrR is_running is_closed get_debug)rOrrrrS szBaseEventLoop.__repr__cCstjd|S)z,Create a Future object attached to the loop.rA)rZFuture)rOrrrr=szBaseEventLoop.create_futurecCsZ|j|jdkrDtj|d|}|jrV|jd=n|j||}|S)zDSchedule a coroutine object. Return a task object. NrAr) _check_closedrurr_source_traceback)rOcoroZtaskrrr create_tasks   zBaseEventLoop.create_taskcCs2|dk r%t| r%td||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler1ru)rOfactoryrrrset_task_factory#s  zBaseEventLoop.set_task_factorycCs|jS)zs z4BaseEventLoop.shutdown_asyncgens..Zreturn_exceptionsrAmessagez?an error occurred during closing of asynchronous generator {!r} exceptionZasyncgen) rzrylenlistclearrgatherzipr rFcall_exception_handlerr)rOZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgensxs"     z BaseEventLoop.shutdown_asyncgensc Cs|j|jr"tdtjdk r@td|j|jtj|_ |j dk rt j }t j d|jd|jz,tj|x|j|jrPqWWdd|_d|_ tjd|jd|j dk r t j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is runningZ firstiterZ finalizerF)rr{rrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrhryrmr_Zset_asyncgen_hooksrrZ_set_running_loop _run_oncerb)rOZold_agen_hooksrrr run_forevers0              zBaseEventLoop.run_forevercCs|jtj| }tj|d|}|r>d|_|jtzIy|jWn4|r|j r|j r|j YnXWd|j tX|j st d|jS)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. rAFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrJrrXZ cancelledrZremove_done_callbackrr)rOZfutureZnew_taskrrrrun_until_completes       z BaseEventLoop.run_until_completecCs d|_dS)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rb)rOrrrrHszBaseEventLoop.stopcCs|jrtd|jr%dS|jr>tjd|d|_|jj|jj|j }|dk rd|_ |j dddS)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTwaitF) r{rrarr debugrerrfrgZshutdown)rOexecutorrrrrWs          zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)ra)rOrrrr|szBaseEventLoop.is_closedcCs:|js6tjd|t|js6|jdS)Nzunclosed event loop %r)r|rrrr{rW)rOrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rh)rOrrrr{szBaseEventLoop.is_runningcCs tjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rir^)rOrrrriszBaseEventLoop.timecGs6|j|j|||}|jr2|jd=|S)a8Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr~)call_atrir)rOZdelaycallbackrtimerrrr call_laters  zBaseEventLoop.call_latercGsx|j|jr-|j|j|dtj||||}|jrX|jd=tj|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. rrTr~) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushrf)rOwhenrrrrrrr#s      zBaseEventLoop.call_atcGsV|j|jr-|j|j|d|j||}|jrR|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonrr~)rrrr _call_soonr)rOrrrrrrr3s     zBaseEventLoop.call_sooncCs[tj|stj|r3tdj|t|sWtdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr1rr)rOrmethodrrrrFs zBaseEventLoop._check_callbackcCs<tj|||}|jr(|jd=|jj||S)Nrr~)rZHandlerrer3)rOrrrrrrrQs   zBaseEventLoop._call_sooncCs>|jdkrdStj}||jkr:tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rhrrr)rOZ thread_idrrrrXs  zBaseEventLoop._check_threadcGsV|j|jr#|j|d|j||}|jrH|jd=|j|S)z"Like call_soon(), but thread-safe.call_soon_threadsaferr~)rrrrrr)rOrrrrrrris     z"BaseEventLoop.call_soon_threadsafecGs{|j|jr#|j|d|dkr\|j}|dkr\tjj}||_tj|j||d|S)Nrun_in_executorrA) rrrrg concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rOrfuncrrrrrts      zBaseEventLoop.run_in_executorcCs ||_dS)N)rg)rOrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r*|jd||rA|jd||rX|jd||ro|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r3joinr rrirr?rsrB) rOr5r6r7r%r8r;msgt0Zaddrinfodtrrr_getaddrinfo_debugs(  z BaseEventLoop._getaddrinfo_debugr7rr%r8r;c CsW|jr.|jd|j||||||S|jdtj||||||SdS)N)rrrrr?)rOr5r6r7r%r8r;rrrr?s  zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rOZsockaddrr;rrrrszBaseEventLoop.getnameinfosslr# local_addrc#s#| dk r| rtd| dkrI|rI|sCtd|} |dk sa|dk r|dk rytdt||fd|dtjd|d|d |} | g} | dk rt| d|dtjd|d|d |} | j| nd} tj| d |EdH| j}|s:td | dk rd| j}|sdtd g}xU|D]\}}}}}y tjd|d|d|}|j d | dk rax|D]\}}}}}y|j |PWqtk rI}z9t|j d j ||j j}|j|WYdd}~XqXqW|jd}wq|jr}tjd |||j||EdHWnhtk r}z(|dk r|j|j|WYdd}~Xqq|dk r|jYqqXPqqWt|dkr"|dqt|dtfdd|Dr[|dtdj djdd|Dn9|dkrtdt|stdj ||j|||| EdH\}}|jr|jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same timer7r%r8r;rAz!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s!|]}t|kVqdS)N)r)rrI)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrIrrrrsz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}rz%r connected to %s:%r: (%r, %r))rrDrr&r3rrrr" setblockingbinderrnorstrerrorlowerrWrr r sock_connectrrallrr'_create_connection_transportget_extra_info)rOprotocol_factoryr5r6rr7r8r;r#rrf1fsf2infosZ laddr_infos exceptionsr%Zcnamer@_ZladdrrI transportrr)rrcreate_connections                $         %     zBaseEventLoop.create_connectionc cs|jd|}|j}|rjt|tr=dn|}|j||||d|d|} n|j|||} y |EdHWn| jYnX| |fS)NFrr)rr=r rorrrW) rOr#rrrrrrZrrrrrr+s     z*BaseEventLoop._create_connection_transport reuse_address reuse_portallow_broadcastc#sT| dk rt| s-tdj| s]s]|s]|s]|s]|s]|s]| rtddd|d|d|d|d |d | } d jd d | jD} tdj| | jdd} nps|dkrtd||fdff}ntj}xdfdffD]\}}|dk rDt |d|dt j d|d|d|EdH}|st dxS|D]K\}}}}}||f}||krddg||<||||.zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrr%rAz!getaddrinfo() returned empty listcsNg|]D\}}r(|ddkp;o;|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrxs z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r)rrdictritemsrrc OrderedDictrDrr(r"rpnamermplatformr r! SO_REUSEADDRr$Z SO_BROADCASTrrrWr3r=rrr rBr)rOrrrr7r8r;rrrr#ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZpror@rrZ local_addressZremote_addressrIrrZrr)rrrcreate_datagram_endpointCs            %    "                    z&BaseEventLoop.create_datagram_endpointc csQt||fd|dtjd|d|EdH}|sMtdj||S)Nr7r%r;rAz%getaddrinfo({!r}) returned empty list)rDrr&r"r)rOr5r6r7r;rrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfobacklogr c #sdt|trtd|dk s3dk r|dk rKtdttdd} | dkrtjdkotj dk} g} |dkrdg} n4t|t st|t j  r|g} n|} fd d | D}t j|d EdH}ttjj|}d }zWxJ|D]B}|\}}}}}ytj|||}Wn=tjk rjrtjd |||ddw=YnX| j|| r|jtjtjd| rt||| kr!ttdr!|jtjtjdy|j|Wq=t k r~}z*t |j!d||j"j#fWYdd}~Xq=Xq=Wd}Wd|sx| D]}|j$qWXnB|dkrtdt%|stdj&||g} t'| }xA| D]9}|j(||j)d j*|||||q Wjr`tj+d||S)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timer-rrrr,c s.g|]$}j|ddqS)r7r;)r)rr5)r7r;r6rOrrrs z/BaseEventLoop.create_server..rAFz:create_server() failed to create socket.socket(%r, %r, %r)exc_infoT IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving),r ror1rgetattrrrprrmrrrcIterablerrset itertoolschain from_iterableerrorrr warningr3r r!rr$rrZ IPV6_V6ONLYrr"rrrrWr'rrKZlistenrZ_start_servingrB)rOrr5r6r7r;r#rrrrr-rLZhostsrrZ completedresr9Zsocktyper8Z canonnameZsaerrrr)r7r;r6rOr create_servers               0          zBaseEventLoop.create_serverccst|s!tdj||j|||dddEdH\}}|jrx|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r,rTNrz%r handled: (%r, %r))r'rrrrrr r)rOrr#rrrrrrconnect_accepted_socket.s # z%BaseEventLoop.connect_accepted_socketc cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz Read pipe %r connected: (%r, %r))r=rrWrr rfileno)rOrrrrZrrrrconnect_read_pipeEs      zBaseEventLoop.connect_read_pipec cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))r=rrWrr rr)rOrrrrZrrrrconnect_write_pipeVs      z BaseEventLoop.connect_write_pipecCs|g}|dk r,|jdt||dk ra|tjkra|jdt|nF|dk r|jdt||dk r|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r3rrrr rr)rOrrrrrBrrr_log_subprocessgs    zBaseEventLoop._log_subprocessrrruniversal_newlinesrTrc kst|ttfs!td|r3td|sEtd|dkr]td|} |jrd|} |j| ||||j| |d||||| EdH} |jrtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) r r/rrrrrr rB) rOrcmdrrrrrrrr debug_logrrrrsubprocess_shellts"        # zBaseEventLoop.subprocess_shellc os |rtd|r$td|dkr<td|f| } x<| D]4} t| ttfsPtdt| jqPW|} |jrd|}|j|||||j | | d||||| EdH}|jrt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) rr rr/r1r%rRrrrr rB)rOrZprogramrrrrrrrrZ popen_argsargrrrrrrsubprocess_execs*          zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rk)rOrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs;|dk r.t| r.tdj|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})rr1rrk)rOZhandlerrrrset_exception_handlers   z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk rQt|||jf}nd}d|kr|jdk r|jjr|jj|d<|g}xt|D]}|dkrq||}|dkrdjtj|}d }||j 7}nI|dkr=djtj|}d }||j 7}n t |}|j d j ||qWt jd j|d |dS)a@Default exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr,z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} r>rr)rrr% __traceback__rtrsortedr traceback format_listrstriprr3rr r ) rOcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6          z'BaseEventLoop.default_exception_handlercCs|jdkrKy|j|Wqtk rGtjdddYqXny|j||Wnptk r}zPy#|jddd|d|iWn%tk rtjd ddYnXWYdd}~XnXdS) aCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerrTrz$Unhandled error in exception handlerrr#zeException in default exception handler while handling an unexpected error in custom exception handler)rkr&rFr r )rOr#rIrrrrs"    z$BaseEventLoop.call_exception_handlercCs!|jr dS|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrer3)rOrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r(r)rOrrrr_add_callback_signalsafe's z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rfr`)rOrrrr_timer_handle_cancelled,s z%BaseEventLoop._timer_handle_cancelledc Cslt|j}|tkr|j|tkrg}x3|jD](}|jrYd|_q>|j|q>Wtj|||_d|_nJxG|jr|jdjr|jd8_tj |j}d|_qWd}|j s|j rd}n2|jr)|jdj }t d||j}|jr|dkr|j}|jj|}|j|}|dkrtj} n tj} t|} |dkrtj| d|d| q+| rtj| d|d|d| q+|dkr+tj| d |d|dn|jj|}|j||j|j} xU|jr|jd}|j | krtPtj |j}d|_|j j|qNWt|j } xt| D]} |j j}|jrq|jrTz[||_|j}|j|j|}||jkrCtjd t||Wdd|_Xq|jqWd}dS) zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds) rrf_MIN_SCHEDULED_TIMER_HANDLESr`%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr'r3rheapifyheappoprerbZ_whenmaxrirZ _selectorZselectloggingINFODEBUGr logrrjrangepopleftrtZ_runrsr r)rOZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrr1s                                zBaseEventLoop._run_oncec Csytj}tj}Wntk r.dSYnXt|}|j|krNdStj}|}|r|d|fkrtj d|t q||d|_n<|d|fkrtj d|t n|dd|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF) rmset_coroutine_wrapperget_coroutine_wrapperAttributeErrorrorvrZ debug_wrapperrrRuntimeWarning)rOenabledZ set_wrapperZ get_wrapperwrapperZcurrent_wrapperrrrrs.          z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r)rOrrrr}szBaseEventLoop.get_debugcCs&||_|jr"|j|dS)N)rr{r)rOr<rrrrls  zBaseEventLoop.set_debug)GrRr\r]rPrSr=rrrrrrrrrrrrrrrrrrrHrWr|rZPY34rr{rirrrrrrrrrrr?rrrrrrr2Z AI_PASSIVErrrrrrrrrrrr&rr(r)r*rrr}rlrrrrr s  !            %             !   u    _     , 2    c ! ).__doc__rcZconcurrent.futuresrrr rr0rprrrrir rmrrwr,rrrrrrr3r __all__r+r,BrokenPipeErrorConnectionResetErrorConnectionAbortedErrorZ_FATAL_ERROR_IGNORErrr$r'r)r:r&rDrJZAbstractServerrKZAbstractEventLoopr rrrrsL                    = /PK!\7kwFwF*__pycache__/proactor_events.cpython-35.pycnu[ YfN@s_dZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdddfddZddZddZd d Zd d Zd dZ ddZ e j rddZ dddZddZddZddZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk r|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__ ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"     z#_ProactorBasePipeTransport.__repr__cCs||jdr) rVrWrXrrr\ ExceptionrBrr]r)rrorDr#r#r$rs    z(BaseProactorEventLoop._loop_self_readingcCs|jjddS)Ns)rrm)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs5dfddjdS)Ncsy|dk r|j\}}jr@tjd||}dk rj||dddd|idn"j||dd|idjrdSjj}Wnt k rL}zbj dkrj dd d |d ij njr:tjd d dWYdd}~Xn?t jk rjj Yn!X|jj <|jdS)Nz#%r got a new connection from %r: %rrTr r|r!rr=zAccept failed on a socketr>rHzAccept failed on socket %rr<)rVZ_debugr rArrrrWrr[r*rBr7rr\rr])roZconnZaddrrrD)rprotocol_factoryrr!rrr#r$rs>            z2BaseProactorEventLoop._start_serving..loop)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_eventssz%BaseProactorEventLoop._process_eventscCs5x!|jjD]}|jqW|jjdS)N)rvaluesr6clear)rZfuturer#r#r$rsz*BaseProactorEventLoop._stop_accept_futurescCs(|j|jj||jdS)N)rrW _stop_servingr7)rrr#r#r$r#s z#BaseProactorEventLoop._stop_serving)r(rKrLr rrrrrr7rrrrrrrrrrrrrr#r#)r"r$r{s4           (  )rM__all__rHr8rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrNZWriteTransportr`rsZ Transportryr{Z BaseEventLooprr#r#r#r$s0     M T  PK!99)__pycache__/sslproto.cpython-35.opt-2.pycnu[ ]]e @sddlZddlZyddlZWnek rBdZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCs|rtdttdr?tj}|sd|_nLtjtj}|jtjO_|jtj O_|j tj |_ |S)Nz(Server side SSL needs a valid SSLContextcreate_default_contextF) ValueErrorhasattrsslrcheck_hostnameZ SSLContextZPROTOCOL_SSLv23optionsZ OP_NO_SSLv2Z OP_NO_SSLv3Zset_default_verify_pathsZ CERT_REQUIRED verify_mode) server_sideserver_hostname sslcontextr-/opt/alt/python35/lib64/python3.5/sslproto.py_create_transport_contexts     rcCs ttdS)N MemoryBIO)r r rrrr_is_sslproto_available%srZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@seZdZdZdddZeddZedd Zed d Zed d Z dddZ dddZ ddZ dddZ dddZdS)_SSLPipeiNcCsj||_||_||_t|_tj|_tj|_d|_ d|_ d|_ d|_ dS)NF) _context _server_side_server_hostname _UNWRAPPED_stater r _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextrrrrr__init__Ds       z_SSLPipe.__init__cCs|jS)N)r)r$rrrr%Zsz_SSLPipe.contextcCs|jS)N)r )r$rrr ssl_object_sz_SSLPipe.ssl_objectcCs|jS)N)r!)r$rrr need_ssldatagsz_SSLPipe.need_ssldatacCs |jtkS)N)r_WRAPPED)r$rrrwrappedmsz_SSLPipe.wrappedcCs||jtkrtd|jj|j|jd|jd|j|_ t |_||_ |j ddd\}}|S)Nz"handshake in progress or completedrronly_handshakeT) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr" feed_ssldata)r$callbackssldataappdatarrr do_handshakevs      z_SSLPipe.do_handshakecCsa|jtkrtd|jtkr6tdt|_||_|jd\}}|S)Nzno security layer presentzshutdown in progressr+)rrr- _SHUTDOWNr#r/)r$r0r1r2rrrshutdowns     z_SSLPipe.shutdowncCs&|jj|jd\}}dS)Nr+)rZ write_eofr/)r$r1r2rrrfeed_eofs z_SSLPipe.feed_eofFcCs|jtkr1|r!|g}ng}g|fSd|_|rP|jj|g}g}y|jtkr|jjt|_|j r|j d|r||fS|jtkrx|jj |j }|j ||sPqWni|jt kr0|jjd|_t|_|jrU|jn%|jtkrU|j |jj Wntjtjfk r}zlt|ddtjtjtjfkr|jtkr|j r|j ||jtjk|_WYdd}~XnX|jjr|j |jj ||fS)NFerrno)rrr!rwriter.r r3r)r"readmax_sizeappendr4Zunwrapr#r SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr7rpending)r$datar,r2r1chunkexcrrrr/sV                ( z_SSLPipe.feed_ssldatarcCsl|jtkrM|t|kr7||dg}ng}|t|fSg}t|}xd|_y6|t|kr||jj||d7}Wn|tjk r}zY|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjrB|j|jj|t|ks]|jrbPqbW||fS)NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr!r r8r r<reasonr?r7r@rArrBr;r9)r$rCoffsetr1viewrErrr feed_appdatas2  $  ( z_SSLPipe.feed_appdatai)__name__ __module__ __qualname__r:r&propertyr%r'r(r*r3r5r6r/rKrrrrr0s   Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rlddZ ddZ ddZ ddddZddZddZddZddZdS)_SSLProtocolTransportcCs(||_||_||_d|_dS)NF)_loop _ssl_protocol _app_protocol_closed)r$loopZ ssl_protocol app_protocolrrrr&)s   z_SSLProtocolTransport.__init__NcCs|jj||S)N)rR_get_extra_info)r$namedefaultrrrget_extra_info0sz$_SSLProtocolTransport.get_extra_infocCs ||_dS)N)rS)r$protocolrrr set_protocol4sz"_SSLProtocolTransport.set_protocolcCs|jS)N)rS)r$rrr get_protocol7sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rT)r$rrr is_closing:sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)NT)rTrR_start_shutdown)r$rrrclose=s z_SSLProtocolTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rTwarningswarnResourceWarningr`)r$rrr__del__Ls z_SSLProtocolTransport.__del__cCs|jjjdS)N)rR _transport pause_reading)r$rrrrfQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)N)rRreresume_reading)r$rrrrgYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)N)rRreset_write_buffer_limits)r$highlowrrrrhasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjjS)N)rRreget_write_buffer_size)r$rrrrkvsz+_SSLProtocolTransport.get_write_buffer_sizecCsTt|tttfs6tdjt|j|s@dS|jj |dS)Nz/data: expecting a bytes-like instance, got {!r}) isinstancebytes bytearrayrG TypeErrorformattyperLrR_write_appdata)r$rCrrrr8zs  z_SSLProtocolTransport.writecCsdS)NFr)r$rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)N)rR_abort)r$rrrabortsz_SSLProtocolTransport.abort)rLrMrNr&rZr\r]r^r`rZPY34rdrfrgrhrkr8rsrurrrrrP&s            rPc@seZdZdddddZdddZdd Zd d Zd d ZddZddZ ddZ dddZ ddZ ddZ ddZddZddZd d!d"Zd#d$Zd%d&ZdS)' SSLProtocolFNTcCstdkrtd|s-t||}||_|rO| rO||_n d|_||_td||_tj |_ d|_ ||_ ||_ ||_t|j ||j|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not availablerrF)r r-rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrQrSrP_app_transport_sslpipe_session_established _in_handshake _in_shutdownre_call_connection_made)r$rUrVrwaiterrrZcall_connection_maderrrr&s.                 zSSLProtocol.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)r~ cancelled set_exception set_result)r$rErrr_wakeup_waiters zSSLProtocol._wakeup_waitercCs5||_t|j|j|j|_|jdS)N)rerrwrrr_start_handshake)r$ transportrrrconnection_mades   zSSLProtocol.connection_madecCsN|jr+d|_|jj|jj|d|_d|_|j|dS)NF)rrQ call_soonrSconnection_lostrerr)r$rErrrrs     zSSLProtocol.connection_lostcCs|jjdS)N)rS pause_writing)r$rrrrszSSLProtocol.pause_writingcCs|jjdS)N)rSresume_writing)r$rrrrszSSLProtocol.resume_writingcCsy|jj|\}}Wnatjk r}z>|jjr_tjd||j|j |j dSWYdd}~XnXx|D]}|j j |qWx2|D]*}|r|j j|q|jPqWdS)Nz%r: SSL error %s (reason %s))rr/r r<rQ get_debugrwarningr7rHrtrer8rS data_receivedr_)r$rCr1r2erDrrrrs     zSSLProtocol.data_receivedc Cspz[|jjr"tjd||jt|jsZ|jj}|rZtj dWd|j j XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl) rQrrdebugrConnectionResetErrorrrS eof_receivedrrer`)r$Z keep_openrrrrs  zSSLProtocol.eof_receivedcCsD||jkr|j|S|jdk r<|jj||S|SdS)N)ryrerZ)r$rXrYrrrrWs  zSSLProtocol._get_extra_infocCs=|jr dS|jr#|jnd|_|jddS)NTr+)rrrtrr)r$rrrr_&s     zSSLProtocol._start_shutdowncCs9|jj|df|jt|7_|jdS)Nr)r|r;r}rF_process_write_backlog)r$rCrrrrr/szSSLProtocol._write_appdatacCsm|jjr4tjd||jj|_n d|_d|_|jjd|jj |j dS)Nz%r starts SSL handshakeTr+r)r+r) rQrrrtime_handshake_start_timerr|r;rr)r$rrrr4s  zSSLProtocol._start_handshakecCsd|_|jj}ye|dk r*||j}t|jdsy|jry|jjtj krytj ||jWnt k r!}z|j j rt|tjrtjd|ddntjd|dd|jjt|tr |j|dSWYdd}~XnX|j j r^|j j|j}tjd||d|jjd |d |jd |jd ||jr|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateexc_infoTz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@peercertcipher compressionr')$rrr'Z getpeercertr rwrrr Z CERT_NONEZmatch_hostname BaseExceptionrQrrlr=rrrer` ExceptionrrrrryupdaterrrrSrrrrr)r$Z handshake_excZsslobjrrEZdtrrr_on_handshake_complete@sD               z"SSLProtocol._on_handshake_completecCs|jdkrdSyxtt|jD]}|jd\}}|ri|jj||\}}n?|r|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q,WWn`tk r}z@|jrZ|j|n|j|dt|ts|WYdd}~XnXdS)NrrzFatal error on SSL transport)rerangerFr|rrKr3rr5 _finalizer8Z_pausedrgr}rr _fatal_errorrlr)r$irCrIr1rDrErrrrts8        z"SSLProtocol._process_write_backlogzFatal error on transportc Cst|tjr=|jjrhtjd||ddn+|jjd|d|d|jd|i|jr|jj |dS)Nz%r: %srTmessage exceptionrr[) rlrZ_FATAL_ERROR_IGNORErQrrrZcall_exception_handlerreZ _force_close)r$rErrrrrs    zSSLProtocol._fatal_errorcCs)d|_|jdk r%|jjdS)N)rrer`)r$rrrrs zSSLProtocol._finalizec Cs2z |jdk r|jjWd|jXdS)N)rerur)r$rrrrtszSSLProtocol._abort)rLrMrNr&rrrrrrrrWr_rrrrrrrrtrrrrrvs$ #       4 , rv)rzrar ImportErrorrrrrlogrrrrr.r)r4objectrZ_FlowControlMixinZ TransportrPZProtocolrvrrrrs(       nPK!J,__pycache__/base_events.cpython-35.opt-2.pycnu[ ] @sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZd gZd Zd ZeeefZd dZ ddZ!ddZ"ddZ#ddZ$ddZ%dddej&ddddddZ'dd Z(Gd!d"d"ej)Z*Gd#d d ej+Z,dS)$N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?cCsH|j}tj|r:t|jtjr:t|jSt|SdS)N) _callbackinspectZismethod isinstance__self__rTaskreprstr)handlecbr0/opt/alt/python35/lib64/python3.5/base_events.py_format_handle:s $ rcCs4|tjkrdS|tjkr&dSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeCs rc Cs`ttdstdn>y|jtjtjdWntk r[tdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportLs  r%cCs|jtj@tjkS)N)typer SOCK_STREAM)r$rrr_is_stream_socketWsr(cCs|jtj@tjkS)N)r&r SOCK_DGRAM)r$rrr_is_dgram_socket^sr*cCsttdsdS|dtjtjhks:|dkr>dS|tjkrYtj}n|tjkrttj}ndS|dkrd}nwt|tr|dkrd}nSt|tr|dkrd}n/yt |}Wnt t fk rdSYnX|tj krAtj g}ttdrJ|jtjn |g}t|trh|jd}d|krxdSxP|D]H}y-tj|||||d||ffSWqtk rYqXqWdS)N inet_ptonrAF_INET6Zidna%)rr IPPROTO_TCP IPPROTO_UDPr'r)rbytesrint TypeErrorr AF_UNSPECAF_INETappendr.decoder+r#)hostportfamilyr&protoZafsafrrr _ipaddr_infoesH              r>r;r&r<flagsc Cs|dd\}}t|||||}|dk rZ|j} | j|g| S|j||d|d|d|d|SdS)Nr;r&r<r?)r> create_future set_result getaddrinfo) addressr;r&r<r?loopr9r:infofutrrr_ensure_resolveds  rHcCs=|j}t|tr,t|t r,dS|jjdS)N) _exceptionr BaseException Exception_loopstop)rGexcrrr_run_until_complete_cbs  rOc@sjeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs(||_||_d|_g|_dS)Nr)rLsockets _active_count_waiters)selfrErQrrr__init__s   zServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rQ)rTrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rR)rTrrr_attachszServer._attachcCs;|jd8_|jdkr7|jdkr7|jdS)Nrr)rRrQ_wakeup)rTrrr_detachszServer._detachcCs`|j}|dkrdSd|_x|D]}|jj|q)W|jdkr\|jdS)Nr)rQrLZ _stop_servingrRrZ)rTrQr$rrrcloses    z Server.closecCs@|j}d|_x'|D]}|js|j|qWdS)N)rSdonerB)rTwaiterswaiterrrrrZs     zServer._wakeupccsN|jdks|jdkr"dS|jj}|jj||EdHdS)N)rQrSrLrAr7)rTr_rrr wait_closeds zServer.wait_closedN) rW __module__ __qualname__rUrXrYr[r\rZrr`rrrrrPs      rPc@seZdZddZddZddZddZd d Zd d Zd dd dd ddZ d dddd dd dd ddZ d d d ddZ d d ddZ d d ddZ ed ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zejrd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPdQdPdRdPdSdPdTdUZ*dPdVdWZ+ed d dXd dOdPdRdPdSdPdYd dZd dd d[d\Z,edd]d^Z-ed d dOdPdRdPdSdPd_d d`d dad dYd dbdcZ.edddeZ/ed d dOe0j1dSe0j2dYd dfdgdXd d_d d`d dhdiZ3edXd djdkZ4edldmZ5edndoZ6dpdqZ7edre8j9dse8j9dte8j9duddvdwdxdPdydzZ:edre8j9dse8j9dte8j9duddvddxdPd{d|Z;d}d~Z<ddZ=ddZ>ddZ?ddZ@ddZAddZBddZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj ottjjdd|_d|_d|_d|_ttdrtj|_n d|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysr?ignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rTrrrrUs(             zBaseEventLoop.__init__cCs,d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rVrW is_running is_closed get_debug)rTrrrrX szBaseEventLoop.__repr__cCstjd|S)NrE)rFuture)rTrrrrAszBaseEventLoop.create_futurecCsZ|j|jdkrDtj|d|}|jrV|jd=n|j||}|S)NrEr) _check_closedr{rr_source_traceback)rTcoroZtaskrrr create_tasks   zBaseEventLoop.create_taskcCs2|dk r%t| r%td||_dS)Nz'task factory must be a callable or None)callabler4r{)rTfactoryrrrset_task_factory#s  zBaseEventLoop.set_task_factorycCs|jS)N)r{)rTrrrget_task_factory1szBaseEventLoop.get_task_factoryNextraservercCs tdS)N)NotImplementedError)rTr$protocolr_rrrrr_make_socket_transport5sz$BaseEventLoop._make_socket_transport server_sideFserver_hostnamec Cs tdS)N)r) rTZrawsockr sslcontextr_rrrrrrr_make_ssl_transport:sz!BaseEventLoop._make_ssl_transportcCs tdS)N)r)rTr$rrDr_rrrr_make_datagram_transport@sz&BaseEventLoop._make_datagram_transportcCs tdS)N)r)rTpiperr_rrrr_make_read_pipe_transportEsz'BaseEventLoop._make_read_pipe_transportcCs tdS)N)r)rTrrr_rrrr_make_write_pipe_transportJsz(BaseEventLoop._make_write_pipe_transportc Ks tdS)N)r) rTrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportOsz(BaseEventLoop._make_subprocess_transportcCs tdS)N)r)rTrrr_write_to_selfVszBaseEventLoop._write_to_selfcCs tdS)N)r)rT event_listrrr_process_events_szBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rf RuntimeError)rTrrrrcs zBaseEventLoop._check_closedcCs=|jj||js9|j|j|jdS)N)rdiscardrracloser)rTagenrrr_asyncgen_finalizer_hookgs z&BaseEventLoop._asyncgen_finalizer_hookcCs<|jr(tjdj|td||jj|dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() callsource)rwarningswarnformatResourceWarningradd)rTrrrr_asyncgen_firstiter_hookos   z&BaseEventLoop._asyncgen_firstiter_hookccsd|_|jdks(t|j r,dSt|j}|jjtjdd|Dddd|}|EdH}xTt||D]C\}}t|t r|j ddj |d|d |iqWdS) NTcSsg|]}|jqSr)r).0Zagrrr s z4BaseEventLoop.shutdown_asyncgens..Zreturn_exceptionsrEmessagez?an error occurred during closing of asynchronous generator {!r} exceptionZasyncgen) rrlenlistclearrgatherziprrKcall_exception_handlerr)rTZ closing_agensZ shutdown_cororesultsresultrrrrshutdown_asyncgensxs"     z BaseEventLoop.shutdown_asyncgensc Cs|j|jr"tdtjdk r@td|j|jtj|_ |j dk rt j }t j d|jd|jz,tj|x|j|jrPqWWdd|_d|_ tjd|jd|j dk r t j |XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is runningZ firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrmrrsrdZset_asyncgen_hooksrrZ_set_running_loop _run_oncerg)rTZold_agen_hooksrrr run_forevers0              zBaseEventLoop.run_forevercCs|jtj| }tj|d|}|r>d|_|jtzIy|jWn4|r|j r|j r|j YnXWd|j tX|j st d|jS)NrEFz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingadd_done_callbackrOrr] cancelledrZremove_done_callbackrr)rTfutureZnew_taskrrrrun_until_completes       z BaseEventLoop.run_until_completecCs d|_dS)NT)rg)rTrrrrMszBaseEventLoop.stopcCs|jrtd|jr%dS|jr>tjd|d|_|jj|jj|j }|dk rd|_ |j dddS)Nz!Cannot close a running event loopzClose %rTwaitF) rrrfrr debugrjrrkrlshutdown)rTexecutorrrrr\s          zBaseEventLoop.closecCs|jS)N)rf)rTrrrrszBaseEventLoop.is_closedcCs:|js6tjd|t|js6|jdS)Nzunclosed event loop %r)rrrrrr\)rTrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)N)rm)rTrrrrszBaseEventLoop.is_runningcCs tjS)N)rnrc)rTrrrrnszBaseEventLoop.timecGs6|j|j|||}|jr2|jd=|S)Nrr)call_atrnr)rTdelaycallbackrtimerrrr call_laters  zBaseEventLoop.call_latercGsx|j|jr-|j|j|dtj||||}|jrX|jd=tj|j |d|_ |S)NrrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushrk)rTwhenrrrrrrr#s      zBaseEventLoop.call_atcGsV|j|jr-|j|j|d|j||}|jrR|jd=|S)N call_soonrr)rrrr _call_soonr)rTrrrrrrr3s     zBaseEventLoop.call_sooncCs[tj|stj|r3tdj|t|sWtdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr4rr)rTrmethodrrrrFs zBaseEventLoop._check_callbackcCs<tj|||}|jr(|jd=|jj||S)Nrr)rZHandlerrjr7)rTrrrrrrrQs   zBaseEventLoop._call_sooncCs>|jdkrdStj}||jkr:tddS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rmrrr)rTZ thread_idrrrrXs  zBaseEventLoop._check_threadcGsV|j|jr#|j|d|j||}|jrH|jd=|j|S)Ncall_soon_threadsaferr)rrrrrr)rTrrrrrrris     z"BaseEventLoop.call_soon_threadsafecGs{|j|jr#|j|d|dkr\|j}|dkr\tjj}||_tj|j||d|S)Nrun_in_executorrE) rrrrl concurrentrThreadPoolExecutorZ wrap_futuresubmit)rTrfuncrrrrrts      zBaseEventLoop.run_in_executorcCs ||_dS)N)rl)rTrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r*|jd||rA|jd||rX|jd||ro|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r7joinr rrnrrCryrF) rTr9r:r;r&r<r?msgt0Zaddrinfodtrrr_getaddrinfo_debugs(  z BaseEventLoop._getaddrinfo_debugr;rr&r<r?c CsW|jr.|jd|j||||||S|jdtj||||||SdS)N)rrrrrC)rTr9r:r;r&r<r?rrrrCs  zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rTZsockaddrr?rrrrszBaseEventLoop.getnameinfosslr$ local_addrc#s#| dk r| rtd| dkrI|rI|sCtd|} |dk sa|dk r|dk rytdt||fd|dtjd|d|d|} | g} | dk rt| d|dtjd|d|d|} | j| nd} tj| d|EdH| j}|s:td | dk rd| j}|sdtd g}xU|D]\}}}}}y tjd|d|d|}|j d | dk rax|D]\}}}}}y|j |PWqtk rI}z9t|j d j ||j j}|j|WYdd}~XqXqW|jd}wq|jr}tjd |||j||EdHWnhtk r}z(|dk r|j|j|WYdd}~Xqq|dk r|jYqqXPqqWt|d kr"|dqt|dtfdd|Dr[|dtdj djdd|Dn9|dkrtdt|stdj ||j|||| EdH\}}|jr|jd}tjd|||||||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same timer;r&r<r?rEz!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s!|]}t|kVqdS)N)r)rrN)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrNrrrrsz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}rz%r connected to %s:%r: (%r, %r))r rHrr'r7rrrr# setblockingbinderrnorstrerrorlowerr\rr r sock_connectrrallrr(_create_connection_transportget_extra_info)rTprotocol_factoryr9r:rr;r<r?r$rrf1fsf2infosZ laddr_infos exceptionsr&ZcnamerD_laddrrN transportrr)rrcreate_connections                $         %     zBaseEventLoop.create_connectionc cs|jd|}|j}|rjt|tr=dn|}|j||||d|d|} n|j|||} y |EdHWn| jYnX| |fS)NFrr)rrArrurrr\) rTr$rrrrrr_rrrrrr+s     z*BaseEventLoop._create_connection_transport reuse_address reuse_portallow_broadcastc#sT| dk rt| s-tdj| s]s]|s]|s]|s]|s]|s]| rtddd|d|d|d|d|d | } d jd d | jD} td j| | jdd} nps|dkrtd||fdff}ntj}xdfdffD]\}}|dk rDt |d|dt j d|d|d|EdH}|st dxS|D]K\}}}}}||f}||krddg||<||||.zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrr&rEz!getaddrinfo() returned empty listcsNg|]D\}}r(|ddkp;o;|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrxs z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r*r rdictritemsrrh OrderedDictrHrr)r#rvnamersplatformr!r" SO_REUSEADDRr% SO_BROADCASTrrr\r7rArrr rFr)rTrrrr;r<r?rrrr$ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxaddrrZfamrZprorDrrZ local_addressZremote_addressrNrr_rr)rrrcreate_datagram_endpointCs            %    "                    z&BaseEventLoop.create_datagram_endpointc csQt||fd|dtjd|d|EdH}|sMtdj||S)Nr;r&r?rEz%getaddrinfo({!r}) returned empty list)rHrr'r#r)rTr9r:r;r?rrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfobacklogr c #sdt|trtd|dk s3dk r|dk rKtdttdd} | dkrtjdkotj dk} g} |dkrdg} n4t|t st|t j  r|g} n|} fdd | D}t j|d EdH}ttjj|}d }zWxJ|D]B}|\}}}}}ytj|||}Wn=tjk rjrtjd |||d dw=YnX| j|| r|jtjtjd| rt||| kr!ttdr!|jtjtjdy|j|Wq=t k r~}z*t |j!d||j"j#fWYdd}~Xq=Xq=Wd}Wd|sx| D]}|j$qWXnB|dkrtdt%|stdj&||g} t'| }xA| D]9}|j(||j)d j*|||||q Wjr`tj+d||S)Nz*ssl argument must be an SSLContext or Nonez8host/port and sock can not be specified at the same timer.rrrr-c s.g|]$}j|ddqS)r;r?)r)rr9)r;r?r:rTrrrs z/BaseEventLoop.create_server..rEFz:create_server() failed to create socket.socket(%r, %r, %r)exc_infoT IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving),rrur4r getattrrrvr rsr rrhIterablerrset itertoolschain from_iterableerrorrr warningr7r!r"rr%rr IPV6_V6ONLYrr#rrrr\r(rrPlistenrZ_start_servingrF)rTrr9r:r;r?r$rrrrr.rQZhostsrrZ completedresr=socktyper< canonnamesaerrrr)r;r?r:rTr create_servers               0          zBaseEventLoop.create_serverccst|s!tdj||j|||dddEdH\}}|jrx|jd}tjd|||||fS)Nz&A Stream Socket was expected, got {!r}r-rTrz%r handled: (%r, %r))r(r rrrrr r)rTrr$rrrrrrconnect_accepted_socket.s # z%BaseEventLoop.connect_accepted_socketc cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rArr\rr rfileno)rTrrrr_rrrrconnect_read_pipeEs      zBaseEventLoop.connect_read_pipec cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rArr\rr rr()rTrrrr_rrrrconnect_write_pipeVs      z BaseEventLoop.connect_write_pipecCs|g}|dk r,|jdt||dk ra|tjkra|jdt|nF|dk r|jdt||dk r|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r7rrrr rr)rTrrrrrFrrr_log_subprocessgs    zBaseEventLoop._log_subprocessrrruniversal_newlinesrTrc kst|ttfs!td|r3td|sEtd|dkr]td|} |jrd|} |j| ||||j| |d||||| EdH} |jrtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr2rr rr,rr rF) rTrcmdrrrr-rrrr debug_logrrrrsubprocess_shellts"        # zBaseEventLoop.subprocess_shellc os |rtd|r$td|dkr<td|f| } x<| D]4} t| ttfsPtdt| jqPW|} |jrd|}|j|||||j | | d||||| EdH}|jrt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r rrr2r4r&rWrr,rr rF)rTrZprogramrrrr-rrrrZ popen_argsargrr/rrrrsubprocess_execs*          zBaseEventLoop.subprocess_execcCs|jS)N)rq)rTrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs;|dk r.t| r.tdj|||_dS)Nz/A callable object or None is expected, got {!r})rr4rrq)rThandlerrrrset_exception_handlers   z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk rQt|||jf}nd}d|kr|jdk r|jjr|jj|d<|g}xt|D]}|d krq||}|dkrdjtj|}d}||j 7}nI|dkr=djtj|}d }||j 7}n t |}|j d j ||qWt jd j|d |dS)Nrz!Unhandled exception in event looprFZsource_tracebackZhandle_tracebackr-z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} r>rr)rxr& __traceback__rzrsortedr traceback format_listrstriprr7rr r) rTcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6          z'BaseEventLoop.default_exception_handlercCs|jdkrKy|j|Wqtk rGtjdddYqXny|j||Wnptk r}zPy#|jddd|d|iWn%tk rtjdddYnXWYdd}~XnXdS) Nz&Exception in default exception handlerrTrz$Unhandled error in exception handlerrr<zeException in default exception handler while handling an unexpected error in custom exception handler)rqr?rKr r)rTr<rNrrrrs"    z$BaseEventLoop.call_exception_handlercCs!|jr dS|jj|dS)N) _cancelledrjr7)rTrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|j||jdS)N)rAr)rTrrrr_add_callback_signalsafe's z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rkre)rTrrrr_timer_handle_cancelled,s z%BaseEventLoop._timer_handle_cancelledc Cslt|j}|tkr|j|tkrg}x3|jD](}|jrYd|_q>|j|q>Wtj|||_d|_nJxG|jr|jdjr|jd8_tj |j}d|_qWd}|j s|j rd}n2|jr)|jdj }t d||j}|jr|dkr|j}|jj|}|j|}|dkrtj} n tj} t|} |dkrtj| d|d| q+| rtj| d|d|d| q+|dkr+tj| d|d|dn|jj|}|j||j|j} xU|jr|jd}|j | krtPtj |j}d|_|j j|qNWt|j } xt| D]} |j j}|jrq|jrTz[||_|j}|j|j|}||jkrCtjd t||Wdd|_Xq|jqWd}dS) NFrrg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds) rrk_MIN_SCHEDULED_TIMER_HANDLESre%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr@r7rheapifyheappoprjrgZ_whenmaxrnr _selectorselectloggingINFODEBUGr logrrprangepopleftrzZ_runryrr)rTZ sched_countZ new_scheduledrtimeoutrrrrlevelZneventend_timeZntodoirrrr1s                                zBaseEventLoop._run_oncec Csytj}tj}Wntk r.dSYnXt|}|j|krNdStj}|}|r|d|fkrtj d|t q||d|_n<|d|fkrtj d|t n|dd|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF) rsset_coroutine_wrapperget_coroutine_wrapperAttributeErrorrur|rZ debug_wrapperrrRuntimeWarning)rTenabledZ set_wrapperZ get_wrapperwrapperZcurrent_wrapperrrrrs.          z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r)rTrrrrszBaseEventLoop.get_debugcCs&||_|jr"|j|dS)N)rrr)rTrYrrrrrs  zBaseEventLoop.set_debug)GrWrarbrUrXrArrrrrrrrrrrrrrrrrrrMr\rrZPY34rrrnrrrrrrrrrrrCrrrrrrr5 AI_PASSIVEr&r'r)r*r,rrr0r2r3r5r?rrArBrCrrrrrrrrrr s  !            %             !   u    _     , 2    c ! )-rhconcurrent.futuresrrr rrKrvrrrrnr9rsrr}r-rrrrrrrNr __all__rDrEBrokenPipeErrorConnectionResetErrorConnectionAbortedErrorZ_FATAL_ERROR_IGNORErrr%r(r*r>r'rHrOZAbstractServerrPZAbstractEventLoopr rrrrsJ                    = /PK!n *__pycache__/protocols.cpython-35.opt-2.pycnu[ ]@skddddgZGdddZGdddeZGdddeZGdddeZdS) BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s@eZdZddZddZddZddZd S) rcCsdS)N)selfZ transportrr./opt/alt/python35/lib64/python3.5/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname__rr r r rrrrrs   c@s(eZdZddZddZdS)rcCsdS)Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrr>s  c@s(eZdZddZddZdS)rcCsdS)Nr)rraddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrgs  c@s4eZdZddZddZddZdS)rcCsdS)Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrts   N)__all__rrrrrrrrs  7) PK!qG'__pycache__/compat.cpython-35.opt-1.pycnu[ Yf@sOdZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCs&tsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css0|]&}t|tr$t|n|VqdS)N) isinstance memoryviewbytes).0datar 3/opt/alt/python35/lib64/python3.5/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes s  r)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s  PK!ߟ!!)__pycache__/__init__.cpython-35.opt-2.pycnu[ ]@sddlZyddlmZWnek r@ddlZYnXejdkryddlmZWnek rddlZYnXddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTejejeje je je je je jejejejZejdkrkddlTeej7ZnddlTeej7ZdS)N) selectorswin32) _overlapped)*)sysr ImportErrorplatformrZ base_eventsZ coroutineseventsfuturesZlocksZ protocolsqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsrr-/opt/alt/python35/lib64/python3.5/__init__.pys6              E   PK!7&&0__pycache__/base_subprocess.cpython-35.opt-1.pycnu[ Yf]#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercsEeZdZddfddZddZddZdd Zd d Zd d ZddZ e j rddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZS)0BaseSubprocessTransportNc  stj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkrd|j d<|tjkrd|j d<|tjkrd|j d ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,      z BaseSubprocessTransport.__repr__cKs tdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x3|jjD]"}|dkr;q&|jjq&W|jdk r|jdkr|jjdkr|jj rt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs%||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transportsz*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procsz#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rJr send_signal)r)signalr/r/r0rKs z#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rJr terminate)r)r/r/r0rMs z!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rJrr?)r)r/r/r0r?s zBaseSubprocessTransport.killc #sy7j}j}|jdk r]|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x'j D]\}}|j||q Wd_ WnKt k r}z+|dk rr|j rr|j|WYdd}~Xn'X|dk r|j r|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rOsrcs tdS)Nr )rPr/)r)r/r0rOsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s6       z&BaseSubprocessTransport._connect_pipescGs?|jdk r(|jj||fn|jj||dS)N)rr4rrQ)r)cbrYr/r/r0_callszBaseSubprocessTransport._callcCs'|j|jj|||jdS)N)r\rZpipe_connection_lost _try_finish)r)rHrZr/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r\rZpipe_data_received)r)rHrYr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|jjr"tjd||||_|jjdkrI||j_|j|jj |j x*|j D]}|j sp|j |qpWd|_ dS)Nz%r exited with return code %r)rr#rr8rr returncoder\rZprocess_exitedr]rrTrU)r)r`r,r/r/r0_process_exiteds      z'BaseSubprocessTransport._process_exitedccs>|jdk r|jS|jj}|jj||EdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr4)r)r,r/r/r0_waits zBaseSubprocessTransport._waitcCsU|jdkrdStdd|jjDrQd|_|j|jddS)Ncss$|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rallrr>rr\_call_connection_lost)r)r/r/r0r]s   z#BaseSubprocessTransport._try_finishc Cs7z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)rZr/r/r0rhs   z-BaseSubprocessTransport._call_connection_lost)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rErFrGrIrJrKrMr?rr(r\r^r_rarbr]rhr/r/)r.r0r s0 )               %     rc@sXeZdZddZddZddZddZd d Zd d Zd S)rNcCs(||_||_d|_d|_dS)NF)rVrHr6rc)r)rVrHr/r/r0rs   z!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rR sz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rHr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs,d|_|jj|j|d|_dS)NT)rcrVr^rH)r)rZr/r/r0ris z(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rVr pause_writing)r)r/r/r0rlsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rVrresume_writing)r)r/r/r0rmsz'WriteSubprocessPipeProto.resume_writingN) r3rjrkrrRr9rirlrmr/r/r/r0rNs      rNc@seZdZddZdS)rPcCs|jj|j|dS)N)rVr_rH)r)rYr/r/r0 data_received#sz%ReadSubprocessPipeProto.data_receivedN)r3rjrkrnr/r/r/r0rP s rP)rrrBrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrNZProtocolrPr/r/r/r0s   PK!r,6$__pycache__/log.cpython-35.opt-1.pycnu[ Yf|@s%dZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python35/lib64/python3.5/asyncio/log.pys PK!x$__pycache__/constants.cpython-35.pycnu[ Yf@sdZdZdZdS)z Constants.N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYrr6/opt/alt/python35/lib64/python3.5/asyncio/constants.pysPK!SS)__pycache__/sslproto.cpython-35.opt-1.pycnu[ Yf]e @sddlZddlZyddlZWnek rBdZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCs|rtdttdr?tj}|sd|_nLtjtj}|jtjO_|jtj O_|j tj |_ |S)Nz(Server side SSL needs a valid SSLContextcreate_default_contextF) ValueErrorhasattrsslrcheck_hostnameZ SSLContextZPROTOCOL_SSLv23ZoptionsZ OP_NO_SSLv2Z OP_NO_SSLv3Zset_default_verify_pathsZ CERT_REQUIRED verify_mode) server_sideserver_hostname sslcontextr5/opt/alt/python35/lib64/python3.5/asyncio/sslproto.py_create_transport_contexts     rcCs ttdS)N MemoryBIO)r r rrrr_is_sslproto_available%srZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@seZdZdZdZdddZeddZed d Zed d Z ed dZ dddZ dddZ ddZ dddZdddZdS)_SSLPipeaAn SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). iNcCsj||_||_||_t|_tj|_tj|_d|_ d|_ d|_ d|_ dS)a The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) _context _server_side_server_hostname _UNWRAPPED_stater r _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextrrrrr__init__Ds       z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r)r#rrrr$Zsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )r)r#rrr ssl_object_sz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake that is currently in progress.)r )r#rrr need_ssldatagsz_SSLPipe.need_ssldatacCs |jtkS)zj Whether a security layer is currently in effect. Return False during handshake. )r_WRAPPED)r#rrrwrappedmsz_SSLPipe.wrappedcCs||jtkrtd|jj|j|jd|jd|j|_ t |_||_ |j ddd\}}|S)aLStart the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completedrronly_handshakeT) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr! feed_ssldata)r#callbackssldataappdatarrr do_handshakevs      z_SSLPipe.do_handshakecCsa|jtkrtd|jtkr6tdt|_||_|jd\}}|S)a1Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. zno security layer presentzshutdown in progressr*)rrr, _SHUTDOWNr"r.)r#r/r0r1rrrshutdowns     z_SSLPipe.shutdowncCs&|jj|jd\}}dS)zSend a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. r*N)rZ write_eofr.)r#r0r1rrrfeed_eofs z_SSLPipe.feed_eofFcCs|jtkr1|r!|g}ng}g|fSd|_|rP|jj|g}g}y|jtkr|jjt|_|j r|j d|r||fS|jtkrx|jj |j }|j ||sPqWni|jt kr0|jjd|_t|_|jrU|jn%|jtkrU|j |jj Wntjtjfk r}zlt|ddtjtjtjfkr|jtkr|j r|j ||jtjk|_WYdd}~XnX|jjr|j |jj ||fS)aFeed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). FNerrno)rrr rwriter-rr2r(r!readmax_sizeappendr3Zunwrapr"r SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr6rpending)r#datar+r1r0chunkexcrrrr.sV                ( z_SSLPipe.feed_ssldatarcCsl|jtkrM|t|kr7||dg}ng}|t|fSg}t|}xd|_y6|t|kr||jj||d7}Wn|tjk r}zY|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjrB|j|jj|t|ks]|jrbPqbW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr rr7r r;reasonr>r6r?r@rrAr:r8)r#rBoffsetr0ZviewrDrrr feed_appdatas2  $  ( z_SSLPipe.feed_appdatai)__name__ __module__ __qualname____doc__r9r%propertyr$r&r'r)r2r4r5r.rIrrrrr0s   Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rlddZ ddZ ddZ ddddZddZddZddZddZdS)_SSLProtocolTransportcCs(||_||_||_d|_dS)NF)_loop _ssl_protocol _app_protocol_closed)r#loopZ ssl_protocol app_protocolrrrr%)s   z_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rQ_get_extra_info)r#namedefaultrrrget_extra_info0sz$_SSLProtocolTransport.get_extra_infocCs ||_dS)N)rR)r#protocolrrr set_protocol4sz"_SSLProtocolTransport.set_protocolcCs|jS)N)rR)r#rrr get_protocol7sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rS)r#rrr is_closing:sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rSrQ_start_shutdown)r#rrrclose=s z_SSLProtocolTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rSwarningswarnResourceWarningr_)r#rrr__del__Ls z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rQ _transport pause_reading)r#rrrreQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rQrdresume_reading)r#rrrrfYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rQrdset_write_buffer_limits)r#ZhighZlowrrrrgasz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjjS)z,Return the current size of the write buffer.)rQrdget_write_buffer_size)r#rrrrhvsz+_SSLProtocolTransport.get_write_buffer_sizecCsTt|tttfs6tdjt|j|s@dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrF TypeErrorformattyperJrQ_write_appdata)r#rBrrrr7zs  z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rQ_abort)r#rrrabortsz_SSLProtocolTransport.abort)rJrKrLr%rYr[r\r]r_rZPY34rcrerfrgrhr7rprrrrrrrO&s            rOc@seZdZdZdddddZdddZd d Zd d Zd dZddZ ddZ ddZ dddZ ddZ ddZddZddZdd Zd!d"d#Zd$d%Zd&d'ZdS)( SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|s-t||}||_|rO| rO||_n d|_||_td||_tj |_ d|_ ||_ ||_ ||_t|j ||j|_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not availablerrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrPrRrO_app_transport_sslpipe_session_established _in_handshake _in_shutdownrd_call_connection_made)r#rTrUrZwaiterrrZcall_connection_maderrrr%s.                 zSSLProtocol.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)r{Z cancelledZ set_exceptionZ set_result)r#rDrrr_wakeup_waiters zSSLProtocol._wakeup_waitercCs5||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rdrrtrrr}_start_handshake)r# transportrrrconnection_mades   zSSLProtocol.connection_madecCsN|jr+d|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)r~rP call_soonrRconnection_lostrdr|r)r#rDrrrrs     zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rR pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rRresume_writing)r#rrrrszSSLProtocol.resume_writingcCsy|jj|\}}Wnatjk r}z>|jjr_tjd||j|j |j dSWYdd}~XnXx|D]}|j j |qWx2|D]*}|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. z%r: SSL error %s (reason %s)N)r}r.r r;rP get_debugrwarningr6rGrqrdr7rR data_receivedr^)r#rBr0r1erCrrrrs     zSSLProtocol.data_receivedc Cspz[|jjr"tjd||jt|jsZ|jj}|rZtj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rPrrdebugrConnectionResetErrorrrR eof_receivedrrdr_)r#Z keep_openrrrrs  zSSLProtocol.eof_receivedcCsD||jkr|j|S|jdk r<|jj||S|SdS)N)rvrdrY)r#rWrXrrrrVs  zSSLProtocol._get_extra_infocCs=|jr dS|jr#|jnd|_|jddS)NTr*)rrrqro)r#rrrr^&s     zSSLProtocol._start_shutdowncCs9|jj|df|jt|7_|jdS)Nr)ryr:rzrE_process_write_backlog)r#rBrrrro/szSSLProtocol._write_appdatacCsm|jjr4tjd||jj|_n d|_d|_|jjd|jj |j dS)Nz%r starts SSL handshakeTr*r)r*r) rPrrrtime_handshake_start_timerryr:rr)r#rrrr4s  zSSLProtocol._start_handshakecCsd|_|jj}ye|dk r*||j}t|jdsy|jry|jjtj krytj ||jWnt k r!}z|j j rt|tjrtjd|ddntjd|dd|jjt|tr |j|dSWYdd}~XnX|j j r^|j j|j}tjd||d|jjd |d |jd |jd ||jr|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateexc_infoTz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@peercertcipher compressionr&)$rr}r&Z getpeercertr rtrr r Z CERT_NONEZmatch_hostname BaseExceptionrPrrir<rrrdr_ ExceptionrrrrrvupdaterrrrRrr|r~rr)r#Z handshake_excZsslobjrrDZdtrrr_on_handshake_complete@sD               z"SSLProtocol._on_handshake_completecCs|jdkrdSyxtt|jD]}|jd\}}|ri|jj||\}}n?|r|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q,WWn`tk r}z@|jrZ|j|n|j|dt|ts|WYdd}~XnXdS)NrrzFatal error on SSL transport)rdrangerEryr}rIr2rr4 _finalizer7Z_pausedrfrzrr _fatal_errorrir)r#irBrHr0rCrDrrrrts8        z"SSLProtocol._process_write_backlogzFatal error on transportc Cst|tjr=|jjrhtjd||ddn+|jjd|d|d|jd|i|jr|jj |dS)Nz%r: %srTmessageZ exceptionrrZ) rirZ_FATAL_ERROR_IGNORErPrrrZcall_exception_handlerrdZ _force_close)r#rDrrrrrs    zSSLProtocol._fatal_errorcCs)d|_|jdk r%|jjdS)N)r}rdr_)r#rrrrs zSSLProtocol._finalizec Cs2z |jdk r|jjWd|jXdS)N)rdrrr)r#rrrrqszSSLProtocol._abort)rJrKrLrMr%rrrrrrrrVr^rorrrrrrqrrrrrss& #       4 , rs)rwr`r ImportErrorrrrrlogrrrrr-r(r3objectrZ_FlowControlMixinZ TransportrOZProtocolrsrrrrs(       nPK!x(@(@+__pycache__/test_utils.cpython-35.opt-2.pycnu[ ]8@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZmZyddlZWnek rdZYnXddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"ej#dkrddl$m%Z%nddlm%Z%ddZ&ddZ'dddZ(ddZ)GdddeZ*GdddeZ+GdddZ,Gd d!d!e,e+Z-d"d#d$d%Z.e/ed&rGd'd(d(ej0eZ1Gd)d*d*e1eZ2Gd+d,d,e2Z3Gd-d.d.e,e3Z4d/d0Z5ej6d1d2Z7ej6d"d#d3d4Z8ej6d5d6d7dd"d#d8d9Z9d:d;Z:Gd<d=d=ej;Z<Gd>d?d?ej=Z>d@dAZ?GdBdCdCe@ZAdDdEZBGdFdGdGe jCZCej6dHdIZDejEejFejGdJdKZHdLdMZIdS)NN)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportwin32) socketpaircCs$tdkrdStjtjSdS)N)sslZ SSLContextZPROTOCOL_SSLv23rr//opt/alt/python35/lib64/python3.5/test_utils.pydummy_ssl_context-s rc CsVtdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)Nrrrrronce5szrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)looprgentrrr run_briefly4s  rcCsttj|}x]|so|dk rP|tj}|dkrPtj|jtjdd|qWdS)NrgMbP?r)timer TimeoutErrorrr sleep)rZpredtimeoutdeadlinerrr run_untilCs    r#cCs|j|j|jdS)N)Z call_soonstopZ run_forever)rrrrrun_onceMsr%c@s(eZdZddZddZdS)SilentWSGIRequestHandlercCs tjS)N)ioStringIO)selfrrr get_stderrZsz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r)formatargsrrr log_message]sz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r*r-rrrrr&Xs  r&cs4eZdZdZfddZddZS)SilentWSGIServercs/tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r)request client_addr) __class__rrr4eszSilentWSGIServer.get_requestcCsdS)Nr)r)r7client_addressrrr handle_errorjszSilentWSGIServer.handle_error)r.r/r0r6r4r;rr)r9rr1as r1c@seZdZddZdS)SSLWSGIServerMixinc Cstjjtjjtdd}tjj|s]tjjtjjtjdd}tjj|d}tjj|d}tj|d|d|d d }y!|j||||j Wnt k rYnXdS) Nz..ZteststestZ test_asyncioz ssl_key.pemz ssl_cert.pemkeyfilecertfileZ server_sideT) ospathjoindirname__file__isdirrZ wrap_socketZRequestHandlerClassrOSError)r)r7r:herer>r?Zssockrrrfinish_requestps$    z!SSLWSGIServerMixin.finish_requestN)r.r/r0rHrrrrr<ns r<c@seZdZdS) SSLWSGIServerN)r.r/r0rrrrrIs rIuse_sslFc #sdd}|r|n|}||tj|j_tjdfdd}|jz VWdjj|j XdS)NcSs#d}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rKrLr)environZstart_responsestatusZheadersrrrapps  z_run_test_server..apptargetcsjddS)NZ poll_intervalg?)Z serve_foreverr)httpdrrsz"_run_test_server..) r&Zset_appZserver_addressaddress threadingThreadstartshutdownZ server_closerB)rSrJ server_clsserver_ssl_clsrOZ server_classZ server_threadr)rQr_run_test_servers        rZAF_UNIXc@seZdZddZdS)UnixHTTPServercCs&tjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r)rrrr`s zUnixHTTPServer.server_bindN)r.r/r0r`rrrrr\s r\cs4eZdZdZddZfddZS)UnixWSGIServerr2cCstj||jdS)N)r\r`Z setup_environ)r)rrrr`s zUnixWSGIServer.server_bindcs/tj\}}|j|j|dfS)N 127.0.0.1)rbrc)r3r4r5r6)r)r7r8)r9rrr4szUnixWSGIServer.get_request)r.r/r0r6r`r4rr)r9rras  rac@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r)r7r:rrrr;sz!SilentUnixWSGIServer.handle_errorN)r.r/r0r;rrrrrds rdc@seZdZdS)UnixSSLWSGIServerN)r.r/r0rrrrres rec Cs!tj}|jSWdQRXdS)N)tempfileNamedTemporaryFilename)filerrrgen_unix_socket_pathsrjccs@t}z |VWdytj|Wntk r:YnXXdS)N)rjr@unlinkrF)rArrrunix_socket_paths   rlccs;t+}td|d|dtdtEdHWdQRXdS)NrSrJrXrY)rlrZrdre)rJrArrrrun_test_unix_servers rmhostz 127.0.0.1portc cs.td||fd|dtdtEdHdS)NrSrJrXrY)rZr1rI)rnrorJrrrrun_test_serversrpcCsni}xHt|D]:}|jdr:|jdr:qtdd||.genFTrg& .>)r3r~_check_on_close_gennext_timeZ_clock_resolution_timersr| _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r)r)r9rrr~s              zTestLoop.__init__cCs|jS)N)r)r)rrrr4sz TestLoop.timecCs|r|j|7_dS)N)r)r)advancerrr advance_time7szTestLoop.advance_timec sOtj|jrKy|jjdWntk r>Yn XtddS)NrzTime generator is not finished)r3rrrsend StopIterationAssertionError)r))r9rrr<s   zTestLoop.closecGs tj||||j|.)r rrZthreading_setup_thread_cleanup)r)rrrsetUps zTestCase.setUpcCsU|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r)rrrtearDowns    zTestCase.tearDowncOsGddd}|S)Nc@s(eZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r)rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r)excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r.r/r0rrrrrrEmptyCMs  rr)r)r,rrrrrsubTestszTestCase.subTest) r.r/r0rrrrrrZPY34rrrrrrs    rc cs;tj}ztjtjddVWdtj|XdS)Nr)rlevelsetLevelloggingCRITICAL)Z old_levelrrrdisable_loggers   rcCs=tjtj}||_||_||_d|j_|S)Ng)rZ MagicMocksocketprotorwfamily gettimeoutrr)rrwrsockrrrmock_nonblocking_sockets     rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availablerrF)rZpatchrrrrforce_legacy_ssl_supports r)Jr contextlibr'rr@rrr^rrfrTrZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrcrrr r r r Z coroutinesr logrr=rplatformZ windows_utilsrrrr#r%r&r1r<rIrZhasattrr_r\rardrerjcontextmanagerrlrmrpr{ BaseSelectorr|Z BaseEventLooprrvrrrrr IPPROTO_TCP SOCK_STREAMAF_INETrrrrrrs~                           -  PK!cz=$__pycache__/log.cpython-35.opt-2.pycnu[ ]|@sddlZejeZdS)N)logging getLogger __package__loggerrr(/opt/alt/python35/lib64/python3.5/log.pys PK!,F*__pycache__/constants.cpython-35.opt-2.pycnu[ ]@sdZdZdS)N)Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYrr./opt/alt/python35/lib64/python3.5/constants.pysPK!")+__pycache__/transports.cpython-35.opt-2.pycnu[ ]R'@sddlmZddddddgZGdddZGd ddeZGd ddeZGd ddeeZGd ddeZGd ddeZGdddeZ dS))compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@s^eZdZdddZdddZddZdd Zd d Zd d ZdS)rNcCs|dkri}||_dS)N)_extra)selfextrar //opt/alt/python35/lib64/python3.5/transports.py__init__ s zBaseTransport.__init__cCs|jj||S)N)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCs tdS)N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCs tdS)N)r)r r r r closeszBaseTransport.closecCs tdS)N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCs tdS)N)r)r r r r get_protocol(szBaseTransport.get_protocol) __name__ __module__ __qualname__rrrrrrr r r r r s   c@s(eZdZddZddZdS)rcCs tdS)N)r)r r r r pause_reading0szReadTransport.pause_readingcCs tdS)N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrr r r r r-s  c@sjeZdZddddZddZddZdd Zd d Zd d ZddZ dS)rNcCs tdS)N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCs tdS)N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCs tdS)N)r)r datar r r write]szWriteTransport.writecCs tj|}|j|dS)N)rZflatten_list_bytesr#)r Z list_of_datar"r r r writelineseszWriteTransport.writelinescCs tdS)N)r)r r r r write_eofnszWriteTransport.write_eofcCs tdS)N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCs tdS)N)r)r r r r abort{szWriteTransport.abort) rrrr r!r#r$r%r&r'r r r r rAs    c@seZdZdS)rN)rrrr r r r rs c@s+eZdZdddZddZdS)rNcCs tdS)N)r)r r"addrr r r sendtoszDatagramTransport.sendtocCs tdS)N)r)r r r r r'szDatagramTransport.abort)rrrr)r'r r r r rs  c@sXeZdZddZddZddZddZd d Zd d Zd S)rcCs tdS)N)r)r r r r get_pidszSubprocessTransport.get_pidcCs tdS)N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCs tdS)N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCs tdS)N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCs tdS)N)r)r r r r terminates zSubprocessTransport.terminatecCs tdS)N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs      cs|eZdZddfddZddZddZdd Zddd d Zddd d ZddZ S)_FlowControlMixinNcs0tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs  z_FlowControlMixin.__init__cCs|j}||jkrdS|jsd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NTmessagezprotocol.pause_writing() failed exception transportr)r! _high_waterr5 _protocolZ pause_writing Exceptionr4call_exception_handler)r sizeexcr r r _maybe_pause_protocols    z'_FlowControlMixin._maybe_pause_protocolcCs|jr|j|jkrd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NFr8z protocol.resume_writing() failedr9r:r)r5r! _low_waterr<Zresume_writingr=r4r>)r r@r r r _maybe_resume_protocols   z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rBr;)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCs|dkr+|dkr!d}n d|}|dkrA|d}||koXdknsstd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr;rB)r rrr r r r6s       z*_FlowControlMixin._set_write_buffer_limitscCs$|jd|d||jdS)Nrr)r6rA)r rrr r r r -sz)_FlowControlMixin.set_write_buffer_limitscCs tdS)N)r)r r r r r!1sz'_FlowControlMixin.get_write_buffer_size) rrrrrArCrDr6r r!r r )r7r r2s    r2N) Zasyncior__all__rrrrrrr2r r r r s #D4PK!G9g""!__pycache__/queues.cpython-35.pycnu[ Yf@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr3/opt/alt/python35/lib64/python3.5/asyncio/queues.pyrs c@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrs c@seZdZdZdddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS))ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rloopNcCs|dkrtj|_n ||_||_tj|_tj|_d|_t j d|j|_ |j j |j |dS)Nrr)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s     zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs7x0|r2|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs     zQueue._wakeup_nextcCs(djt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCsdj|j}t|ddr@|djt|j7}|jre|djt|j7}|jr|djt|j7}|jr|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts   z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs*|jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullmsz Queue.fullc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs    z Queue.putcCsO|jrt|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s    zQueue.put_nowaitc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|jS)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7r8r( get_nowait)rgetterrrrgets   z Queue.getcCs2|jrt|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr<s   zQueue.get_nowaitcCsJ|jdkrtd|jd8_|jdkrF|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)r ValueErrorrr)rrrr task_dones  zQueue.task_doneccs%|jdkr!|jjEdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r>r<r@rBrrrrrs&            c@sFeZdZdZddZejddZejddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrDr%rEr"rrrrrs  c@s:eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs    JoinableQueue)r__all__rrFrr r Z coroutinesr ExceptionrrrrrZPY35rHr#rrrrs   PK!< y("("+__pycache__/coroutines.cpython-35.opt-2.pycnu[ ])@s(dddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd l m Z ejd Zejj oeejjd ZyejZejZWnek r dZdZYnXy ejZWnek r9d d ZYnXyddlmZm Z!Wne"k rrdZZ!YnXddZ#e#Z$[#ddZ%GdddZ&ddZe'Z(ddZej)e&fZ*edk re*ef7Z*edk r efe*Z*ddZ+ddZ,dS) coroutineiscoroutinefunction iscoroutineN)compat)events)futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r //opt/alt/python35/lib64/python3.5/coroutines.py.sr ) Coroutine AwaitablecCsaGddd}dd}d}|}||}t||j||j|fkS) Nc@s@eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__:sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__<sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__>sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r send@s z&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen9s    rcss |EdHdS)Nr )genr r r yield_from_genCsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug8s     r"cCs t|dS)N) CoroWrapper)rr r r debug_wrapperOsr$c@s3eZdZdddZddZddZdd ZerTd d Zn d d Zddd dZ ddZ e ddZ e ddZ e ddZejr#ddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)%r#NcCs[||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr traceback extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r rZs   zCoroWrapper.__init__cCsRt|}|jr>|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__bs    zCoroWrapper.__repr__cCs|S)Nr )rr r r riszCoroWrapper.__iter__cCs|jjdS)N)rr)rr r r rlszCoroWrapper.__next__cGsHtj}|j}|jj|jtkr8|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr r/Zcallerr r r rts    zCoroWrapper.sendcCs|jj|S)N)rr)rr r r r r|scCs|jj|||S)N)rthrow)rtyper r%r r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r8szCoroWrapper.closecCs |jjS)N)rgi_frame)rr r r r9szCoroWrapper.gi_framecCs |jjS)N)r gi_running)rr r r r:szCoroWrapper.gi_runningcCs |jjS)N)rgi_code)rr r r r;szCoroWrapper.gi_codecCs@t|jdd}|dk r<tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr<r r r __await__s  zCoroWrapper.__await__cCs |jjS)N)r gi_yieldfrom)rr r r r@szCoroWrapper.gi_yieldfromcCs |jjS)N)rr<)rr r r r<szCoroWrapper.cr_awaitcCs |jjS)N)r cr_running)rr r r rAszCoroWrapper.cr_runningcCs |jjS)N)rcr_code)rr r r rBszCoroWrapper.cr_codecCs |jjS)N)rcr_frame)rr r r rCszCoroWrapper.cr_framecCst|dd}t|dd}|dkrBt|dd}|dk r|jd krd|}t|df}|rdjtj|}|d7}||j7}tj|dS) Nrr9rCrz%r was never yielded fromr)z6 Coroutine object created at (most recent call last): r+)r*r4joinr% format_listrstripr error)rrr/msgtbr r r __del__s   zCoroWrapper.__del__)rrrrr0rr_YIELD_FROM_BUGrr6r8propertyr9r:r;rZPY35r?r@r<rArBrCrKr r r r r#Ws(        r#cstrStjr(n!tjfddtsstdkrd}qt}n$tjfdd}t|_|S)Nc ?s||}tj|s<tj|s<t|trJ|EdH}nKtdk ry |j}Wntk rwYnXt|tr|EdH}|S)N) rZisfutureinspectZ isgenerator isinstancer# _AwaitableABCr?AttributeError)argskwresZ await_meth)r r r r!s   zcoroutine..corocs\t||d}|jr.|jd=tdd|_tdd|_|S)Nr rrrr+)r#r)r*rr)rRkwdsw)r!r r r wrappers   zcoroutine..wrapper)_inspect_iscoroutinefunctionrNisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rWr )r!r r rs  !  $ cCs"t|ddtkp!t|S)Nr^)r*r^rX)r r r r rscCs t|tS)N)rO_COROUTINE_TYPES)objr r r r sc "Csft|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk ry |j}Wntk rYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkr#t j |fi}y |j}Wntk rM|j}YnXy |j}Wntk rx|j}YnX|j}d}t|t rtj|j  r|j dk rt j|j }|dk r|\}}|dkrd |||f} qbd |||f} nG|dk rF|j}d |||f} n|j}d |||f} | S) NrBr;rrz{}()Fz {} runningrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr>rArQr:rOr#r rrZ_format_callbackr;rBr9rC co_filenamerNrYZ_get_function_sourcef_linenoco_firstlineno) r!Z coro_namerunningr Z coro_codeZ coro_framefilenamelinenosourcer.r r r r,sl                      r,)-__all__rZrNZopcodeosr'r%typesrDrrrlogr Zopmapr5flagsignore_environmentboolenvirongetr\rr] CoroutineTypeZ_types_CoroutineTyperQrrXcollections.abcrZ _CoroutineABCrrP ImportErrorr"rLr$r#objectr^ GeneratorTyper_rr,r r r r sX                   i :       PK!WEE0__pycache__/proactor_events.cpython-35.opt-1.pycnu[ YfN@s_dZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdddfddZddZddZd d Zd d Zd dZ ddZ e j rddZ dddZddZddZddZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk r|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__ ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"     z#_ProactorBasePipeTransport.__repr__cCs||jdr) rUrVrWrrr[ ExceptionrBrr\r)rrnrDr#r#r$rs    z(BaseProactorEventLoop._loop_self_readingcCs|jjddS)Ns)rrl)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs5dfddjdS)Ncsy|dk r|j\}}jr@tjd||}dk rj||dddd|idn"j||dd|idjrdSjj}Wnt k rL}zbj dkrj dd d |d ij njr:tjd d dWYdd}~Xn?t jk rjj Yn!X|jj <|jdS)Nz#%r got a new connection from %r: %rrTr r{r!rr=zAccept failed on a socketr>rHzAccept failed on socket %rr<)rUZ_debugr rArrrrVrrZr*rBr7rr[rr\)rnZconnZaddrrrD)rprotocol_factoryrr!rrr#r$rs>            z2BaseProactorEventLoop._start_serving..loop)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_eventssz%BaseProactorEventLoop._process_eventscCs5x!|jjD]}|jqW|jjdS)N)rvaluesr6clear)rZfuturer#r#r$rsz*BaseProactorEventLoop._stop_accept_futurescCs(|j|jj||jdS)N)rrV _stop_servingr7)rrr#r#r$r#s z#BaseProactorEventLoop._stop_serving)r(rKrLr rrrrrr7rrrrrrrrrrrrrr#r#)r"r$r{s4           (  )rM__all__rHr8rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrNZWriteTransportr_rrZ TransportrxrzZ BaseEventLooprr#r#r#r$s0     M T  PK!;SrZrZ/__pycache__/windows_events.cpython-35.opt-1.pycnu[ Yf.l@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cseZdZdZddfddZfddZdd Zfd d Zfd d ZfddZ S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. loopNcs3tjd||jr&|jd=||_dS)Nrr)super__init___source_traceback_ov)selfovr) __class__;/opt/alt/python35/lib64/python3.5/asyncio/windows_events.pyr-s  z_OverlappedFuture.__init__csZtj}|jdk rV|jjr0dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s  z_OverlappedFuture._repr_infocCs|jdkrdSy|jjWnctk r}zCddd|d|i}|jrg|j|d<|jj|WYdd}~XnXd|_dS)Nmessagez&Cancelling an overlapped future failed exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s   #z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Js z_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rsz_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/rr)rrr's  rcseZdZdZddfddZddZfdd Zd d Zd d ZfddZ fddZ fddZ S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.rNcsNtjd||jr&|jd=||_||_||_d|_dS)NrrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZs     z_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr6Z WAIT_OBJECT_0)rrrr_pollhsz_BaseWaitHandleFuture._pollcs~tj}|jd|j|jdk rW|jrDdnd}|j||jdk rz|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr6r<r7)rr!r")rrrrms z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|Wnytk r}zY|jtjkrddd|d|i}|jr|j|d<|jj |dSWYdd}~XnX|j ddS)NFr#z$Failed to unregister the wait handler$r%r&) r8r7r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r?)rr:r+r,rrr_unregister_wait|s"       z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rBrr')r)rrrr's z_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rBrr.)rr$)rrrr.s z#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rBrr/)rr0)rrrr/s z _BaseWaitHandleFuture.set_result) r1r2r3r4rr<rr?rBr'r.r/rr)rrr5Ws    r5csLeZdZdZddfddZddZfdd ZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. rNcs)tj|||d|d|_dS)Nr)rr_done_callback)rreventr:r)rrrrsz_WaitCancelFuture.__init__cCstddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs3tt|j|jdk r/|j|dS)N)rrC_schedule_callbacksrD)r)rrrrGsz%_WaitCancelFuture._schedule_callbacks)r1r2r3r4rr'rGrr)rrrCs  rCcsFeZdZddfddZfddZddZS) _WaitHandleFuturerNcsVtj|||d|||_d|_tjdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr9r:proactorr)rrrrs   z_WaitHandleFuture.__init__csa|jdk r1tj|jd|_d|_|jj|jd|_tj|dS)N) rJr; CloseHandlerKrI _unregisterrrr?)rr>)rrrr?s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnytk r}zY|jtjkrddd|d|i}|jr|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFr#z$Failed to unregister the wait handler$r%r&)r8r7r ZUnregisterWaitExrJr(r@rArr)r*rI _wait_cancelr?rK)rr:r+r,rrrrBs$       z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBrr)rrrHs rHc@sXeZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs@||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs    zPipeServer.__init__cCs |j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Cs|jrdStjtjB}|r3|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr;ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs     zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsu|jdk r%|jjd|_|jdk rqx|jD]}|jq>Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs    zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs     rPc@s"eZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCs tjS)N)r socketpair)rrrr _socketpair&sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre#s recspeZdZdZdfddZddZeddZed d Zedd d Z S) rz2Windows version of proactor event loop using IOCP.Ncs)|dkrt}tj|dS)N)rrr)rrL)rrrr-s  zProactorEventLoop.__init__cCs tjS)N)r rf)rrrrrg2szProactorEventLoop._socketpairccsN|jj|}|EdH}|}|j||dd|i}||fS)Nextraaddr)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection5s   z(ProactorEventLoop.create_pipe_connectioncsAtdfddjgS)Ncsbd}y|rj|j}jj|jrE|jdS}j||ddij}|dkrdSjj|}Wnt k r#}zh|r|j d krj ddd|d|i|jnj rt jd|d d WYdd}~Xn;tjk rG|rC|jYnX|_|jdS) Nrhrirr#zPipe accept failedr$razAccept pipe failed on pipe %rexc_infoTr)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwBs<           z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipe>s !( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||d| d|| } y | EdHWn+tk rv} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)Nwaiterrh) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerhkwargsrzZtranspr+errrrr_make_subprocess_transportms      z,ProactorEventLoop._make_subprocess_transport) r1r2r3r4rrgr rpryrrr)rrr*s   /c@s6eZdZdZdddZddZddZd d d Zd d ZdddZ dddZ ddZ ddZ ddZ eddZd ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd d)d*Zd+d,Zd-d.Zd/d0Zd S)1rz#Proactor implementation using IOCP.lcCsdd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr8 _unregistered_stopped_serving)rZ concurrencyrrrrs    zIocpProactor.__init__cCs)d|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs,|js|j||j}g|_|S)N)rr<)rtimeoutrXrrrselects     zIocpProactor.selectcCs |jj}|j||S)N)r)r{r/)rvaluer>rrr_results zIocpProactor._resultrc Cs|j|tjt}yHt|tjrM|j|j||n|j|j|Wnt k r|j dSYnXdd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N) getresultr(r@r ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs   zIocpProactor.recvcCs|j|tjt}t|tjrJ|j|j||n|j|j|dd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N)rr(r@r rrr~)rorrr+rrr finish_sends z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends  zIocpProactor.sendcs|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j |d|j |S)Ncs^|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts    z*IocpProactor.accept..finish_acceptc ss6y |EdHWn"tjk r1|jYnXdS)N)rrurb)r%rrrr accept_coros   z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts   zIocpProactor.acceptcs|jytjjjWnStk r}z3|jtjkrTj ddkrmWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs'|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects   z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(r@errnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects zIocpProactor.connectcsi|jtjt}|jj}|rD|jSfdd}|j||S)Ncs|jS)N)r)rorr)rarrfinish_accept_pipes z4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrss  zIocpProactor.accept_pipeccst}xytj|}PWn:tk rY}z|jtjkrGWYdd}~XnXt|dt}tj |d|j EdHq Wt j |S)Nr) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(r@ZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr9r+rrrrjszIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr9rrrrwait_for_handle*szIocpProactor.wait_for_handlecCs"|j|dd}||_|S)NT)rrD)rrEZ done_callbackr>rrrrO2s zIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|r|t |||d|j nt ||||d|j j rj d=fdd}|d|f|j|j <S)Ng@@rrcs jS)N)r<)rorr)rmrrfinish_wait_for_handleMsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r;INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rCr)rHrr)rr9rZ _is_cancelmsrr:rr)rmrr9s      zIocpProactor._wait_for_handlecCsB||jkr>|jj|tj|j|jdddS)Nr)r8r]r rrtr)robjrrrrYsz IocpProactor._register_with_iocpcCst|d|j}|jr(|jd=|jsy|dd|}Wn2tk r{}z|j|WYdd}~XnX|j|||||f|j|j<|S)Nrrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrcs     zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr=)rrrrrrNszIocpProactor._unregistercCs tj|}|jd|S)Nr)rr)rrsrrrrs zIocpProactor._get_accept_socketcCs|dkrt}nF|dkr0tdn+tj|d}|tkr[tdxutj|j|}|dkrPd}|\}}}}y"|jj|\}} } } Wnrt k r.|j j r|j j dddd||||fi|dtj fkr'tj|w^YnX| |jkrK|jq^|js^y| ||| } WnBtk r} z"|j| |jj|WYdd} ~ Xq^X|j| |jj|q^Wx'|jD]} |jj| jdqW|jjdS) Nrznegative timeoutg@@ztimeout too bigr#z8GetQueuedCompletionStatus() returned an unexpected eventstatusz)err=%s transferred=%s key=%#x address=%#x)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr;rMrr'doner(r.rr=r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr<sJ      "      # zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCs7xt|jjD]\}\}}}}|jr=qt|trOqy|jWqtk r}zR|jdk rddd|d|i}|j r|j |d<|jj |WYdd}~XqXqWx)|jr|j dst j dqWg|_|jdk r3tj|jd|_dS)Nr#zCancelling a future failedr$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrCr'r(r)rr*r<r debugrrr;rM)rr r>rrrr+r,rrrrbs,.    '  zIocpProactor.closecCs|jdS)N)rb)rrrrrdszIocpProactor.__del__)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr<rrbrdrrrrrs.          7  c@seZdZddZdS)r|c swtj|d|d|d|d|d||_fdd}jjjtjj} | j|dS)Nrrrrrcs jj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrsz4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr6rv) rr~rrrrrrrrmr)rr_starts !z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|s r|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrs r)-r4r;rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr5rCrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsJ        0J4;]jPK! 1ee!__pycache__/events.cpython-35.pycnu[ YfTY@s dZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddZ ddZdddZddZGdddZGdddeZGdddZGdddZGdddZGd d!d!eZdae jZGd"d#d#e jZeZd$dZd%d Zd&d'Zd(dZ d)dZ!d*dZ"d+d Z#d,d Z$d-d Z%d.d Z&dS)/z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compatcCstjrtj|}nt|dr3|j}tj|r[|j}|j|j fSt |t j rzt |jStjrt |t jrt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder3/opt/alt/python35/lib64/python3.5/asyncio/events.pyrs     rcCsag}|r&|jdd|D|rL|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argrrr 0sz*_format_args_and_kwargs..css0|]&\}}dj|tj|VqdS)z{}={}N)formatr r!)r"kvrrrr$2s(z, ))extenditemsjoin)argskwargsr+rrr_format_args_and_kwargs(sr/cCst|tjrAt|||}t|j|j|j|St|drbt |d}n-t|drt |d}n t |}|t||7}|r||7}|S)N __qualname____name__) rrrr/_format_callbackrr-keywordsrgetattrr!)rr-r.suffix func_reprrrrr37s  r3cCs6t||d}t|}|r2|d|7}|S)Nz at %s:%s)r3r)rr-r7sourcerrr_format_callback_sourceHs  r9c@sXeZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsg||_||_||_d|_d|_|jjrZtjtj d|_ n d|_ dS)NF) r=r:r;r<r? get_debug traceback extract_stacksys _getframer>)selfcallbackr-looprrr__init__Vs     zHandle.__init__cCs|jjg}|jr%|jd|jdk rP|jt|j|j|jr|jd}|jd|d|df|S)NZ cancelledrAzcreated at %s:%sr) __class__r2r<appendr:r9r;r>)rGinfoframerrr _repr_infoas    zHandle._repr_infocCs3|jdk r|jS|j}ddj|S)Nz<%s> )r?rPr,)rGrNrrr__repr__ls zHandle.__repr__cCsF|jsBd|_|jjr0t||_d|_d|_dS)NT)r<r=rBr!r?r:r;)rGrrrcancelrs    z Handle.cancelcCsy|j|jWntk r}zgt|j|j}dj|}d|d|d|i}|jr{|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {}messageZ exceptionhandleZsource_traceback)r:r; Exceptionr9r%r>r=call_exception_handler)rGexccbmsgcontextrrr_run}s   #z Handle._runN)r:r;r<r=r>r?r@) r2 __module__r1__doc__ __slots__rJrPrRrSr\rrrrrPs   cseZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZS)rz7Object returned by timed callback registration methods. _scheduled_whencsQ|dk sttj||||jr;|jd=||_d|_dS)NrAFrK)AssertionErrorsuperrJr>rar`)rGwhenrHr-rI)rLrrrJs    zTimerHandle.__init__cs?tj}|jrdnd}|j|d|j|S)NrAzwhen=%s)rcrPr<insertra)rGrNpos)rLrrrPszTimerHandle._repr_infocCs t|jS)N)hashra)rGrrr__hash__szTimerHandle.__hash__cCs|j|jkS)N)ra)rGotherrrr__lt__szTimerHandle.__lt__cCs#|j|jkrdS|j|S)NT)ra__eq__)rGrjrrr__le__szTimerHandle.__le__cCs|j|jkS)N)ra)rGrjrrr__gt__szTimerHandle.__gt__cCs#|j|jkrdS|j|S)NT)rarl)rGrjrrr__ge__szTimerHandle.__ge__cCsYt|trU|j|jkoT|j|jkoT|j|jkoT|j|jkStS)N)rrrar:r;r<NotImplemented)rGrjrrrrls zTimerHandle.__eq__cCs$|j|}|tkrtS| S)N)rlrp)rGrjZequalrrr__ne__szTimerHandle.__ne__cs*|js|jj|tjdS)N)r<r=_timer_handle_cancelledrcrS)rG)rLrrrSs zTimerHandle.cancel)r2r]r1r^r_rJrPrirkrmrnrorlrqrSrr)rLrrs         c@s.eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)rp)rGrrrcloseszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)rp)rGrrr wait_closedszAbstractServer.wait_closedN)r2r]r1r^rsrtrrrrrs  c@sIeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%d&d%d'd%d(d%d)d*Zd%d+d,Zd-d-d.d-d$d%d'd%d(d%d/d-d0d-d1d-d2d3Zd-d-d$ejd(ejd/d-d4d5d.d-d6d-d7d-d8d9Zd.d-d/d-d1d-d:d;Zd/d-d4d5d.d-d<d=Zd-d-d$d%d'd%d(d%d6d-d7d-d>d-d/d-d?d@ZdAdBZdCdDZ dEe!j"dFe!j"dGe!j"dHdIZ#dEe!j"dFe!j"dGe!j"dJdKZ$dLdMZ%dNdOZ&dPdQZ'dRdSZ(dTdUZ)dVdWZ*dXdYZ+dZd[Z,d\d]Z-d^d_Z.d`daZ/dbdcZ0dddeZ1dfdgZ2dhdiZ3djdkZ4dldmZ5dndoZ6d-S)przAbstract event loop.cCs tdS)z*Run the event loop until stop() is called.N)NotImplementedError)rGrrr run_foreverszAbstractEventLoop.run_forevercCs tdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)ru)rGZfuturerrrrun_until_completesz$AbstractEventLoop.run_until_completecCs tdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)ru)rGrrrstopszAbstractEventLoop.stopcCs tdS)z3Return whether the event loop is currently running.N)ru)rGrrr is_runningszAbstractEventLoop.is_runningcCs tdS)z*Returns True if the event loop was closed.N)ru)rGrrr is_closedszAbstractEventLoop.is_closedcCs tdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)ru)rGrrrrss zAbstractEventLoop.closecCs tdS)z,Shutdown all active asynchronous generators.N)ru)rGrrrshutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCs tdS)z3Notification that a TimerHandle has been cancelled.N)ru)rGrUrrrrrsz)AbstractEventLoop._timer_handle_cancelledcGs|jd||S)Nr) call_later)rGrHr-rrr call_soonszAbstractEventLoop.call_sooncGs tdS)N)ru)rGZdelayrHr-rrrr| szAbstractEventLoop.call_latercGs tdS)N)ru)rGrdrHr-rrrcall_at szAbstractEventLoop.call_atcCs tdS)N)ru)rGrrrtimeszAbstractEventLoop.timecCs tdS)N)ru)rGrrr create_futureszAbstractEventLoop.create_futurecCs tdS)N)ru)rGcororrr create_taskszAbstractEventLoop.create_taskcGs tdS)N)ru)rGrHr-rrrcall_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGs tdS)N)ru)rGexecutorrr-rrrrun_in_executor sz!AbstractEventLoop.run_in_executorcCs tdS)N)ru)rGrrrrset_default_executor#sz&AbstractEventLoop.set_default_executorfamilyrtypeprotoflagscCs tdS)N)ru)rGhostportrrrrrrr getaddrinfo(szAbstractEventLoop.getaddrinfocCs tdS)N)ru)rGZsockaddrrrrr getnameinfo+szAbstractEventLoop.getnameinfoNsslsock local_addrserver_hostnamec Cs tdS)N)ru) rGprotocol_factoryrrrrrrrrrrrrcreate_connection.sz#AbstractEventLoop.create_connectionbacklogd reuse_address reuse_portc Cs tdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)ru) rGrrrrrrrrrrrrr create_server3s'zAbstractEventLoop.create_servercCs tdS)N)ru)rGrpathrrrrrrcreate_unix_connection\sz(AbstractEventLoop.create_unix_connectioncCs tdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)ru)rGrrrrrrrrcreate_unix_serverasz$AbstractEventLoop.create_unix_serverallow_broadcastc Cs tdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)ru) rGrrZ remote_addrrrrrrrrrrrcreate_datagram_endpointvs!z*AbstractEventLoop.create_datagram_endpointcCs tdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)ru)rGrpiperrrconnect_read_pipes z#AbstractEventLoop.connect_read_pipecCs tdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)ru)rGrrrrrconnect_write_pipes z$AbstractEventLoop.connect_write_pipestdinstdoutstderrcKs tdS)N)ru)rGrcmdrrrr.rrrsubprocess_shellsz"AbstractEventLoop.subprocess_shellcOs tdS)N)ru)rGrrrrr-r.rrrsubprocess_execsz!AbstractEventLoop.subprocess_execcGs tdS)N)ru)rGfdrHr-rrr add_readerszAbstractEventLoop.add_readercCs tdS)N)ru)rGrrrr remove_readerszAbstractEventLoop.remove_readercGs tdS)N)ru)rGrrHr-rrr add_writerszAbstractEventLoop.add_writercCs tdS)N)ru)rGrrrr remove_writerszAbstractEventLoop.remove_writercCs tdS)N)ru)rGrnbytesrrr sock_recvszAbstractEventLoop.sock_recvcCs tdS)N)ru)rGrdatarrr sock_sendallszAbstractEventLoop.sock_sendallcCs tdS)N)ru)rGrZaddressrrr sock_connectszAbstractEventLoop.sock_connectcCs tdS)N)ru)rGrrrr sock_acceptszAbstractEventLoop.sock_acceptcGs tdS)N)ru)rGsigrHr-rrradd_signal_handlersz$AbstractEventLoop.add_signal_handlercCs tdS)N)ru)rGrrrrremove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCs tdS)N)ru)rGfactoryrrrset_task_factorysz"AbstractEventLoop.set_task_factorycCs tdS)N)ru)rGrrrget_task_factorysz"AbstractEventLoop.get_task_factorycCs tdS)N)ru)rGrrrget_exception_handlersz'AbstractEventLoop.get_exception_handlercCs tdS)N)ru)rGZhandlerrrrset_exception_handlersz'AbstractEventLoop.set_exception_handlercCs tdS)N)ru)rGr[rrrdefault_exception_handlersz+AbstractEventLoop.default_exception_handlercCs tdS)N)ru)rGr[rrrrWsz(AbstractEventLoop.call_exception_handlercCs tdS)N)ru)rGrrrrBszAbstractEventLoop.get_debugcCs tdS)N)ru)rGZenabledrrr set_debugszAbstractEventLoop.set_debug)7r2r]r1r^rvrwrxryrzrsr{rrr}r|r~rrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrWrBrrrrrrsx                 $  &   !                   c@sReZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCs tdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)ru)rGrrrrsz&AbstractEventLoopPolicy.get_event_loopcCs tdS)z3Set the event loop for the current context to loop.N)ru)rGrIrrrr sz&AbstractEventLoopPolicy.set_event_loopcCs tdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)ru)rGrrrr sz&AbstractEventLoopPolicy.new_event_loopcCs tdS)z$Get the watcher for child processes.N)ru)rGrrrr sz)AbstractEventLoopPolicy.get_child_watchercCs tdS)z$Set the watcher for child processes.N)ru)rGwatcherrrrr "sz)AbstractEventLoopPolicy.set_child_watcherN) r2r]r1r^rr r r r rrrrrs    c@seeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r2r]r1r= _set_calledrrrr_Local6s rcCs|j|_dS)N)r_local)rGrrrrJ:sz#BaseDefaultEventLoopPolicy.__init__cCs|jjdkrJ|jj rJttjtjrJ|j|j|jjdkrut dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rr=rr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rGrrrr=s z)BaseDefaultEventLoopPolicy.get_event_loopcCs=d|j_|dks-t|ts-t||j_dS)zSet the event loop.TN)rrrrrbr=)rGrIrrrr Ks !z)BaseDefaultEventLoopPolicy.set_event_loopcCs |jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rGrrrr Qsz)BaseDefaultEventLoopPolicy.new_event_loop) r2r]r1r^rrlocalrrJrr r rrrrr's    rc@seZdZdZdZdS) _RunningLoopN)r2r]r1r=_pidrrrrres rcCs2tj}|dk r.tjtjkr.|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_loopr=rosgetpid)Z running_looprrrrms !cCstjt_|t_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrr=)rIrrrr xsc Cs7t*tdkr,ddlm}|aWdQRXdS)NrA)DefaultEventLoopPolicy)_lock_event_loop_policyr0r)rrrr_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrrrrrrs cCs+|dks!t|ts!t|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)rrrbr)Zpolicyrrrrs!cCs&t}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_looprrrrs  cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rIrrrr scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr rrrrr scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr rrrrr scCstj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rrrrr s)'r^__all__rrrr rrrErrCZasynciorrr/r3r9rrrrrrrZLockrrrrrr rrrrr r r r rrrrsT              >8 4"7        PK!H@tn77(__pycache__/streams.cpython-35.opt-2.pycnu[ ]^ @sdddddddgZddlZeed rIejd d gd d lmZd dlmZd dlmZd dlmZd dlm Z d dl m Z d"Z Gddde ZGdddeZe ddddde ddZe ddddde ddZeed rte dddde dd Ze dddde dd ZGdddejZGdddeejZGd ddZGd!ddZdS)# StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs"eZdZfddZS)rcs6tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__,/opt/alt/python35/lib64/python3.5/streams.pyr s  zIncompleteReadError.__init__)__name__ __module__ __qualname__rrr)rrrs cs"eZdZfddZS)rcstj|||_dS)N)rrconsumed)rmessager!)rrrr-szLimitOverrunError.__init__)rrr rrr)rrr's looplimitc +s|dkrtj}td|d|}t|d||jfdd|||EdH\}}t|||}||fS)Nr$r#csS)Nrr)protocolrrKsz!open_connection..)rget_event_looprrcreate_connectionr) hostportr#r$kwdsreader transport_writerr)r%rr2s  )c+sKdkrtjfdd}j||||EdHS)Ncs.tdd}t|d}|S)Nr$r#)rr)r,r%)client_connected_cbr$r#rrfactoryks  zstart_server..factory)rr'Z create_server)r0r)r*r#r$r+r1r)r0r$r#rrPs  c+s|dkrtj}td|d|}t|d||jfdd||EdH\}}t|||}||fS)Nr$r#csS)Nrr)r%rrr&sz&open_unix_connection..)rr'rrZcreate_unix_connectionr)pathr#r$r+r,r-r.r/r)r%rr ws  &c+sHdkrtjfdd}j|||EdHS)Ncs.tdd}t|d}|S)Nr$r#)rr)r,r%)r0r$r#rrr1s  z"start_unix_server..factory)rr'Zcreate_unix_server)r0r2r#r$r+r1r)r0r$r#rr s  c@sUeZdZdddZddZddZdd Zed d ZdS) FlowControlMixinNcCsF|dkrtj|_n ||_d|_d|_d|_dS)NF)rr'_loop_paused _drain_waiter_connection_lost)rr#rrrrs     zFlowControlMixin.__init__cCs,d|_|jjr(tjd|dS)NTz%r pauses writing)r5r4 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCscd|_|jjr(tjd||j}|dk r_d|_|js_|jddS)NFz%r resumes writing)r5r4r8rr9r6done set_result)rwaiterrrrresume_writings     zFlowControlMixin.resume_writingcCsud|_|jsdS|j}|dkr/dSd|_|jrHdS|dkrd|jdn |j|dS)NT)r7r5r6r;r< set_exception)rexcr=rrrconnection_losts       z FlowControlMixin.connection_lostccsP|jrtd|js"dS|j}|jj}||_|EdHdS)NzConnection lost)r7ConnectionResetErrorr5r6r4 create_future)rr=rrr _drain_helpers     zFlowControlMixin._drain_helper) rrr rr:r>rArrDrrrrr3s   r3cs^eZdZddfddZddZfddZdd Zd d ZS) rNcs;tjd|||_d|_||_d|_dS)Nr#F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr0r#)rrrrs    zStreamReaderProtocol.__init__cCs|jj||jddk |_|jdk rt|||j|j|_|j|j|j}tj |r|jj |dS)NZ sslcontext) rE set_transportget_extra_inforHrGrr4rFr Z iscoroutineZ create_task)rr-resrrrconnection_mades   z$StreamReaderProtocol.connection_madecsa|jdk r;|dkr+|jjn|jj|tj|d|_d|_dS)N)rEfeed_eofr?rrArF)rr@)rrrrAs  z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rE feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rErMrH)rrrr eof_receiveds  z!StreamReaderProtocol.eof_received)rrr rrLrArPrQrr)rrrs   c@seZdZddZddZeddZddZd d Zd d Z d dZ ddZ dddZ e ddZdS)rcCs(||_||_||_||_dS)N) _transport _protocol_readerr4)rr-r%r,r#rrrrs   zStreamWriter.__init__cCsM|jjd|jg}|jdk r<|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrRrTappendjoin)rinforrr__repr__szStreamWriter.__repr__cCs|jS)N)rR)rrrrr-!szStreamWriter.transportcCs|jj|dS)N)rRwrite)rrOrrrrZ%szStreamWriter.writecCs|jj|dS)N)rR writelines)rrOrrrr[(szStreamWriter.writelinescCs |jjS)N)rR write_eof)rrrrr\+szStreamWriter.write_eofcCs |jjS)N)rR can_write_eof)rrrrr].szStreamWriter.can_write_eofcCs |jjS)N)rRclose)rrrrr^1szStreamWriter.closeNcCs|jj||S)N)rRrJ)rnamedefaultrrrrJ4szStreamWriter.get_extra_infoccsi|jdk r0|jj}|dk r0||jdk rS|jjrSdV|jjEdHdS)N)rT exceptionrRZ is_closingrSrD)rr@rrrdrain7s  zStreamWriter.drain)rrr rrYpropertyr-rZr[r\r]r^rJrrbrrrrr s       c@s0eZdZedddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZedddZed'ddZed d!Zejred"d#Zed$d%Zejr,d&d#ZdS)(rNcCs|dkrtd||_|dkr?tj|_n ||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr'r4 bytearray_buffer_eof_waiter _exceptionrRr5)rr$r#rrrrRs          zStreamReader.__init__cCsdg}|jr,|jdt|j|jrB|jd|jtkre|jd|j|jr|jd|j|jr|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rU) rgrVrrhre_DEFAULT_LIMITrirjrRr5rW)rrXrrrrYes          zStreamReader.__repr__cCs|jS)N)rj)rrrrrawszStreamReader.exceptioncCsD||_|j}|dk r@d|_|js@|j|dS)N)rjri cancelledr?)rr@r=rrrr?zs      zStreamReader.set_exceptioncCs;|j}|dk r7d|_|js7|jddS)N)rirmr<)rr=rrr_wakeup_waiters     zStreamReader._wakeup_waitercCs ||_dS)N)rR)rr-rrrrIszStreamReader.set_transportcCs;|jr7t|j|jkr7d|_|jjdS)NF)r5rrgrerRresume_reading)rrrr_maybe_resume_transports! z$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rhrn)rrrrrMs zStreamReader.feed_eofcCs|jo|j S)N)rhrg)rrrrat_eofszStreamReader.at_eofc Cs|s dS|jj||j|jdk r|j rt|jd|jkry|jjWntk rd|_Yn Xd|_dS)NrT) rgextendrnrRr5rreZ pause_readingNotImplementedError)rrOrrrrNs   zStreamReader.feed_datac csq|jdk rtd||jr>d|_|jj|jj|_z|jEdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming dataF)ri RuntimeErrorr5rRror4rC)r func_namerrr_wait_for_datas     zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rX}z |jSWYdd}~Xntk r}za|jj||jr|jd|j|=n |jj|j t |j dWYdd}~XnX|S)Ns r) r readuntilrrrrg startswithr!clearrprdargs)rsepseplenlineerrrreadlines   &zStreamReader.readlines ccsYt|}|dkr$td|jdk r<|jd}xt|j}|||kr|jj||}|dkrP|d|}||jkrtd||jrt|j}|jj t |d|j dEdHqEW||jkrtd||jd||}|jd||=|j t|S)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitrwz2Separator is found, but chunk is longer than limit) rrdrjrgfindrerrhbytesryrrvrp)rZ separatorr|offsetbuflenZisepchunkrrrrws:          zStreamReader.readuntilr ccs|jdk r|j|dkr(dS|dkryg}x/|j|jEdH}|s[P|j|q=Wdj|S|j r|j r|jdEdHt|jd|}|jd|=|j |S)Nrread) rjrrerVrWrgrhrvrrp)rnZblocksblockrOrrrrJs$     zStreamReader.readccs |dkrtd|jdk r0|j|dkr@dSx_t|j|kr|jrt|j}|jjt|||jdEdHqCWt|j|krt|j}|jjn)t|jd|}|jd|=|j |S)Nrz*readexactly size can not be less than zeror readexactly) rdrjrrgrhrryrrvrp)rrZ incompleterOrrrr}s&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs'|jEdH}|dkr#t|S)Nr)rStopAsyncIteration)rvalrrr __anext__s zStreamReader.__anext__cCs|S)Nr)rrrrrsr)rrr rlrrYrar?rnrIrprMrqrNrrvrrwrrrZPY35rrZPY352rrrrrPs,          [2*  i)__all__sockethasattrrrr rrrrlogrrlEOFErrorr Exceptionrrrr r ZProtocolr3rrrrrrrs@      " B3GPK!(>>&__pycache__/locks.cpython-35.opt-1.pycnu[ Yf:@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s:eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr2/opt/alt/python35/lib64/python3.5/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gs"z|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s   r c@sseZdZddZddZeddZejroddZ ed d Z ed d Z d S)_ContextManagerMixincCstddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs|jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s     rcspeZdZdZddddZfddZdd Zed d Zd d Z ddZ S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... loopNcCsCtj|_d|_|dk r0||_ntj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs    z Lock.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r3tdd|jDr3d|_dS|jj}|jj|zLy|EdHd|_dSWn+tjk r|js|jYnXWd|jj |XdS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendr CancelledError_wake_up_firstremove)rfutrrrrs&      z Lock.acquirecCs/|jrd|_|jn tddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r>r)rrrrrs   z Lock.releasecCs2x+|jD] }|js |jdPq WdS)z-Wake up the first waiter who isn't cancelled.TN)r(done set_result)rr@rrrr>s  zLock._wake_up_first) rrrrrr0r,r rrr>rr)r5rrYs 4  cspeZdZdZddddZfddZdd Zd d Zd d Ze ddZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. r%NcCsCtj|_d|_|dk r0||_ntj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs    zEvent.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rCr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rC)rrrris_setsz Event.is_setcCsC|js?d|_x*|jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rCr(rArB)rr@rrrrDs    z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rC)rrrrclearsz Event.clearc csU|jr dS|jj}|jj|z|EdHdSWd|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rCr*r;r(r<r?)rr@rrrwaits  z Event.wait) rrrrrr0rErDrFr rGrr)r5rrs   cs|eZdZdZdddddZfddZedd Zed d Zd d dZ ddZ S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr%cCs|dk r||_ntj|_|dkrHtd|j}n|j|jk rftd||_|j|_|j|_|j|_t j |_ dS)Nr%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrrs        zCondition.__init__csetj}|jr!dnd}|jrKdj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr02s  zCondition.__repr__ccs|jstd|jzH|jj}|jj|z|EdHdSWd|jj|XWdx0y|jEdHPWqpt j k rYqpXqpWXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNT) r,rrr*r;r(r<r?rr r=)rr@rrrrG9s    zCondition.waitccs2|}x"|s-|jEdH|}q W|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rG)rZ predicateresultrrrwait_for[s    zCondition.wait_forrcCsf|jstdd}xA|jD]6}||kr;P|js(|d7}|jdq(WdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rArB)rnidxr@rrrnotifyis     zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rMr2r()rrrr notify_allszCondition.notify_all) rrrrrr0r rGrJrMrNrr)r5rrs "csseZdZdZdddddZfddZd d Zd d Zed dZ ddZ S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rr%NcCs[|dkrtd||_tj|_|dk rH||_ntj|_dS)Nrz$Semaphore initial value must be >= 0)rHrCr&r'r(r*r r+)rvaluer%rrrrs     zSemaphore.__init__csqtj}|jr!dndj|j}|jrWdj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rCr(r2)rr3r4)r5rrr0s   zSemaphore.__repr__cCs@x9|jr;|jj}|js|jddSqWdS)N)r(popleftrArB)rZwaiterrrr _wake_up_nexts    zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rC)rrrrr,szSemaphore.lockedc csx}|jdkr|jj}|jj|y |EdHWq|j|jdkrt|j rt|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rCr*r;r(r<Zcancelr6rQ)rr@rrrrs     zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rCrQ)rrrrrszSemaphore.release) rrrrrr0rQr,r rrrr)r5rrs    csCeZdZdZdddfddZfddZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rr%Ncs#||_tj|d|dS)Nr%) _bound_valuer/r)rrOr%)r5rrrs zBoundedSemaphore.__init__cs/|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rCrRrHr/r)r)r5rrrs zBoundedSemaphore.release)rrrrrrrr)r5rrs )r__all__r&rr r Z coroutinesr r rrrrrrrrrrs .zBuMPK!-FF%__pycache__/test_utils.cpython-35.pycnu[ Yf8@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZyddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrddl%m&Z&nddlm&Z&ddZ'ddZ(dddZ)ddZ*GdddeZ+GdddeZ,Gdd d Z-Gd!d"d"e-e,Z.d#d$d%d&Z/e0ed'rGd(d)d)ej1eZ2Gd*d+d+e2eZ3Gd,d-d-e3Z4Gd.d/d/e-e4Z5d0d1Z6ej7d2d3Z8ej7d#d$d4d5Z9ej7d6d7d8dd#d$d9d:Z:d;d<Z;Gd=d>d>ej<Z=Gd?d@d@ej>Z?dAdBZ@GdCdDdDeAZBdEdFZCGdGdHdHe jDZDej7dIdJZEejFejGejHdKdLZIdMdNZJdS)OzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportwin32) socketpaircCs$tdkrdStjtjSdS)N)sslZ SSLContextZPROTOCOL_SSLv23rr7/opt/alt/python35/lib64/python3.5/asyncio/test_utils.pydummy_ssl_context-s rc CsVtdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)Nrrrrronce5szrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)looprgentrrr run_briefly4s  rcCsttj|}x]|so|dk rP|tj}|dkrPtj|jtjdd|qWdS)NrgMbP?r)timer TimeoutErrorrr Zsleep)rZpredtimeoutZdeadlinerrr run_untilCs    r!cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)rrrrrun_onceMsr#c@s(eZdZddZddZdS)SilentWSGIRequestHandlercCs tjS)N)ioStringIO)selfrrr get_stderrZsz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r'formatargsrrr log_message]sz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r(r+rrrrr$Xs  r$cs4eZdZdZfddZddZS)SilentWSGIServercs/tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r'request client_addr) __class__rrr2eszSilentWSGIServer.get_requestcCsdS)Nr)r'r5client_addressrrr handle_errorjszSilentWSGIServer.handle_error)r,r-r.r4r2r9rr)r7rr/as r/c@seZdZddZdS)SSLWSGIServerMixinc Cstjjtjjtdd}tjj|s]tjjtjjtjdd}tjj|d}tjj|d}tj|d|d|d d }y!|j||||j Wnt k rYnXdS) Nz..ZteststestZ test_asyncioz ssl_key.pemz ssl_cert.pemkeyfilecertfileZ server_sideT) ospathjoindirname__file__isdirrZ wrap_socketZRequestHandlerClassrOSError)r'r5r8herer<r=Zssockrrrfinish_requestps$    z!SSLWSGIServerMixin.finish_requestN)r,r-r.rFrrrrr:ns r:c@seZdZdS) SSLWSGIServerN)r,r-r.rrrrrGs rGuse_sslFc #sdd}|r|n|}||tj|j_tjdfdd}|jz VWdjj|j XdS)NcSs#d}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rIrJr)environZstart_responseZstatusZheadersrrrapps  z_run_test_server..apptargetcsjddS)NZ poll_intervalg?)Z serve_foreverr)httpdrrsz"_run_test_server..) r$Zset_appZserver_addressaddress threadingZThreadstartZshutdownZ server_closer@)rPrH server_clsserver_ssl_clsrLZ server_classZ server_threadr)rNr_run_test_servers        rUZAF_UNIXc@seZdZddZdS)UnixHTTPServercCs&tjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r'rrrrZs zUnixHTTPServer.server_bindN)r,r-r.rZrrrrrVs rVcs4eZdZdZddZfddZS)UnixWSGIServerr0cCstj||jdS)N)rVrZZ setup_environ)r'rrrrZs zUnixWSGIServer.server_bindcs/tj\}}|j|j|dfS)N 127.0.0.1)r\r])r1r2r3r4)r'r5r6)r7rrr2szUnixWSGIServer.get_request)r,r-r.r4rZr2rr)r7rr[s  r[c@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r'r5r8rrrr9sz!SilentUnixWSGIServer.handle_errorN)r,r-r.r9rrrrr^s r^c@seZdZdS)UnixSSLWSGIServerN)r,r-r.rrrrr_s r_c Cs!tj}|jSWdQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_pathsrcccs@t}z |VWdytj|Wntk r:YnXXdS)N)rcr>unlinkrD)r?rrrunix_socket_paths   reccs;t+}td|d|dtdtEdHWdQRXdS)NrPrHrSrT)rerUr^r_)rHr?rrrrun_test_unix_servers rfhostz 127.0.0.1portc cs.td||fd|dtdtEdHdS)NrPrHrSrT)rUr/rG)rgrhrHrrrrun_test_serversricCsni}xHt|D]:}|jdr:|jdr:qtdd||.genFTrg& .>)r1rv_check_on_close_gennext_timeZ_clock_resolution_timersrtZ _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r'r)r7rrrvs              zTestLoop.__init__cCs|jS)N)r)r'rrrr4sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r'advancerrr advance_time7szTestLoop.advance_timec sOtj|jrKy|jjdWntk r>Yn XtddS)NrzTime generator is not finished)r1rrrsend StopIterationAssertionError)r')r7rrr<s   zTestLoop.closecGs tj||||j|.)r rrZthreading_setup_thread_cleanup)r'rrrsetUps zTestCase.setUpcCsU|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r'rrrtearDowns    zTestCase.tearDowncOsGddd}|S)Nc@s(eZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r'rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r'excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r,r-r.rrrrrrEmptyCMs  rr)r'r*rrrrrsubTestszTestCase.subTest) r,r-r.rrrrrrZPY34rrrrrrs    rc cs;tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers   rcCs=tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorpfamilyZ gettimeoutrk)rrprZsockrrrmock_nonblocking_sockets     rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availablerkF)rZpatchrrrrforce_legacy_ssl_supports r)Krr contextlibr%rr>rrrXrr`rQrZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorr]rrr r r r Z coroutinesr logrr;rplatformZ windows_utilsrrrr!r#r$r/r:rGrUhasattrrYrVr[r^r_rccontextmanagerrerfrirsZ BaseSelectorrtZ BaseEventLooprrorrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                           -  PK!_##+__pycache__/coroutines.cpython-35.opt-1.pycnu[ Yf)@s(dddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd l m Z ejd Zejj oeejjd ZyejZejZWnek r dZdZYnXy ejZWnek r9d d ZYnXyddlmZm Z!Wne"k rrdZZ!YnXddZ#e#Z$[#ddZ%GdddZ&ddZe'Z(ddZej)e&fZ*edk re*ef7Z*edk r efe*Z*ddZ+ddZ,dS) coroutineiscoroutinefunction iscoroutineN)compat)events)futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r 7/opt/alt/python35/lib64/python3.5/asyncio/coroutines.py.sr ) Coroutine AwaitablecCsaGddd}dd}d}|}||}t||j||j|fkS) Nc@s@eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__:sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__<sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__>sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r send@s z&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen9s    rcss |EdHdS)Nr )genr r r yield_from_genCsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug8s     r"cCs t|dS)N) CoroWrapper)rr r r debug_wrapperOsr$c@s3eZdZdddZddZddZdd ZerTd d Zn d d Zddd dZ ddZ e ddZ e ddZ e ddZejr#ddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)%r#NcCs[||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr traceback extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r rZs   zCoroWrapper.__init__cCsRt|}|jr>|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__bs    zCoroWrapper.__repr__cCs|S)Nr )rr r r riszCoroWrapper.__iter__cCs|jjdS)N)rr)rr r r rlszCoroWrapper.__next__cGsHtj}|j}|jj|jtkr8|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr r/Zcallerr r r rts    zCoroWrapper.sendcCs|jj|S)N)rr)rr r r r r|scCs|jj|||S)N)rthrow)rtyper r%r r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r8szCoroWrapper.closecCs |jjS)N)rgi_frame)rr r r r9szCoroWrapper.gi_framecCs |jjS)N)r gi_running)rr r r r:szCoroWrapper.gi_runningcCs |jjS)N)rgi_code)rr r r r;szCoroWrapper.gi_codecCs@t|jdd}|dk r<tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr<r r r __await__s  zCoroWrapper.__await__cCs |jjS)N)r gi_yieldfrom)rr r r r@szCoroWrapper.gi_yieldfromcCs |jjS)N)rr<)rr r r r<szCoroWrapper.cr_awaitcCs |jjS)N)r cr_running)rr r r rAszCoroWrapper.cr_runningcCs |jjS)N)rcr_code)rr r r rBszCoroWrapper.cr_codecCs |jjS)N)rcr_frame)rr r r rCszCoroWrapper.cr_framecCst|dd}t|dd}|dkrBt|dd}|dk r|jd krd|}t|df}|rdjtj|}|d7}||j7}tj|dS) Nrr9rCrz%r was never yielded fromr)z6 Coroutine object created at (most recent call last): r+)r*r4joinr% format_listrstripr error)rrr/msgtbr r r __del__s   zCoroWrapper.__del__)rrrrr0rr_YIELD_FROM_BUGrr6r8propertyr9r:r;rZPY35r?r@r<rArBrCrKr r r r r#Ws(        r#cstrStjr(n!tjfddtsstdkrd}qt}n$tjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?s||}tj|s<tj|s<t|trJ|EdH}nKtdk ry |j}Wntk rwYnXt|tr|EdH}|S)N) rZisfutureinspectZ isgenerator isinstancer# _AwaitableABCr?AttributeError)argskwresZ await_meth)r r r r!s   zcoroutine..coroNcs\t||d}|jr.|jd=tdd|_tdd|_|S)Nr rrrr+)r#r)r*rr)rRkwdsw)r!r r r wrappers   zcoroutine..wrapper)_inspect_iscoroutinefunctionrNisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rWr )r!r r rs  !  $ cCs"t|ddtkp!t|S)z6Return True if func is a decorated coroutine function.r^N)r*r^rX)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rO_COROUTINE_TYPES)objr r r r sc "Csft|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk ry |j}Wntk rYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkr#t j |fi}y |j}Wntk rM|j}YnXy |j}Wntk rx|j}YnX|j}d}t|t rtj|j  r|j dk rt j|j }|dk r|\}}|dkrd |||f} qbd |||f} nG|dk rF|j}d |||f} n|j}d |||f} | S) NrBr;rrz{}()Fz {} runningrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr>rArQr:rOr#r rrZ_format_callbackr;rBr9rC co_filenamerNrYZ_get_function_sourcef_linenoco_firstlineno) r!Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenosourcer.r r r r,sl                      r,)-__all__rZrNZopcodeosr'r%typesrDrrrlogr Zopmapr5flagsignore_environmentboolenvirongetr\rr] CoroutineTypeZ_types_CoroutineTyperQrrXcollections.abcrZ _CoroutineABCrrP ImportErrorr"rLr$r#objectr^ GeneratorTyper_rr,r r r r sX                   i :       PK!_HEHE+__pycache__/test_utils.cpython-35.opt-1.pycnu[ Yf8@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZyddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrddl%m&Z&nddlm&Z&ddZ'ddZ(dddZ)ddZ*GdddeZ+GdddeZ,Gdd d Z-Gd!d"d"e-e,Z.d#d$d%d&Z/e0ed'rGd(d)d)ej1eZ2Gd*d+d+e2eZ3Gd,d-d-e3Z4Gd.d/d/e-e4Z5d0d1Z6ej7d2d3Z8ej7d#d$d4d5Z9ej7d6d7d8dd#d$d9d:Z:d;d<Z;Gd=d>d>ej<Z=Gd?d@d@ej>Z?dAdBZ@GdCdDdDeAZBdEdFZCGdGdHdHe jDZDej7dIdJZEejFejGejHdKdLZIdMdNZJdS)OzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportwin32) socketpaircCs$tdkrdStjtjSdS)N)sslZ SSLContextZPROTOCOL_SSLv23rr7/opt/alt/python35/lib64/python3.5/asyncio/test_utils.pydummy_ssl_context-s rc CsVtdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)Nrrrrronce5szrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)looprgentrrr run_briefly4s  rcCsttj|}x]|so|dk rP|tj}|dkrPtj|jtjdd|qWdS)NrgMbP?r)timer TimeoutErrorrr Zsleep)rZpredtimeoutZdeadlinerrr run_untilCs    r!cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)rrrrrun_onceMsr#c@s(eZdZddZddZdS)SilentWSGIRequestHandlercCs tjS)N)ioStringIO)selfrrr get_stderrZsz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r'formatargsrrr log_message]sz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r(r+rrrrr$Xs  r$cs4eZdZdZfddZddZS)SilentWSGIServercs/tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r'request client_addr) __class__rrr2eszSilentWSGIServer.get_requestcCsdS)Nr)r'r5client_addressrrr handle_errorjszSilentWSGIServer.handle_error)r,r-r.r4r2r9rr)r7rr/as r/c@seZdZddZdS)SSLWSGIServerMixinc Cstjjtjjtdd}tjj|s]tjjtjjtjdd}tjj|d}tjj|d}tj|d|d|d d }y!|j||||j Wnt k rYnXdS) Nz..ZteststestZ test_asyncioz ssl_key.pemz ssl_cert.pemkeyfilecertfileZ server_sideT) ospathjoindirname__file__isdirrZ wrap_socketZRequestHandlerClassrOSError)r'r5r8herer<r=Zssockrrrfinish_requestps$    z!SSLWSGIServerMixin.finish_requestN)r,r-r.rFrrrrr:ns r:c@seZdZdS) SSLWSGIServerN)r,r-r.rrrrrGs rGuse_sslFc #sdd}|r|n|}||tj|j_tjdfdd}|jz VWdjj|j XdS)NcSs#d}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rIrJr)environZstart_responseZstatusZheadersrrrapps  z_run_test_server..apptargetcsjddS)NZ poll_intervalg?)Z serve_foreverr)httpdrrsz"_run_test_server..) r$Zset_appZserver_addressaddress threadingZThreadstartZshutdownZ server_closer@)rPrH server_clsserver_ssl_clsrLZ server_classZ server_threadr)rNr_run_test_servers        rUZAF_UNIXc@seZdZddZdS)UnixHTTPServercCs&tjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r'rrrrZs zUnixHTTPServer.server_bindN)r,r-r.rZrrrrrVs rVcs4eZdZdZddZfddZS)UnixWSGIServerr0cCstj||jdS)N)rVrZZ setup_environ)r'rrrrZs zUnixWSGIServer.server_bindcs/tj\}}|j|j|dfS)N 127.0.0.1)r\r])r1r2r3r4)r'r5r6)r7rrr2szUnixWSGIServer.get_request)r,r-r.r4rZr2rr)r7rr[s  r[c@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r'r5r8rrrr9sz!SilentUnixWSGIServer.handle_errorN)r,r-r.r9rrrrr^s r^c@seZdZdS)UnixSSLWSGIServerN)r,r-r.rrrrr_s r_c Cs!tj}|jSWdQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_pathsrcccs@t}z |VWdytj|Wntk r:YnXXdS)N)rcr>unlinkrD)r?rrrunix_socket_paths   reccs;t+}td|d|dtdtEdHWdQRXdS)NrPrHrSrT)rerUr^r_)rHr?rrrrun_test_unix_servers rfhostz 127.0.0.1portc cs.td||fd|dtdtEdHdS)NrPrHrSrT)rUr/rG)rgrhrHrrrrun_test_serversricCsni}xHt|D]:}|jdr:|jdr:qtdd||.genFTrg& .>)r1rv_check_on_close_gennext_timeZ_clock_resolution_timersrtZ _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r'r)r7rrrvs              zTestLoop.__init__cCs|jS)N)r)r'rrrr4sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r'advancerrr advance_time7szTestLoop.advance_timec sOtj|jrKy|jjdWntk r>Yn XtddS)NrzTime generator is not finished)r1rrrsend StopIterationAssertionError)r')r7rrr<s   zTestLoop.closecGs tj||||j|.)r rrZthreading_setup_thread_cleanup)r'rrrsetUps zTestCase.setUpcCsU|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r'rrrtearDowns    zTestCase.tearDowncOsGddd}|S)Nc@s(eZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r'rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r'excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r,r-r.rrrrrrEmptyCMs  rr)r'r*rrrrrsubTestszTestCase.subTest) r,r-r.rrrrrrZPY34rrrrrrs    rc cs;tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers   rcCs=tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorpfamilyZ gettimeoutrk)rrprZsockrrrmock_nonblocking_sockets     rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availablerkF)rZpatchrrrrforce_legacy_ssl_supports r)Krr contextlibr%rr>rrrXrr`rQrZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorr]rrr r r r Z coroutinesr logrr;rplatformZ windows_utilsrrrr!r#r$r/r:rGrUhasattrrYrVr[r^r_rccontextmanagerrerfrirsZ BaseSelectorrtZ BaseEventLooprrorrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                           -  PK!̔VV/__pycache__/windows_events.cpython-35.opt-2.pycnu[ ].l@sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZd dddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdddeZ Gd d!d!e j!Z"Gd"dde j#Z$Gd#ddZ%Gd$d%d%ej&Z'e"Z(Gd&d'd'ej)Z*e*Z+dS)(N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cs|eZdZddfddZfddZddZfd d Zfd d Zfd dZS)_OverlappedFutureloopNcs3tjd||jr&|jd=||_dS)Nrr)super__init___source_traceback_ov)selfovr) __class__3/opt/alt/python35/lib64/python3.5/windows_events.pyr-s  z_OverlappedFuture.__init__csZtj}|jdk rV|jjr0dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s  z_OverlappedFuture._repr_infocCs|jdkrdSy|jjWnctk r}zCddd|d|i}|jrg|j|d<|jj|WYdd}~XnXd|_dS)Nmessagez&Cancelling an overlapped future failed exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s   #z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Js z_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rsz_OverlappedFuture.set_result) __name__ __module__ __qualname__rrr-r'r.r/rr)rrr's  rcseZdZddfddZddZfddZd d Zd d Zfd dZfddZ fddZ S)_BaseWaitHandleFuturerNcsNtjd||jr&|jd=||_||_||_d|_dS)NrrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZs     z_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr5Z WAIT_OBJECT_0)rrrr_pollhsz_BaseWaitHandleFuture._pollcs~tj}|jd|j|jdk rW|jrDdnd}|j||jdk rz|jd|j|S)Nz handle=%#xsignaledZwaitingzwait_handle=%#x)rrappendr5r;r6)rr!r")rrrrms z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|Wnytk r}zY|jtjkrddd|d|i}|jr|j|d<|jj |dSWYdd}~XnX|j ddS)NFr#z$Failed to unregister the wait handler$r%r&) r7r6r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r?)rr9r+r,rrr_unregister_wait|s"       z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rBrr')r)rrrr's z_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rBrr.)rr$)rrrr.s z#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rBrr/)rr0)rrrr/s z _BaseWaitHandleFuture.set_result) r1r2r3rr;rr?rBr'r.r/rr)rrr4Ws    r4csFeZdZddfddZddZfddZS) _WaitCancelFuturerNcs)tj|||d|d|_dS)Nr)rr_done_callback)rreventr9r)rrrrsz_WaitCancelFuture.__init__cCstddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs3tt|j|jdk r/|j|dS)N)rrC_schedule_callbacksrD)r)rrrrGsz%_WaitCancelFuture._schedule_callbacks)r1r2r3rr'rGrr)rrrCs  rCcsFeZdZddfddZfddZddZS) _WaitHandleFuturerNcsVtj|||d|||_d|_tjdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr8r9proactorr)rrrrs   z_WaitHandleFuture.__init__csa|jdk r1tj|jd|_d|_|jj|jd|_tj|dS)N) rJr: CloseHandlerKrI _unregisterrrr?)rr>)rrrr?s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnytk r}zY|jtjkrddd|d|i}|jr|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFr#z$Failed to unregister the wait handler$r%r&)r7r6r ZUnregisterWaitExrJr(r@rArr)r*rI _wait_cancelr?rK)rr9r+r,rrrrBs$       z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBrr)rrrHs rHc@sReZdZddZddZddZddZd d ZeZd S) PipeServercCs@||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs    zPipeServer.__init__cCs |j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Cs|jrdStjtjB}|r3|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr:ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr BUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs     zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsu|jdk r%|jjd|_|jdk rqx|jD]}|jq>Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrbrrrrcs    zPipeServer.closeN) r1r2r3rrYrWrZrc__del__rrrrrPs     rPc@seZdZddZdS)_WindowsSelectorEventLoopcCs tjS)N)r socketpair)rrrr _socketpair&sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3rhrrrrrf#s rfcsjeZdZdfddZddZeddZedd Zedd d ZS) rNcs)|dkrt}tj|dS)N)rrr)rrL)rrrr-s  zProactorEventLoop.__init__cCs tjS)N)r rg)rrrrrh2szProactorEventLoop._socketpairccsN|jj|}|EdH}|}|j||dd|i}||fS)Nextraaddr)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr frbprotocoltransrrrcreate_pipe_connection5s   z(ProactorEventLoop.create_pipe_connectioncsAtdfddjgS)Ncsbd}y|rj|j}jj|jrE|jdS}j||ddij}|dkrdSjj|}Wnt k r#}zh|r|j d krj ddd|d|i|jnj rt jd|d d WYdd}~Xn;tjk rG|rC|jYnX|_|jdS) Nrirjrr#zPipe accept failedr$rbzAccept pipe failed on pipe %rexc_infoTr)r0rTdiscardrZrcrlrYrI accept_piper(filenor*Z_debugr warningrCancelledErrorrVadd_done_callback)rnrbror+)r loop_accept_pipermrserverrrryBs<           z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)rPZ call_soon)rrmr r)r ryrmrrzrstart_serving_pipe>s !( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||d| d|| } y | EdHWn+tk rv} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)Nwaiterri) create_future_WindowsSubprocessTransport Exceptionrc_wait)rroargsshellstdinstdoutstderrbufsizerikwargsr|Ztranspr+errrrr_make_subprocess_transportms      z,ProactorEventLoop._make_subprocess_transport) r1r2r3rrhr rqr{rrr)rrr*s   /c@s0eZdZdddZddZddZdd d Zd d Zd ddZd ddZ ddZ ddZ ddZ e ddZdddZddZddZd d!Zd"d#Zd$d%Zd&d'Zdd(d)Zd*d+Zd,d-Zd.d/ZdS)0rlcCsdd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr\_iocp_cacherRrSr7 _unregistered_stopped_serving)rZ concurrencyrrrrs    zIocpProactor.__init__cCs)d|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs,|js|j||j}g|_|S)N)rr;)rtimeoutrXrrrselects     zIocpProactor.selectcCs |jj}|j||S)N)r)r}r/)rvaluer>rrr_results zIocpProactor._resultrc Cs|j|tjt}yHt|tjrM|j|j||n|j|j|Wnt k r|j dSYnXdd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N) getresultr(r@r ERROR_NETNAME_DELETEDConnectionResetErrorr)rpkeyrr+rrr finish_recvs z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr\ isinstancesocketZWSARecvruZReadFileBrokenPipeErrorr _register)rconnnbytesr`rrrrrrecvs   zIocpProactor.recvcCs|j|tjt}t|tjrJ|j|j||n|j|j|dd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N)rr(r@r rrr)rprrr+rrr finish_sends z&IocpProactor.send..finish_send) rr rr\rrZWSASendruZ WriteFiler)rrbufr`rrrrrsends  zIocpProactor.sendcs|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j |d|j |S)Ncs^|jtjdj}jtjtj|j j j fS)Nz@P) rstructpackru setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeout gettimeout getpeername)rprrr)rlistenerrr finish_accepts    z*IocpProactor.accept..finish_acceptc ss6y |EdHWn"tjk r1|jYnXdS)N)rrwrc)r%rrrr accept_coros   z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyr rr\ZAcceptExrur rrZ ensure_futurer))rrrrrr%coror)rrraccepts   zIocpProactor.acceptcs|jytjjjWnStk r}z3|jtjkrTj ddkrmWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs'|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rprr)rrrfinish_connects   z,IocpProactor.connect..finish_connect)rr Z BindLocalrurr(r@errnoZ WSAEINVAL getsocknamerr\Z ConnectExr)rrr errr)rrconnects zIocpProactor.connectcsi|jtjt}|jj}|rD|jSfdd}|j||S)Ncs|jS)N)r)rprr)rbrrfinish_accept_pipes z4IocpProactor.accept_pipe..finish_accept_pipe)rr rr\ZConnectNamedPiperurr)rrbrZ connectedrr)rbrrts  zIocpProactor.accept_pipeccst}xytj|}PWn:tk rY}z|jtjkrGWYdd}~XnXt|dt}tj |d|j EdHq Wt j |S)Nr) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(r@ZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrsleepr)r r])rr delayr8r+rrrrkszIocpProactor.connect_pipecCs|j||dS)NF)_wait_for_handle)rr8rrrrwait_for_handle*szIocpProactor.wait_for_handlecCs"|j|dd}||_|S)NT)rrD)rrEZ done_callbackr>rrrrO2s zIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|r|t |||d|j nt ||||d|j j rj d=fdd}|d|f|j|j <S)Ng@@rrcs jS)N)r;)rprr)rnrrfinish_wait_for_handleMsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r:INFINITEmathceilr rr\ZRegisterWaitWithQueuerr rCr)rHrr)rr8rZ _is_cancelmsrr9rr)rnrr9s      zIocpProactor._wait_for_handlecCsB||jkr>|jj|tj|j|jdddS)Nr)r7r^r rrur)robjrrrrYsz IocpProactor._register_with_iocpcCst|d|j}|jr(|jd=|jsy|dd|}Wn2tk r{}z|j|WYdd}~XnX|j|||||f|j|j<|S)Nrrr) rr)rrr(r.r/rr )rrrcallbackrnrrrrrrcs     zIocpProactor._registercCs|jj|dS)N)rr=)rrrrrrNszIocpProactor._unregistercCs tj|}|jd|S)Nr)rr)rrsrrrrs zIocpProactor._get_accept_socketcCs|dkrt}nF|dkr0tdn+tj|d}|tkr[tdxutj|j|}|dkrPd}|\}}}}y"|jj|\}} } } Wnrt k r.|j j r|j j dddd||||fi|dtj fkr'tj|w^YnX| |jkrK|jq^|js^y| ||| } WnBtk r} z"|j| |jj|WYdd} ~ Xq^X|j| |jj|q^Wx'|jD]} |jj| jdqW|jjdS) Nrznegative timeoutg@@ztimeout too bigr#z8GetQueuedCompletionStatus() returned an unexpected eventstatusz)err=%s transferred=%s key=%#x address=%#x)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr:rMrr'doner(r.rr=r/rr rd)rrrrrZ transferredrr rnrrrrrrrrr;sJ      "      # zIocpProactor._pollcCs|jj|dS)N)rr^)rrrrr _stop_servingszIocpProactor._stop_servingcCs7xt|jjD]\}\}}}}|jr=qt|trOqy|jWqtk r}zR|jdk rddd|d|i}|j r|j |d<|jj |WYdd}~XqXqWx)|jr|j dst j dqWg|_|jdk r3tj|jd|_dS)Nr#zCancelling a future failedr$r%r&rz"taking long time to close proactor)listritems cancelledrrCr'r(r)rr*r;r debugrrr:rM)rr r>rrrr+r,rrrrcs,.    '  zIocpProactor.closecCs|jdS)N)rc)rrrrreszIocpProactor.__del__)r1r2r3rrrrrrrrrrtr rkrrOrrrrNrr;rrcrerrrrrs,          7  c@seZdZddZdS)r~c swtj|d|d|d|d|d||_fdd}jjjtjj} | j|dS)Nrrrrrcs jj}j|dS)N)_procpollZ_process_exited)rn returncode)rrrrsz4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr5rx) rrrrrrrrrrnr)rr_starts !z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr~s r~c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrs r),r:rrrrrRrrrrrrr r Z coroutinesr logr __all__r\rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrFuturerr4rCrHobjectrPZBaseSelectorEventLooprfZBaseProactorEventLooprrZBaseSubprocessTransportr~r ZBaseDefaultEventLoopPolicyrrrrrrsH        0J4;]jPK!(>> __pycache__/locks.cpython-35.pycnu[ Yf:@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s:eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr2/opt/alt/python35/lib64/python3.5/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gs"z|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s   r c@sseZdZddZddZeddZejroddZ ed d Z ed d Z d S)_ContextManagerMixincCstddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs|jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s     rcspeZdZdZddddZfddZdd Zed d Zd d Z ddZ S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... loopNcCsCtj|_d|_|dk r0||_ntj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs    z Lock.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r3tdd|jDr3d|_dS|jj}|jj|zLy|EdHd|_dSWn+tjk r|js|jYnXWd|jj |XdS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendr CancelledError_wake_up_firstremove)rfutrrrrs&      z Lock.acquirecCs/|jrd|_|jn tddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r>r)rrrrrs   z Lock.releasecCs2x+|jD] }|js |jdPq WdS)z-Wake up the first waiter who isn't cancelled.TN)r(done set_result)rr@rrrr>s  zLock._wake_up_first) rrrrrr0r,r rrr>rr)r5rrYs 4  cspeZdZdZddddZfddZdd Zd d Zd d Ze ddZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. r%NcCsCtj|_d|_|dk r0||_ntj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs    zEvent.__init__csbtj}|jrdnd}|jrHdj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rCr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rC)rrrris_setsz Event.is_setcCsC|js?d|_x*|jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rCr(rArB)rr@rrrrDs    z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rC)rrrrclearsz Event.clearc csU|jr dS|jj}|jj|z|EdHdSWd|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rCr*r;r(r<r?)rr@rrrwaits  z Event.wait) rrrrrr0rErDrFr rGrr)r5rrs   cs|eZdZdZdddddZfddZedd Zed d Zd d dZ ddZ S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr%cCs|dk r||_ntj|_|dkrHtd|j}n|j|jk rftd||_|j|_|j|_|j|_t j |_ dS)Nr%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrrs        zCondition.__init__csetj}|jr!dnd}|jrKdj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr02s  zCondition.__repr__ccs|jstd|jzH|jj}|jj|z|EdHdSWd|jj|XWdx0y|jEdHPWqpt j k rYqpXqpWXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNT) r,rrr*r;r(r<r?rr r=)rr@rrrrG9s    zCondition.waitccs2|}x"|s-|jEdH|}q W|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rG)rZ predicateresultrrrwait_for[s    zCondition.wait_forrcCsf|jstdd}xA|jD]6}||kr;P|js(|d7}|jdq(WdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rArB)rnidxr@rrrnotifyis     zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rMr2r()rrrr notify_allszCondition.notify_all) rrrrrr0r rGrJrMrNrr)r5rrs "csseZdZdZdddddZfddZd d Zd d Zed dZ ddZ S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rr%NcCs[|dkrtd||_tj|_|dk rH||_ntj|_dS)Nrz$Semaphore initial value must be >= 0)rHrCr&r'r(r*r r+)rvaluer%rrrrs     zSemaphore.__init__csqtj}|jr!dndj|j}|jrWdj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rCr(r2)rr3r4)r5rrr0s   zSemaphore.__repr__cCs@x9|jr;|jj}|js|jddSqWdS)N)r(popleftrArB)rZwaiterrrr _wake_up_nexts    zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rC)rrrrr,szSemaphore.lockedc csx}|jdkr|jj}|jj|y |EdHWq|j|jdkrt|j rt|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rCr*r;r(r<Zcancelr6rQ)rr@rrrrs     zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rCrQ)rrrrrszSemaphore.release) rrrrrr0rQr,r rrrr)r5rrs    csCeZdZdZdddfddZfddZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rr%Ncs#||_tj|d|dS)Nr%) _bound_valuer/r)rrOr%)r5rrrs zBoundedSemaphore.__init__cs/|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rCrRrHr/r)r)r5rrrs zBoundedSemaphore.release)rrrrrrrr)r5rrs )r__all__r&rr r Z coroutinesr r rrrrrrrrrrs .zBuMPK!2q##%__pycache__/coroutines.cpython-35.pycnu[ Yf)@s(dddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd l m Z ejd Zejj oeejjd ZyejZejZWnek r dZdZYnXy ejZWnek r9d d ZYnXyddlmZm Z!Wne"k rrdZZ!YnXddZ#e#Z$[#ddZ%GdddZ&ddZe'Z(ddZej)e&fZ*edk re*ef7Z*edk r efe*Z*ddZ+ddZ,dS) coroutineiscoroutinefunction iscoroutineN)compat)events)futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r 7/opt/alt/python35/lib64/python3.5/asyncio/coroutines.py.sr ) Coroutine AwaitablecCsaGddd}dd}d}|}||}t||j||j|fkS) Nc@s@eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__:sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__<sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__>sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r send@s z&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen9s    rcss |EdHdS)Nr )genr r r yield_from_genCsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug8s     r"cCs t|dS)N) CoroWrapper)rr r r debug_wrapperOsr$c@s3eZdZdddZddZddZdd ZerTd d Zn d d Zddd dZ ddZ e ddZ e ddZ e ddZejr#ddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)%r#NcCstj|s*tj|s*t|||_||_tjtj d|_ t |dd|_ t |dd|_ dS)Nrrr)inspect isgeneratorrAssertionErrorrr traceback extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r rZs *  zCoroWrapper.__init__cCsRt|}|jr>|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner, __class__r)r coro_reprframer r r __repr__bs    zCoroWrapper.__repr__cCs|S)Nr )rr r r riszCoroWrapper.__iter__cCs|jjdS)N)rr)rr r r rlszCoroWrapper.__next__cGs]tj}|j}|jdks*t|jj|jtkrM|d}|jj |S)Nr) r*r+f_backf_lastir'f_codeco_code _YIELD_FROMrr)rr r2Zcallerr r r rts    zCoroWrapper.sendcCs|jj|S)N)rr)rr r r r r|scCs|jj|||S)N)rthrow)rtyper r(r r r r9szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r;szCoroWrapper.closecCs |jjS)N)rgi_frame)rr r r r<szCoroWrapper.gi_framecCs |jjS)N)r gi_running)rr r r r=szCoroWrapper.gi_runningcCs |jjS)N)rgi_code)rr r r r>szCoroWrapper.gi_codecCs@t|jdd}|dk r<tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r-r RuntimeErrorformat)rr?r r r __await__s  zCoroWrapper.__await__cCs |jjS)N)r gi_yieldfrom)rr r r rCszCoroWrapper.gi_yieldfromcCs |jjS)N)rr?)rr r r r?szCoroWrapper.cr_awaitcCs |jjS)N)r cr_running)rr r r rDszCoroWrapper.cr_runningcCs |jjS)N)rcr_code)rr r r rEszCoroWrapper.cr_codecCs |jjS)N)rcr_frame)rr r r rFszCoroWrapper.cr_framecCst|dd}t|dd}|dkrBt|dd}|dk r|jd krd|}t|df}|rdjtj|}|d7}||j7}tj|dS) Nrr<rFrz%r was never yielded fromr,z6 Coroutine object created at (most recent call last): r.)r-r5joinr( format_listrstripr error)rrr2msgtbr r r __del__s   zCoroWrapper.__del__)rrrrr3rr_YIELD_FROM_BUGrr9r;propertyr<r=r>rZPY35rBrCr?rDrErFrNr r r r r#Ws(        r#cstrStjr(n!tjfddtsstdkrd}qt}n$tjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?s||}tj|s<tj|s<t|trJ|EdH}nKtdk ry |j}Wntk rwYnXt|tr|EdH}|S)N) rZisfuturer%r& isinstancer# _AwaitableABCrBAttributeError)argskwresZ await_meth)r r r r!s   zcoroutine..coroNcs\t||d}|jr.|jd=tdd|_tdd|_|S)Nr rrrr.)r#r,r-rr)rTkwdsw)r!r r r wrappers   zcoroutine..wrapper)_inspect_iscoroutinefunctionr%isgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rYr )r!r r rs  !  $ cCs"t|ddtkp!t|S)z6Return True if func is a decorated coroutine function.r`N)r-r`rZ)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rQ_COROUTINE_TYPES)objr r r r sc "Csxt|stt|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk ry |j }Wntk rYnXYnX|rdj|S|Sd}t |t r|j }|j }|dk rdj|}n|}|dkr5tj|fi}y |j}Wntk r_|j}YnXy |j}Wntk r|j}YnX|j}d}t |t r-tj|j  r-|j dk r-tj|j }|dk r|\}}|dkrd |||f} qtd |||f} nG|dk rX|j}d |||f} n|j}d |||f} | S) NrEr>rrz{}()Fz {} runningrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)rr'hasattrr-r:rrArDrSr=rQr#r rrZ_format_callbackr>rEr<rF co_filenamer%r[Z_get_function_sourcef_linenoco_firstlineno) r!Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenosourcer1r r r r/sn                      r/)-__all__r\r%Zopcodeosr*r(typesrGrrrlogr Zopmapr8flagsignore_environmentboolenvirongetr^rr_ CoroutineTypeZ_types_CoroutineTyperSrrZcollections.abcrZ _CoroutineABCrrR ImportErrorr"rOr$r#objectr` GeneratorTyperarr/r r r r sX                   i :       PK! )r__name__rappendrrjoin)rinforrr__repr__sz!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk retjd|jd|j|_|jj||jj d|jd}|dk rtjd|jd|j|_ |j j||jj d|jd}|dk rtj |d|ddd|j|_ dS)Nrrr rprotocolreader) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&     z(SubprocessStreamProtocol.connection_madecCsS|dkr|j}n|dkr0|j}nd}|dk rO|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@s     z+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr<|j}|dk r+|j|j|dS|dkrT|j}n|dkrl|j}nd}|dkr|dkr|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$             z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedas z'SubprocessStreamProtocol.process_exitedcCs8t|jdkr4|jr4|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/rr)rrr s    r c@seZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCsR||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrls      zProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr<szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr>szProcess.terminatecCs|jjdS)N)rkill)rrrrr?sz Process.killccs|jj}|jj||r>tjd|t|y|jjEdHWnDtt fk r}z|rtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrBr0rrr _feed_stdins &zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr*|j}n|dks<t|j}|jjr|dkrfdnd}tjd|||j EdH}|jjr|dkrdnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rAssertionErrorrr&r@r rBreadr-)rr*r(streamnameoutputrrr _read_streams    zProcess._read_streamNccs|dk r|j|}n |j}|jdk rK|jd}n |j}|jdk rx|jd}n |j}tj|||d|jEdH\}}}|jEdH||fS)Nrr!r ) rFrGrrMrrZgatherr&r;)rrErrrrrr communicates    zProcess.communicate)rr5r6rr propertyr:r r;r<r>r?rFrGrMrNrrrrr8ks     r8c +sodkrtjfdd}j||d|d|d||EdH\}} t|| S)NcstddS)Nrr )r r)rr rrs z)create_subprocess_shell..rrr)rget_event_loopZsubprocess_shellr8) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs  rrrr rc /srdkrtjfdd}j|||d|d|d||EdH\} } t| | S)NcstddS)Nrr )r r)rr rrrPs z(create_subprocess_exec..rrr)rrQZsubprocess_execr8) Zprogramrrrr rargsrSrTr(r"r)rr rrs    )__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r8Z_DEFAULT_LIMITrrrrrrs(      X]    PK! '_&_&0__pycache__/base_subprocess.cpython-35.opt-2.pycnu[ ]]#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercsEeZdZddfddZddZddZdd Zd d Zd d ZddZ e j rddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZS)0BaseSubprocessTransportNc  stj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkrd|j d<|tjkrd|j d<|tjkrd|j d ) r/__name__rappendrrrgetpipejoin)r)infor r rr0r0r1__repr__9s,      z BaseSubprocessTransport.__repr__cKs tdS)N)NotImplementedError)r)r r r r rrr.r0r0r1r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r0r0r1 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r0r0r1 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r0r0r1 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x3|jjD]"}|dkr;q&|jjq&W|jdk r|jdkr|jjdkr|jj rt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr8r!rrpollrr#rwarningkillProcessLookupError)r)protor0r0r1r!bs     zBaseSubprocessTransport.closecCs+|js'tjd|t|jdS)Nzunclosed transport %r)rwarningswarnResourceWarningr!)r)r0r0r1__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r0r0r1get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r0r0r1get_returncodesz&BaseSubprocessTransport.get_returncodecCs%||jkr|j|jSdSdS)N)rr8)r)fdr0r0r1get_pipe_transportsz*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rrD)r)r0r0r1 _check_procsz#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rNr send_signal)r)signalr0r0r1rOs z#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rNr terminate)r)r0r0r1rQs z!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rNrrC)r)r0r0r1rCs zBaseSubprocessTransport.killc #sy7j}j}|jdk r]|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x'j D]\}}|j||q Wd_ WnKt k r}z+|dk rr|j rr|j|WYdd}~Xn'X|dk r|j r|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor0)r)r0r1sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor0)r)r0r1rSsrcs tdS)Nr )rTr0)r)r0r1rSsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelled set_exception set_result) r)r,procr*_r8callbackdataexcr0)r)r1r(s6       z&BaseSubprocessTransport._connect_pipescGs?|jdk r(|jj||fn|jj||dS)N)rr6rrU)r)cbr^r0r0r1_callszBaseSubprocessTransport._callcCs'|j|jj|||jdS)N)rarZpipe_connection_lost _try_finish)r)rLr_r0r0r1_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)rarZpipe_data_received)r)rLr^r0r0r1_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|jjr"tjd||||_|jjdkrI||j_|j|jj |j x*|j D]}|j sp|j |qpWd|_ dS)Nz%r exited with return code %r)rr#rr:rr returncoderarZprocess_exitedrbrrXrZ)r)rer,r0r0r1_process_exiteds      z'BaseSubprocessTransport._process_exitedccs>|jdk r|jS|jj}|jj||EdHS)N)rrZ create_futurerr6)r)r,r0r0r1_waits zBaseSubprocessTransport._waitcCsU|jdkrdStdd|jjDrQd|_|j|jddS)Ncss$|]}|dk o|jVqdS)N) disconnected).0pr0r0r1 sz6BaseSubprocessTransport._try_finish..T)rallrr@rra_call_connection_lost)r)r0r0r1rbs   z#BaseSubprocessTransport._try_finishc Cs7z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r_r0r0r1rms   z-BaseSubprocessTransport._call_connection_lost)r5 __module__ __qualname__rr;r r=r>r?r!rZPY34rIrJrKrMrNrOrQrCrr(rarcrdrfrgrbrmr0r0)r/r1r s0 )               %     rc@sXeZdZddZddZddZddZd d Zd d Zd S)rRcCs(||_||_d|_d|_dS)NF)r[rLr8rh)r)r[rLr0r0r1rs   z!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r8)r)Z transportr0r0r1rV sz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r/r5rLr8)r)r0r0r1r;sz!WriteSubprocessPipeProto.__repr__cCs,d|_|jj|j|d|_dS)NT)rhr[rcrL)r)r_r0r0r1rns z(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)r[r pause_writing)r)r0r0r1rqsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)r[rresume_writing)r)r0r0r1rrsz'WriteSubprocessPipeProto.resume_writingN) r5rorprrVr;rnrqrrr0r0r0r1rRs      rRc@seZdZddZdS)rTcCs|jj|j|dS)N)r[rdrL)r)r^r0r0r1 data_received#sz%ReadSubprocessPipeProto.data_receivedN)r5rorprsr0r0r0r1rT s rT)rrrFrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrRZProtocolrTr0r0r0r1s   PK!FZSZS&__pycache__/tasks.cpython-35.opt-1.pycnu[ Yfg @sCdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZGdddejZejjZejjZejjZedddddeddZddZeddddZeddZddddd dZedddd!dZddd"d#Zeed Cs z!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks;s  zTask.all_tasksrcsktjd||jr&|jd=||_d|_d|_|jj|j|j j j |dS)NrrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r!add)selfcoror)r,rrr%Es     z Task.__init__cCsg|jtjkrS|jrSd|ddi}|jrC|j|d<|jj|tjj|dS)Ntaskmessagez%Task was destroyed but it is pending!Zsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr&rZcall_exception_handlerFuture__del__)r.contextrrrr4Ts   z Task.__del__csrtj}|jr"d|dz wait_for=%r)r$ _repr_infor)rZ_format_coroutiner'insertr()r.infor/)r,rrr7_s  zTask._repr_infolimitc Cs g}y|jj}Wntk r6|jj}YnX|dk rxI|dk r|dk ru|dkrkP|d8}|j||j}qFW|jnj|jdk r|jj}xL|dk r|dk r|dkrP|d8}|j|j |j }qW|S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. Nrr) r'cr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)r.r:Zframesftbrrr get_stackms0             zTask.get_stackfilec Cs]g}t}x|jd|D]}|j}|j}|j}|j} ||krr|j|tj|tj |||j } |j ||| | fq"W|j } |st d|d|n7| dk rt d|d|nt d|d|tj|d|| dk rYx3tj| j| D]} t | d|ddq9WdS) anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. r:zNo stack for %rrHNz)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):end)setrGf_linenof_code co_filenameco_namer- linecache checkcachegetline f_globalsr>rAprint traceback print_listformat_exception_onlyr,) r.r:rHextracted_listZcheckedrElinenocofilenamenamelineexcrrr print_stacks0               zTask.print_stackcCsHd|_|jrdS|jdk r;|jjr;dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner(cancelr))r.rrrras   z Task.cancelcs|jr0t|tjs'tj}d|_|j}d|_||jj|j.)risfuturer iscoroutine TypeErrortyperv ValueErrorrrrrorrrK_wait)fsrr}r~r)rrrLs   cGs|js|jddS)N)r`ri)waiterargsrrr_release_waiterls rccs |dkrtj}|dkr-|EdHS|j}|j|t|}tjt|}t|d|}|j|z|y |EdHWn/t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nr)rr create_future call_laterr functoolspartialr rprrdremove_done_callbackrar`rt TimeoutError)futr}rrtimeout_handlecbrrrrqs,             c #s|jd|dk r3|j|tt|fdd}x|D]}|j|qaWz EdHWddk rjXtt}}xD|D]<}|j||jr|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. Ncsd8dksMtksMtkr||j r||jdk r|dk rcjjs|jddS)Nrr)rr cancelled exceptionrar`ri)rE)counterr~rrrr_on_completions      z_wait.._on_completion) rrrlenrprarKrr`r-)rr}r~rrrEr`pendingr)rr~rrrrs&          rc#sLtj|stj|r7tdt|jdk rIn tjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr#|dk r#j||x"ttD]}|Vq6WdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcs"h|]}t|dqS)r)r )rrE)rrrr s zas_completed..r)Queuercs9x(D] }|jjdqWjdS)N)r put_nowaitclear)rE)rr`todorr _on_timeouts  z!as_completed.._on_timeoutcsEs dSj|j| rAdk rAjdS)N)removerra)rE)r`rrrrrs   z$as_completed.._on_completionc3s0jEdH}|dkr&tj|jS)N)rrrrt)rE)r`rr _wait_for_ones  z#as_completed.._wait_for_one)rrrrrrrvrrrKZqueuesrrrprranger)rrr}rrrrE_r)rr`rrrrrs  c csv|dkrdV|S|dkr-tj}|j}|jj|tj||}z |EdHSWd|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrrrrZ_set_result_unless_cancelledra)Zdelayrtrruhrrrrs       cCs&tjdtddt|d|S)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future() stacklevelr6r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_s rcCstj|r:|dk r6||jk r6td|Stj|r|dkratj}|j|}|j r|j d=|St j rt j |rtt|d|StddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurerrz:An asyncio.Future, a coroutine or an awaitable is requiredr#)rrrrrrrrZ create_taskr&rZPY35rrZ isawaitabler _wrap_awaitabler)rrr0rrrr +s     ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrBsrcs:eZdZdZddfddZddZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. rNcs tjd|||_dS)Nr)r$r% _children)r.childrenr)r,rrr%Tsz_GatheringFuture.__init__cCs@|jrdSd}x#|jD]}|jr d}q W|S)NFT)r`rra)r.ZretZchildrrrraXs   z_GatheringFuture.cancel)rvrwrxryr%rarr)r,rrLs rreturn_exceptionsFcs|s;|dkrtj}|jjgSixt|D]}tj|st|d|}|dkr|j}d|_ n9|}|dkr|j}n|j|k rt d||s zgather..rcsjr&|js"|jdS|jrXtj}sj|dSn>|jdk r|j}sj|dSn |j}||<d7krjdS)Nr) r`rrrrdrhrAZ_resultri)irres) nchildren nfinishedouterresultsrrr_done_callbacks&            zgather.._done_callback)rrrrirKrrr rr2rrr enumeraterprr)rrZcoros_or_futuresrrrrrr)rrrrrrrr bs8            csZt|d|}|jr"|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None rcs~jr&|js"|jdS|jr?jn;|j}|dk rgj|nj|jdS)N)rrrarhrirt)innerr^)rrrrs       zshield.._done_callback)r r`rrrp)rrrrr)rrr s    csStjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcshy tjtdWnAtk rc}z!jrNj|WYdd}~XnXdS)Nr)rZ _chain_futurer rkZset_running_or_notify_cancelrh)r^)r/rurrrcallbacks    z*run_coroutine_threadsafe..callback)rrr concurrentrr3Zcall_soon_threadsafe)r/rrr)r/rurrr s   )$ry__all__Zconcurrent.futuresrrrrrPrUrrzrJrrrrrr3rrrrrrrrrrrglobalsrvr rrr r r rrrrsP        0    --8   T5PK!ߌJJ.__pycache__/windows_utils.cpython-35.opt-2.pycnu[ ]@sDddlZejdkr'edddlZddlZddlZddlZddlZddlZddl Z ddl Z dddddgZ d Z ej Z ejZejZeedrejZnejejdd dZd d d dde ddZGdddZGdddejZdS)Nwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Csk|tjkrd}n$|tjkr0d}n td|tjkrWtd|dkrotdtj|||}z|j|df|jd|jdd\}}tj|||}yb|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) Nz 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedFT)socketAF_INETAF_INET6 ValueError SOCK_STREAMbindlisten getsockname setblockingconnectBlockingIOErrorInterruptedErroracceptclose) familytypeprotohostZlsockaddrportZcsockZssock_r2/opt/alt/python35/lib64/python3.5/windows_utils.pyr%s8            duplexF overlappedTbufsizec Cstjddtjttf}|rWtj}tjtj B}||}}ntj }tj }d|}}|tj O}|dr|tj O}|drtj }nd}d} } ytj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fSWn=| dk rftj| | dk rtj| YnXdS)Nprefixz\\.\pipe\python-pipe-%d-%d-rrr"T)tempfilemktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) r!r"r#addressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovrrr rSs@                 c@seZdZddZddZeddZddZd ej d d Z d d Z ddZ ddZ dS)rcCs ||_dS)N)_handle)selfhandlerrr __init__szPipeHandle.__init__cCs9|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r/ __class____name__)r0r1rrr __repr__szPipeHandle.__repr__cCs|jS)N)r/)r0rrr r1szPipeHandle.handlecCs"|jdkrtd|jS)NzI/O operatioon on closed pipe)r/r )r0rrr filenos zPipeHandle.filenor,cCs)|jdk r%||jd|_dS)N)r/)r0r,rrr rs zPipeHandle.closecCs1|jdk r-tjd|t|jdS)Nz unclosed %r)r/warningswarnResourceWarningr)r0rrr __del__szPipeHandle.__del__cCs|S)Nr)r0rrr __enter__szPipeHandle.__enter__cCs|jdS)N)r)r0tvtbrrr __exit__szPipeHandle.__exit__N)r5 __module__ __qualname__r2r6propertyr1r7r+r,rr;r<r@rrrr rs      cs+eZdZdddfddZS)rNc sd}}}d} } } |tkr[tdd dd\} } tj| tj}n|}|tkrtdd \} } tj| d}n|}|tkrtdd \} }tj|d}n|tkr|}n|}zy)tj|d|d|d||Wn>x0| | | fD]}|dk r0t j |q0WYnRX| dk rvt | |_ | dk rt | |_ | dk rt | |_Wd|tkrtj||tkrtj||tkrtj|XdS) Nr"FTr!rstdinstdoutstderr)FT)TF)TF)rrmsvcrtopen_osfhandler'O_RDONLYSTDOUTsuperr2r+r,rrDrErFr)r0argsrDrErFkwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r4rr r2sH              zPopen.__init__)r5rArBr2rr)r4r rs )TT)sysplatform ImportErrorr+ itertoolsrGr'r subprocessr%r8__all__BUFSIZErrJcountr*hasattrrr rrrrrrrr s*              .0,PK!;SrZrZ)__pycache__/windows_events.cpython-35.pycnu[ Yf.l@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cseZdZdZddfddZfddZdd Zfd d Zfd d ZfddZ S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. loopNcs3tjd||jr&|jd=||_dS)Nrr)super__init___source_traceback_ov)selfovr) __class__;/opt/alt/python35/lib64/python3.5/asyncio/windows_events.pyr-s  z_OverlappedFuture.__init__csZtj}|jdk rV|jjr0dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s  z_OverlappedFuture._repr_infocCs|jdkrdSy|jjWnctk r}zCddd|d|i}|jrg|j|d<|jj|WYdd}~XnXd|_dS)Nmessagez&Cancelling an overlapped future failed exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s   #z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Js z_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Nsz_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rsz_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/rr)rrr's  rcseZdZdZddfddZddZfdd Zd d Zd d ZfddZ fddZ fddZ S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.rNcsNtjd||jr&|jd=||_||_||_d|_dS)NrrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZs     z_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr6Z WAIT_OBJECT_0)rrrr_pollhsz_BaseWaitHandleFuture._pollcs~tj}|jd|j|jdk rW|jrDdnd}|j||jdk rz|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr6r<r7)rr!r")rrrrms z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|Wnytk r}zY|jtjkrddd|d|i}|jr|j|d<|jj |dSWYdd}~XnX|j ddS)NFr#z$Failed to unregister the wait handler$r%r&) r8r7r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r?)rr:r+r,rrr_unregister_wait|s"       z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rBrr')r)rrrr's z_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rBrr.)rr$)rrrr.s z#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rBrr/)rr0)rrrr/s z _BaseWaitHandleFuture.set_result) r1r2r3r4rr<rr?rBr'r.r/rr)rrr5Ws    r5csLeZdZdZddfddZddZfdd ZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. rNcs)tj|||d|d|_dS)Nr)rr_done_callback)rreventr:r)rrrrsz_WaitCancelFuture.__init__cCstddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs3tt|j|jdk r/|j|dS)N)rrC_schedule_callbacksrD)r)rrrrGsz%_WaitCancelFuture._schedule_callbacks)r1r2r3r4rr'rGrr)rrrCs  rCcsFeZdZddfddZfddZddZS) _WaitHandleFuturerNcsVtj|||d|||_d|_tjdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr9r:proactorr)rrrrs   z_WaitHandleFuture.__init__csa|jdk r1tj|jd|_d|_|jj|jd|_tj|dS)N) rJr; CloseHandlerKrI _unregisterrrr?)rr>)rrrr?s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnytk r}zY|jtjkrddd|d|i}|jr|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFr#z$Failed to unregister the wait handler$r%r&)r8r7r ZUnregisterWaitExrJr(r@rArr)r*rI _wait_cancelr?rK)rr:r+r,rrrrBs$       z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBrr)rrrHs rHc@sXeZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs@||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs    zPipeServer.__init__cCs |j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Cs|jrdStjtjB}|r3|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr;ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs     zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsu|jdk r%|jjd|_|jdk rqx|jD]}|jq>Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs    zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs     rPc@s"eZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCs tjS)N)r socketpair)rrrr _socketpair&sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre#s recspeZdZdZdfddZddZeddZed d Zedd d Z S) rz2Windows version of proactor event loop using IOCP.Ncs)|dkrt}tj|dS)N)rrr)rrL)rrrr-s  zProactorEventLoop.__init__cCs tjS)N)r rf)rrrrrg2szProactorEventLoop._socketpairccsN|jj|}|EdH}|}|j||dd|i}||fS)Nextraaddr)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection5s   z(ProactorEventLoop.create_pipe_connectioncsAtdfddjgS)Ncsbd}y|rj|j}jj|jrE|jdS}j||ddij}|dkrdSjj|}Wnt k r#}zh|r|j d krj ddd|d|i|jnj rt jd|d d WYdd}~Xn;tjk rG|rC|jYnX|_|jdS) Nrhrirr#zPipe accept failedr$razAccept pipe failed on pipe %rexc_infoTr)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwBs<           z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipe>s !( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||d| d|| } y | EdHWn+tk rv} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)Nwaiterrh) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerhkwargsrzZtranspr+errrrr_make_subprocess_transportms      z,ProactorEventLoop._make_subprocess_transport) r1r2r3r4rrgr rpryrrr)rrr*s   /c@s6eZdZdZdddZddZddZd d d Zd d ZdddZ dddZ ddZ ddZ ddZ eddZd ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd d)d*Zd+d,Zd-d.Zd/d0Zd S)1rz#Proactor implementation using IOCP.lcCsdd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr8 _unregistered_stopped_serving)rZ concurrencyrrrrs    zIocpProactor.__init__cCs)d|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs,|js|j||j}g|_|S)N)rr<)rtimeoutrXrrrselects     zIocpProactor.selectcCs |jj}|j||S)N)r)r{r/)rvaluer>rrr_results zIocpProactor._resultrc Cs|j|tjt}yHt|tjrM|j|j||n|j|j|Wnt k r|j dSYnXdd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N) getresultr(r@r ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs   zIocpProactor.recvcCs|j|tjt}t|tjrJ|j|j||n|j|j|dd}|j |||S)NcSsay|jSWnLtk r\}z,|jtjkrGt|jnWYdd}~XnXdS)N)rr(r@r rrr~)rorrr+rrr finish_sends z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends  zIocpProactor.sendcs|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j |d|j |S)Ncs^|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts    z*IocpProactor.accept..finish_acceptc ss6y |EdHWn"tjk r1|jYnXdS)N)rrurb)r%rrrr accept_coros   z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts   zIocpProactor.acceptcs|jytjjjWnStk r}z3|jtjkrTj ddkrmWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs'|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects   z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(r@errnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects zIocpProactor.connectcsi|jtjt}|jj}|rD|jSfdd}|j||S)Ncs|jS)N)r)rorr)rarrfinish_accept_pipes z4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrss  zIocpProactor.accept_pipeccst}xytj|}PWn:tk rY}z|jtjkrGWYdd}~XnXt|dt}tj |d|j EdHq Wt j |S)Nr) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(r@ZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr9r+rrrrjszIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr9rrrrwait_for_handle*szIocpProactor.wait_for_handlecCs"|j|dd}||_|S)NT)rrD)rrEZ done_callbackr>rrrrO2s zIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|r|t |||d|j nt ||||d|j j rj d=fdd}|d|f|j|j <S)Ng@@rrcs jS)N)r<)rorr)rmrrfinish_wait_for_handleMsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r;INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rCr)rHrr)rr9rZ _is_cancelmsrr:rr)rmrr9s      zIocpProactor._wait_for_handlecCsB||jkr>|jj|tj|j|jdddS)Nr)r8r]r rrtr)robjrrrrYsz IocpProactor._register_with_iocpcCst|d|j}|jr(|jd=|jsy|dd|}Wn2tk r{}z|j|WYdd}~XnX|j|||||f|j|j<|S)Nrrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrcs     zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr=)rrrrrrNszIocpProactor._unregistercCs tj|}|jd|S)Nr)rr)rrsrrrrs zIocpProactor._get_accept_socketcCs|dkrt}nF|dkr0tdn+tj|d}|tkr[tdxutj|j|}|dkrPd}|\}}}}y"|jj|\}} } } Wnrt k r.|j j r|j j dddd||||fi|dtj fkr'tj|w^YnX| |jkrK|jq^|js^y| ||| } WnBtk r} z"|j| |jj|WYdd} ~ Xq^X|j| |jj|q^Wx'|jD]} |jj| jdqW|jjdS) Nrznegative timeoutg@@ztimeout too bigr#z8GetQueuedCompletionStatus() returned an unexpected eventstatusz)err=%s transferred=%s key=%#x address=%#x)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr;rMrr'doner(r.rr=r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr<sJ      "      # zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCs7xt|jjD]\}\}}}}|jr=qt|trOqy|jWqtk r}zR|jdk rddd|d|i}|j r|j |d<|jj |WYdd}~XqXqWx)|jr|j dst j dqWg|_|jdk r3tj|jd|_dS)Nr#zCancelling a future failedr$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrCr'r(r)rr*r<r debugrrr;rM)rr r>rrrr+r,rrrrbs,.    '  zIocpProactor.closecCs|jdS)N)rb)rrrrrdszIocpProactor.__del__)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr<rrbrdrrrrrs.          7  c@seZdZddZdS)r|c swtj|d|d|d|d|d||_fdd}jjjtjj} | j|dS)Nrrrrrcs jj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrsz4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr6rv) rr~rrrrrrrrmr)rr_starts !z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|s r|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrs r)-r4r;rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr5rCrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsJ        0J4;]jPK!r,6__pycache__/log.cpython-35.pycnu[ Yf|@s%dZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr0/opt/alt/python35/lib64/python3.5/asyncio/log.pys PK!>]00+__pycache__/transports.cpython-35.opt-1.pycnu[ YfR'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sdeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkri}||_dS)N)_extra)selfextrar 7/opt/alt/python35/lib64/python3.5/asyncio/transports.py__init__ s zBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCs tdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCs tdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCs tdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCs tdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s.eZdZdZddZddZdS)rz#Interface for read-only transports.cCs tdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCs tdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-s  c@speZdZdZddddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCs tdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCs tdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCs tdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCs tj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineseszWriteTransport.writelinescCs tdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCs tdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCs tdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort) rrrrr!r"r$r%r&r'r(r r r r rAs    c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rs c@s1eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCs tdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCs tdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)rrrrr)r(r r r r rs  c@sXeZdZddZddZddZddZd d Zd d Zd S)rcCs tdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCs tdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCs tdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCs tdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCs tdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCs tdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs      cseZdZdZddfddZddZddZd d Zddd d Zddd dZ ddZ S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. Ncs0tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs  z_FlowControlMixin.__init__cCs|j}||jkrdS|jsd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NTmessagezprotocol.pause_writing() failed exception transportr)r" _high_waterr5 _protocolZ pause_writing Exceptionr4call_exception_handler)r sizeexcr r r _maybe_pause_protocols    z'_FlowControlMixin._maybe_pause_protocolcCs|jr|j|jkrd|_y|jjWnPtk r}z0|jjddd|d|d|jiWYdd}~XnXdS)NFr8z protocol.resume_writing() failedr9r:r)r5r" _low_waterr<Zresume_writingr=r4r>)r r@r r r _maybe_resume_protocols   z(_FlowControlMixin._maybe_resume_protocolcCs|j|jfS)N)rBr;)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCs|dkr+|dkr!d}n d|}|dkrA|d}||koXdknsstd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr;rB)r rr r r r r6s       z*_FlowControlMixin._set_write_buffer_limitscCs$|jd|d||jdS)Nrr )r6rA)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCs tdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size) rrrrrrArCrDr6r!r"r r )r7r r2s    r2N) rZasyncior__all__rrrrrrr2r r r r s #D4PK!eZdZdfddZdddddddZddd d dddddd d Zdd d dddddd dZdddddZfddZddZ ddZ ddZ ddZ ddZ ddZdddd d!Zdddd"d#Zeddd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zd<d=Zd>d?Zed@dAZ dBdCZ!dDdEZ"dFdGZ#dHdIZ$dJdKZ%dLdMZ&dNdOZ'S)PrNcsatj|dkr%tj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r DefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)r(rrr%<s     zBaseSelectorEventLoop.__init__extraservercCst||||||S)N)_SelectorSocketTransport)r/r"protocolwaiterr0r1rrr_make_socket_transportFsz,BaseSelectorEventLoop._make_socket_transport server_sideFserver_hostnamec Cs{tjs:|j||||d|d|d|d|Stj||||||} t||| d|d|| jS)Nr6r7r0r1)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr2Z_app_transport) r/rawsockr3 sslcontextr4r6r7r0r1Z ssl_protocolrrr_make_ssl_transportKs     z)BaseSelectorEventLoop._make_ssl_transportc Cs"t||||||||| S)N)_SelectorSslTransport) r/r9r3r:r4r6r7r0r1rrrr8Zsz0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r/r"r3addressr4r0rrr_make_datagram_transportds z.BaseSelectorEventLoop._make_datagram_transportcsh|jrtd|jr(dS|jtj|jdk rd|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_piper$closer*)r/)r(rrrCis      zBaseSelectorEventLoop.closecCs tdS)N)NotImplementedError)r/rrr _socketpairtsz!BaseSelectorEventLoop._socketpaircCsU|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenorC_csock _internal_fds)r/rrrrBws     z&BaseSelectorEventLoop._close_self_pipecCsg|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)rErGrI setblockingrJ _add_readerrH_read_from_self)r/rrrr+s z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r/datarrr_process_self_datasz(BaseSelectorEventLoop._process_self_datac Cs_xXy*|jjd}|sP|j|Wqtk rDwYqtk rVPYqXqWdS)Ni)rGrecvrOInterruptedErrorBlockingIOError)r/rNrrrrMs  z%BaseSelectorEventLoop._read_from_selfc Cs[|j}|dk rWy|jdWn.tk rV|jrRtjdddYnXdS)Nsz3Fail to write a null byte into the self-pipe socketexc_infoT)rIsendOSError_debugr r')r/Zcsockrrr_write_to_selfs     z$BaseSelectorEventLoop._write_to_selfdcCs,|j|j|j|||||dS)N)rLrH_accept_connection)r/protocol_factoryr"r:r1backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cs[xTt|D]F}yB|j\}}|jrGtjd||||jdWntttfk rvdSYq t k r} z| j t j t j t j t jfkr |jddd| d|i|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFmessagez&socket.accept() out of system resource exceptionrpeername)rangeacceptrVr r'rKrRrQConnectionAbortedErrorrUerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerrFrHZ call_laterrZACCEPT_RETRY_DELAYr\_accept_connection2Z create_task) r/rZr"r:r1r[_connaddrexcr0rarrrrYs4         z(BaseSelectorEventLoop._accept_connectionc cs$d}d}y|}|j}|rZ|j|||d|ddd|d|}n$|j||d|d|d|}y |EdHWn|jYnXWnytk r} zY|jr ddd| i} |dk r|| d <|dk r|| d <|j| WYdd} ~ XnXdS) Nr4r6Tr0r1r]z3Error on transport creation for incoming connectionr^r3 transport) create_futurer;r5rC ExceptionrVrd) r/rZrgr0r:r1r3rjr4ricontextrrrres4            z)BaseSelectorEventLoop._accept_connection2c CsNy|j|}Wntk r%Yn%X|jsJtdj||dS)Nz.File descriptor {!r} is used by transport {!r})r.r is_closingr@format)r/rrjrrr_ensure_fd_no_transports  z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tj|dfYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandler*rrregisterr EVENT_READrNmodifycancel) r/rcallbackargshandlermaskreaderwriterrrrrLs    z!BaseSelectorEventLoop._add_readerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) rAr*rrrrNr rt unregisterrurv)r/rrrzr{r|rrrrFs     z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn1tk rh|jj|tjd|fYnSX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rqrrrr*rrrsr EVENT_WRITErNrurv) r/rrwrxryrrzr{r|rrr _add_writer(s    z!BaseSelectorEventLoop._add_writerc Cs|jrdSy|jj|}Wntk r>dSYn{X|j|j}\}}|tjM}|s|jj|n|jj |||df|dk r|j dSdSdS)NFT) rAr*rrrrNr r~r}rurv)r/rrrzr{r|rrr_remove_writer7s     z$BaseSelectorEventLoop._remove_writercGs |j||j|||S)N)rprL)r/rrwrxrrr add_readerNs z BaseSelectorEventLoop.add_readercCs|j||j|S)N)rprF)r/rrrr remove_readerSs z#BaseSelectorEventLoop.remove_readercGs |j||j|||S)N)rpr)r/rrwrxrrr add_writerXs z BaseSelectorEventLoop.add_writercCs|j||j|S)N)rpr)r/rrrr remove_writer]s z#BaseSelectorEventLoop.remove_writercCsM|jr'|jdkr'td|j}|j|d|||S)Nrzthe socket must be non-blockingF)rV gettimeout ValueErrorrk _sock_recv)r/r"nfutrrr sock_recvbs   zBaseSelectorEventLoop.sock_recvcCs|j}|r|j||jr/dSy|j|}Wnhttfk r{|j||j|d||Yn?tk r}z|j |WYdd}~XnX|j |dS)NT) rHr cancelledrPrRrQrrrl set_exception set_result)r/r registeredr"rrrNrirrrrqs   # z BaseSelectorEventLoop._sock_recvcCsc|jr'|jdkr'td|j}|rR|j|d||n |jd|S)Nrzthe socket must be non-blockingF)rVrrrk _sock_sendallr)r/r"rNrrrr sock_sendalls    z"BaseSelectorEventLoop.sock_sendallcCs|j}|r|j||jr/dSy|j|}WnSttfk rbd}Yn6tk r}z|j|dSWYdd}~XnX|t|kr|j dn5|r||d}|j ||j |d||dS)NrT) rHrrrTrRrQrlrlenrrr)r/rrr"rNrrrirrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr'|jdkr'tdttd sI|jtjkrtj|d|jd|j d|}|j s|EdH|j d\}}}}}|j }|j ||||EdHS)Nrzthe socket must be non-blockingAF_UNIXrrloop)rVrrhasattrrrrrZ_ensure_resolvedrdoneresultrk _sock_connect)r/r"r>Zresolvedrfrrrr sock_connects "!   z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnttfk ro|jtj|j||j||j |||Yn?t k r}z|j |WYdd}~XnX|j ddS)N) rHconnectrRrQadd_done_callback functoolspartial_sock_connect_doner_sock_connect_cbrlrr)r/rr"r>rrirrrrs   z#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)r)r/rrrrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jrdSy>|jtjtj}|dkrMt|d|fWnIttfk rhYn?tk r}z|j |WYdd}~XnX|j ddS)NrzConnect call failed %s) r getsockoptr SOL_SOCKETSO_ERRORrUrRrQrlrr)r/rr"r>errrirrrrs   z&BaseSelectorEventLoop._sock_connect_cbcCsJ|jr'|jdkr'td|j}|j|d||S)Nrzthe socket must be non-blockingF)rVrrrk _sock_accept)r/r"rrrr sock_accepts   z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr/dSy#|j\}}|jdWnettfk r|j||j|d|YnEt k r}z|j |WYdd}~XnX|j ||fdS)NFT) rHrrrarKrRrQrrrlrr)r/rrr"rrgr>rirrrrs     z"BaseSelectorEventLoop._sock_acceptcCsx|D]\}}|j|j}\}}|tj@rk|dk rk|jr^|j|n |j||tj@r|dk r|jr|j|q|j|qWdS)N) fileobjrNr rtZ _cancelledrFZ _add_callbackr~r)r/Z event_listrrzrr{r|rrr_process_events s   z%BaseSelectorEventLoop._process_eventscCs!|j|j|jdS)N)rFrHrC)r/r"rrr _stop_servingsz#BaseSelectorEventLoop._stop_serving)(r) __module__ __qualname__r%r5r;r8r?rCrErBr+rOrMrWr\rYr rerprLrFrrrrrrrrrrrrrrrrrrrr)r(rr6sT          (#                  cseZdZdZeZdZddfddZddZdd Z d d Z d d Z ddZ ddZ ejrddZdddZddZddZddZS)_SelectorTransportiNc stj||||jd<|j|jdz<%s> )r(r)rappendrr_looprArr*r rtr~get_write_buffer_sizejoin)r/inforstatebufsizerrr__repr__>s*        z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r/rrrabortZsz_SelectorTransport.abortcCs ||_dS)N)r)r/r3rrr set_protocol]sz_SelectorTransport.set_protocolcCs|jS)N)r)r/rrr get_protocol`sz_SelectorTransport.get_protocolcCs|jS)N)r)r/rrrrncsz_SelectorTransport.is_closingcCsn|jr dSd|_|jj|j|jsj|jd7_|jj|j|jj|jddS)NTr) rrrFrrrr call_soon_call_connection_lost)r/rrrrCfs   z_SelectorTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningrC)r/rrr__del__tsz_SelectorTransport.__del__zFatal error on transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srSTr]r^rjr3) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr r'rdrr)r/rir]rrr _fatal_errorys z_SelectorTransport._fatal_errorcCs|jr dS|jr6|jj|jj|j|js[d|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrrrrFrr)r/rirrrrs     z_SelectorTransport._force_closec Csuz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rp|jd|_XdS)N)rrZconnection_lostrrCrrZ_detach)r/rir1rrrrs        z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r/rrrrsz(_SelectorTransport.get_write_buffer_sizei)r)rrmax_size bytearrayrrr%rrrrrnrCrZPY34rrrrrrr)r(rrs         rcseZdZdddfddZddZddZdd Zd d Zd d ZddZ ddZ S)r2Ncstj|||||d|_d|_t|j|jj|jj ||jj|jj |j |j |dk r|jjt j|ddS)NF)r$r%_eof_pausedr#rrrrconnection_maderLr _read_readyr_set_result_unless_cancelled)r/rr"r3r4r0r1)r(rrr%s    z!_SelectorSocketTransport.__init__cCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr@rrrFrrr r')r/rrr pause_readings     z&_SelectorSocketTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr@rrrLrrrr r')r/rrrresume_readings    z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnLttfk r@Yntk rt}z|j|dWYdd}~XnnX|r|jj |nT|j j rt j d||jj}|r|j j|jn |jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrPrrRrQrlrr data_receivedrrr r' eof_receivedrFrrC)r/rNri keep_openrrrrs  #z$_SelectorSocketTransport._read_readycCsNt|tttfs1tdt|j|jrFtd|sPdS|j r|j t j krxt j d|j d7_ dS|js0y|jj|}WnPttfk rYnStk r}z|j|ddSWYdd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrorrr)rr@rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrTrRrQrlrrrr _write_readyextend_maybe_pause_protocol)r/rNrrirrrwrites4     z_SelectorSocketTransport.writecCs |jr dSy|jj|j}Wnlttfk r@Yntk r}z5|jj|j |jj |j |dWYdd}~XnrX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrTrrRrQrlrrrrr_maybe_resume_protocolrrrshutdownrSHUT_WR)r/rrirrrr s&  #    z%_SelectorSocketTransport._write_readycCs6|jr dSd|_|js2|jjtjdS)NT)rrrrrr)r/rrr write_eof"s    z"_SelectorSocketTransport.write_eofcCsdS)NTr)r/rrr can_write_eof)sz&_SelectorSocketTransport.can_write_eof) r)rrr%rrrrrrrrr)r(rr2s   #  r2cseZdZeZdddddfddZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ S)r<NFc stdkrtd|s0tj||}d|ddi} |rY| rY|| d<|j|| } tj|| ||| d|_||_||_ ||_ d|_ |j j d||jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availabler6Zdo_handshake_on_connectFr7r:z%r starts SSL handshake)sslr@r Z_create_transport_contextZ wrap_socketr$r%r_server_hostname_waiter _sslcontextrrupdaterrr r'time _on_handshake) r/rr9r3r:r4r6r7r0r1Z wrap_kwargsZsslsock start_time)r(rrr%1s*          z_SelectorSslTransport.__init__cCs^|jdkrdS|jjsQ|dk rA|jj|n|jjdd|_dS)N)rrrr)r/rirrr_wakeup_waiterUs z$_SelectorSslTransport._wakeup_waiterc%Csy|jjWntjk rH|jj|j|j|dSYntjk r||jj |j|j|dSYnt k r}z|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnhtk r}zH|jj rt j d|dd|jj|j|dSWYdd}~XnX|jjd|d|jjd|jjd |jd |_d |_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r|jj&|}t j'd ||d dS) Nz%r: SSL handshake failedrSTZcheck_hostnamez1%r: SSL handshake failed on matching the hostnamepeercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrrLrrSSLWantWriteErrorr BaseExceptionrr rrFrrCrrrlZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr')r/rrirZdtrrrr_sb               z#_SelectorSslTransport._on_handshakecCsi|jrtd|jr*tdd|_|jj|j|jjretjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr@rrrFrrr r')r/rrrrs     z#_SelectorSslTransport.pause_readingcCsg|jstdd|_|jr+dS|jj|j|j|jjrctj d|dS)Nz Not pausedFz%r resumes reading) rr@rrrLrrrr r')r/rrrrs    z$_SelectorSslTransport.resume_readingcCsr|jr dS|jrKd|_|j|jrK|jj|j|jy|jj|j }Wnt t t j fk rYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnmX|r|jj|nSzE|jjr=tjd||jj}|r_tjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrrrrPrrRrQrrrrrFrlrrrrr r'rrrC)r/rNrirrrrrs4      #z!_SelectorSslTransport._read_readycCs|jr dS|jrTd|_|j|jp8|jsT|jj|j|j|jrAy|j j |j}Wnt t t jfk rd}Ynt jk rd}|jj|jd|_YnYtk r*}z9|jj|j|jj|j|ddSWYdd}~XnX|rA|jd|=|j|js}|jj|j|jr}|jddS)NFrTz"Fatal write error on SSL transport)rrrrrrrLrrrrTrRrQrrrrrrlrrrr)r/rrirrrrs8           z"_SelectorSslTransport._write_readycCst|tttfs1tdt|j|s;dS|jrv|jtj krct j d|jd7_dS|j s|j j|j|j|j j||jdS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)rrrrrrr)rrrr rrrrrrrr)r/rNrrrrs   z_SelectorSslTransport.writecCsdS)NFr)r/rrrrsz#_SelectorSslTransport.can_write_eof)r)rrrrr%rrrrrrrrrr)r(rr<-s " ?  " # r<csgeZdZejZdddfddZddZddZddd Z d d Z S) r=Ncstj||||||_|jj|jj||jj|jj|j|j |dk r|jjt j |ddS)N) r$r%_addressrrrrrLrrrr)r/rr"r3r>r4r0)r(rrr%s  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss!|]\}}t|VqdS)N)r).0rNrfrrr 'szC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r/rrrr&sz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnttfk rFYn|tk rz}z|jj|WYdd}~XnHt k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrrecvfromrrRrQrUrerror_receivedrlrZdatagram_received)r/rNrhrirrrr)s "#z&_SelectorDatagramTransport._read_readycCst|tttfs1tdt|j|s;dS|jro|d|jfkrotd|jf|j r|jr|j t j krt j d|j d7_ dS|jsy7|jr|jj|n|jj||dSWnttfk r&|jj|j|jYnqtk r^}z|jj|dSWYdd}~Xn9tk r}z|j|ddSWYdd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrr)rrrrrr rrrrTsendtorRrQrrr _sendto_readyrUrrrlrrr)r/rNrhrirrrr7s<    z!_SelectorDatagramTransport.sendtocCs:x|jr|jj\}}y3|jr@|jj|n|jj||Wqttfk r|jj||fPYqt k r}z|j j |dSWYdd}~Xqt k r}z|j |ddSWYdd}~XqXqW|j|js6|jj|j|jr6|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrTrrRrQ appendleftrUrrrlrrrrrrr)r/rNrhrirrrr^s*      z(_SelectorDatagramTransport._sendto_ready) r)rr collectionsdequerr%rrrrrr)r(rr=s    'r=)!__all__rrcrrrr,r ImportErrorrrrrrr r r Z coroutinesr logr rrr#Z BaseEventLooprZ_FlowControlMixinZ Transportrr2r<r=rrrrs>            PK!qG!__pycache__/compat.cpython-35.pycnu[ Yf@sOdZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCs&tsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css0|]&}t|tr$t|n|VqdS)N) isinstance memoryviewbytes).0datar 3/opt/alt/python35/lib64/python3.5/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes s  r)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s  PK!"K~~,__pycache__/unix_events.cpython-35.opt-1.pycnu[ Yf @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkrbedddZy ejZWnek rddZYnXGdddejZ e!edrddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%r>ej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr8/opt/alt/python35/lib64/python3.5/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.src seZdZdZdfddZddZfddZd d Zd d Zd dZ ddZ ddZ ddddZ ddddZ edddZddZeddddddddZedddd d!ddd"d#ZS)$_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7sz_UnixSelectorEventLoop.__init__cCs tjS)N)socketZ socketpair)r rrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs8tjx$t|jD]}|j|qWdS)N)rcloselistrremove_signal_handler)r sig)r"rrr%>s z_UnixSelectorEventLoop.closecCs+x$|D]}|sq|j|qWdS)N)_handle_signal)r datarrrr_process_self_dataCs z)_UnixSelectorEventLoop._process_self_datac+Gstj|stj|r*td|j||jytj|jj Wn=t t fk r}zt t |WYdd}~XnXtj|||}||j|rrrr)ws   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y|j|=Wntk r3dSYnX|tjkrOtj}n tj}ytj||WnRtk r}z2|jtj krt dj |nWYdd}~XnX|jsytj dWn;t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr,)r.rKeyErrorr/SIGINTdefault_int_handlerSIG_DFLr3r8r9r4r:r0r2rr7)r r(Zhandlerr=rrrr's(      #z,_UnixSelectorEventLoop.remove_signal_handlercCsbt|ts$tdj|d|ko>tjkns^tdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr-r:r/NSIGr2)r r(rrrr.s z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)r pipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)r rIrJrKrLrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||d| d|| } | j| j|j| y | EdHWn+tk r} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)NrKrL) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)r rJr<shellstdinstdoutstderrbufsizerLkwargswatcherrKtranspr=errrrr_make_subprocess_transports$        z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)r pid returncoder\rrrrSsz._UnixSelectorEventLoop._child_watcher_callbacksslsockserver_hostnamec csB|r!|dkr9tdn|dk r9td|dk r|dk r]tdtjtjtjd}y&|jd|j||EdHWq|jYqXn\|dkrtd|jtjkstj | rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r2r#AF_UNIX SOCK_STREAM setblockingZ sock_connectr%familyr_is_stream_socketr:Z_create_connection_transport)r protocol_factoryrrarbrc transportrJrrrcreate_unix_connections8              z-_UnixSelectorEventLoop.create_unix_connectionbacklogdc !Cst|trtd|dk r|dk r?tdt|}tjtjtj}|dd kry,tj t j|j rt j |WnIt k rYn8tk r}ztjd||WYdd}~XnXy|j|Wqtk ri}zK|j|jtjkrTdj|}ttj|dnWYdd}~Xq|jYqXnO|dkrtd|jtjkstj| rtdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrn)rEboolr-r2_fspathr#rdrestatS_ISSOCKosst_moderemoveFileNotFoundErrorr3rerrorZbindr%r8Z EADDRINUSEr:rgrrhZServerZlistenrfZ_start_serving) r rirrbrlrar]r=msgZserverrrrcreate_unix_serversP      &        z)_UnixSelectorEventLoop.create_unix_server)__name__ __module__ __qualname____doc__rr$r%r+r?r)r'r.rMrOr r^rSrkryrr)r"rr1s,    -   %r set_blockingcCstj|ddS)NF)rsr~)fdrrr_set_nonblocking9srcCs<tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrs O_NONBLOCKZF_SETFL)rflagsrrrr>s cseZdZdZddfddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrddZdddZddZddZS) rHiNcs*tj|||jd<||_||_|j|_||_d|_t j |jj }t j |pt j|pt j|sd|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r&|jjtj|ddS)NrIFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper1_fileno _protocol_closingrsfstatrtrqS_ISFIFOrrS_ISCHRr2r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r looprIrJrKrLmode)r"rrrHs,           z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn,|jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r"rzrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)r r7r!rrrr__repr__es$   z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnLttfk r6Yntk rj}z|j|dWYdd}~XnX|r|jj |ng|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rsreadrmax_sizeBlockingIOErrorInterruptedErrorr3 _fatal_errorrZ data_receivedr get_debugrr7r_remove_readerrZ eof_received_call_connection_lost)r r*r=rrrr{s# z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)r rrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)r rrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)r rJrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)r rrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)r rrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)r rrrr%s z_UnixReadPipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rwarningswarnResourceWarningr%)r rrr__del__sz_UnixReadPipeTransport.__del__zFatal error on pipe transportc Cst|trL|jtjkrL|jjrwtjd||ddn+|jjd|d|d|d|j i|j |dS)Nz%r: %sexc_infoTmessage exceptionrjrJ) rEr3r8ZEIOrrrdebugcall_exception_handlerrr)r r=rrrrrs! z#_UnixReadPipeTransport._fatal_errorcCs6d|_|jj|j|jj|j|dS)NT)rrrrrr)r r=rrrrs z_UnixReadPipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)r r=rrrrs    z,_UnixReadPipeTransport._call_connection_losti)rzr{r|rrrrrrrrrr%rPY34rrrrrr)r"rrHDs            rHcseZdZddfddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejrddZddZddd Zdd!d"Zd#d$ZS)%rNNc sjtj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |p|p| sd|_d|_d|_tdt|j|jj|jj|| s|rAtjjd rA|jj|jj|j|j|dk rf|jjtj|ddS)NrIrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr1rr bytearray_buffer _conn_lostrrsrrtrqrrrrr2rrrrsysplatform startswithrrr r) r rrIrJrKrLrZis_charZis_fifoZ is_socket)r"rrrs2            z _UnixWritePipeTransport.__init__cCs#|jjg}|jdkr.|jdn|jrD|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n,|jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r"rzrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)r r7r!rrYrrrrs(     z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)r rrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCsI|jjrtjd||jr;|jtn |jdS)Nz%r was closed by peer)rrrr7rrBrokenPipeError)r rrrr s  z#_UnixWritePipeTransport._read_readycCsat|trt|}|s%dS|js7|jri|jtjkrVtjd|jd7_dS|j sDyt j |j |}Wnet tfk rd}YnHtk r}z(|jd7_|j|ddSWYdd}~XnX|t|kr dS|dkr+t||d}|jj|j |j|j |7_ |jdS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rEr memoryviewrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrswriterrrrTrrrZ _add_writer _write_readyZ_maybe_pause_protocol)r r*nr=rrrrs2     z_UnixWritePipeTransport.writecCs&ytj|j|j}Wn{ttfk r6Yntk r}zD|jj|jd7_|j j |j|j |dWYdd}~XnX|t |jkr|jj|j j |j|j |jr|j j|j|jddS|dkr"|jd|=dS)Nrz#Fatal write error on pipe transportr)rsrrrrrrTclearrr_remove_writerrrZ_maybe_resume_protocolrrr)r rr=rrrr4s& #     z$_UnixWritePipeTransport._write_readycCsdS)NTr)r rrr can_write_eofNsz%_UnixWritePipeTransport.can_write_eofcCsL|jr dSd|_|jsH|jj|j|jj|jddS)NT)rrrrrrr)r rrr write_eofQs    z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)r rJrrrrZsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)r rrrr]sz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)r rrrr`sz"_UnixWritePipeTransport.is_closingcCs'|jdk r#|j r#|jdS)N)rrr)r rrrr%csz_UnixWritePipeTransport.closecCs4|jdk r0tjd|t|jjdS)Nzunclosed transport %r)rrrrr%)r rrrrlsz_UnixWritePipeTransport.__del__cCs|jddS)N)r)r rrrabortqsz_UnixWritePipeTransport.abortzFatal error on pipe transportc Csyt|tjr=|jjrhtjd||ddn+|jjd|d|d|d|ji|j |dS)Nz%r: %srTrrrjrJ) rErZ_FATAL_ERROR_IGNORErrrrrrr)r r=rrrrrts z$_UnixWritePipeTransport._fatal_errorcCs_d|_|jr%|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrrrrr)r r=rrrrs    z_UnixWritePipeTransport._closec CsDz|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)r r=rrrrs    z-_UnixWritePipeTransport._call_connection_lost)rzr{r|rrrrrrrrrrrr%rrrrrrrrr)r"rrNs$ %   !         rNset_inheritablecCsittdd}tj|tj}|sJtj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables rc@seZdZddZdS)rQc Ksd}|tjkr=|jj\}}t|jdtj|d|d|d|d|ddd|||_|dk r|jt |j dd ||j_ dS) NFrUrVrWrXZuniversal_newlinesrYwb buffering) subprocessPIPErr$rr1Popen_procr%rdetachrV) r r<rUrVrWrXrYrZZstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rzr{r|rrrrrrQs rQc@s^eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)r r_r;r<rrrrRs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)r r_rrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)r rrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)r rrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)r rrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)r abcrrr__exit__szAbstractChildWatcher.__exit__N) rzr{r|r}rRrrr%rrrrrrrs    c@sdeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)r rrrrs zBaseChildWatcher.__init__cCs|jddS)N)r)r rrrr% szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpid szBaseChildWatcher._do_waitpidcCs tdS)N)r)r rrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs|jdk r4|dkr4|jr4tjdt|jdk rV|jjtj||_|dk r|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrrrRuntimeWarningr'r/SIGCHLDr? _sig_chldr)r rrrrrs$  zBaseChildWatcher.attach_loopcCsVy|jWnAtk rQ}z!|jjddd|iWYdd}~XnXdS)Nrz$Unknown exception in SIGCHLD handlerr)rrTrr)r r=rrrr&s  zBaseChildWatcher._sig_chldcCsAtj|rtj| Stj|r9tj|S|SdS)N)rs WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)r statusrrr_compute_returncode2s  z$BaseChildWatcher._compute_returncodeN) rzr{r|rr%rrrrrrrrrrs       rcspeZdZdZfddZddZddZdd Zd d Zd d Z ddZ S)rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cs|jjtjdS)N)rrrr%)r )r"rrr%Ks zSafeChildWatcher.closecCs|S)Nr)r rrrrOszSafeChildWatcher.__enter__cCsdS)Nr)r rrrrrrrRszSafeChildWatcher.__exit__cGs?|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr4rr)r r_r;r<rrrrRUs  z"SafeChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)rrA)r r_rrrr`s   z%SafeChildWatcher.remove_child_handlercCs+x$t|jD]}|j|qWdS)N)r&rr)r r_rrrrgsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn.tk rO|}d}tjd|YnBX|dkr`dS|j|}|jjrtj d||y|j j |\}}Wn7t k r|jjrtjd|ddYnX||||dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rrT) rswaitpidWNOHANGChildProcessErrorrrrrrrrpoprA)r rr_rr`r;r<rrrrls*       zSafeChildWatcher._do_waitpid) rzr{r|r}r%rrrRrrrrr)r"rr@s     csveZdZdZfddZfddZddZdd Zd d Zd d Z ddZ S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs2tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r )r"rrrs  zFastChildWatcher.__init__cs+|jj|jjtjdS)N)rrrrr%)r )r"rrr%s  zFastChildWatcher.closec Cs(|j|jd7_|SWdQRXdS)Nr)rr)r rrrrs zFastChildWatcher.__enter__c Csg|jG|jd8_|js,|j r0dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr5rrr)r rrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGs|jdkrtd|jGy|jj|}Wn)tk rf||f|j| %dr,)rsrrrrrrrrArrrrrrr)r r_rr`r;r<rrrrs6             z FastChildWatcher._do_waitpid_all) rzr{r|r}rr%rrrRrrrr)r"rrs     csdeZdZdZeZfddZddZfddZdd Z d d Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r )r"rrrs z$_UnixDefaultEventLoopPolicy.__init__c Cs^tjN|jdkrSt|_ttjtjrS|jj|j j WdQRXdS)N) rrrrrErcurrent_thread _MainThreadr_localr)r rrr _init_watchers     z)_UnixDefaultEventLoopPolicy._init_watchercsKtj||jdk rGttjtjrG|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrErrrr)r r)r"rrr sz*_UnixDefaultEventLoopPolicy.set_event_loopcCs |jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)r rrrrPs z-_UnixDefaultEventLoopPolicy.get_child_watchercCs)|jdk r|jj||_dS)z$Set the watcher for child processes.N)rr%)r r[rrrset_child_watcher%s z-_UnixDefaultEventLoopPolicy.set_child_watcher) rzr{r|r}rZ _loop_factoryrrrrPrrr)r"rrs   r)5r}r8rsr/r#rqrrrrrrrrrrr r r r r logr__all__r ImportErrorrZfspathrpAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrHZ_FlowControlMixinZWriteTransportrNrrZBaseSubprocessTransportrQrrrrZBaseDefaultEventLoopPolicyrrrrrrrsh                    F=On2PK!ӎɬ&T&T __pycache__/tasks.cpython-35.pycnu[ Yfg @sCdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZGdddejZejjZejjZejjZedddddeddZddZeddddZeddZddddd dZedddd!dZddd"d#Zeed Cs z!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks;s  zTask.all_tasksrcstj|s!tt|tjd||jrG|jd=||_d|_d|_ |j j |j |j jj|dS)NrrF)r iscoroutineAssertionErrorreprsuper__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r!add)selfcoror)r/rrr(Es!     z Task.__init__cCsg|jtjkrS|jrSd|ddi}|jrC|j|d<|jj|tjj|dS)Ntaskmessagez%Task was destroyed but it is pending!Zsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr)rZcall_exception_handlerFuture__del__)r1contextrrrr7Ts   z Task.__del__csrtj}|jr"d|dz wait_for=%r)r' _repr_infor,rZ_format_coroutiner*insertr+)r1infor2)r/rrr:_s  zTask._repr_infolimitc Cs g}y|jj}Wntk r6|jj}YnX|dk rxI|dk r|dk ru|dkrkP|d8}|j||j}qFW|jnj|jdk r|jj}xL|dk r|dk r|dkrP|d8}|j|j |j }qW|S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. Nrr) r*cr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)r1r=Zframesftbrrr get_stackms0             zTask.get_stackfilec Cs]g}t}x|jd|D]}|j}|j}|j}|j} ||krr|j|tj|tj |||j } |j ||| | fq"W|j } |st d|d|n7| dk rt d|d|nt d|d|tj|d|| dk rYx3tj| j| D]} t | d|ddq9WdS) anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. r=zNo stack for %rrKNz)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):end)setrJf_linenof_code co_filenameco_namer0 linecache checkcachegetline f_globalsrArDprint traceback print_listformat_exception_onlyr/) r1r=rKextracted_listZcheckedrHlinenocofilenamenamelineexcrrr print_stacks0               zTask.print_stackcCsHd|_|jrdS|jdk r;|jjr;dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner+cancelr,)r1rrrrds   z Task.cancelcs@|j s%tdj|||jrUt|tjsLtj}d|_|j}d|_||j j |j .)risfuturerr$ TypeErrortypery ValueErrorrrrrfrrrN_wait)fsrrrr)rrrLs   cGs|js|jddS)N)rcrm)waiterargsrrr_release_waiterls rccs |dkrtj}|dkr-|EdHS|j}|j|t|}tjt|}t|d|}|j|z|y |EdHWn/t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nr)rr create_future call_laterr functoolspartialr rsrrhremove_done_callbackrdrcrw TimeoutError)futrrrtimeout_handlecbrrrrqs,             c #s|std|jd|dk rE|j|tt|fdd}x|D]}|j|qsWz EdHWddk rjXtt}}xD|D]<}|j||j r|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. zSet of Futures is empty.Ncsd8dksMtksMtkr||j r||jdk r|dk rcjjs|jddS)Nrr)rr cancelled exceptionrdrcrm)rH)counterrrrrr_on_completions      z_wait.._on_completion) r%rrrlenrsrdrNrrcr0)rrrrrrHrcpendingr)rrrrrrs(          rc#sLtj|stj|r7tdt|jdk rIn tjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr#|dk r#j||x"ttD]}|Vq6WdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcs"h|]}t|dqS)r)r )rrH)rrrr s zas_completed..r)Queuercs9x(D] }|jjdqWjdS)N)r put_nowaitclear)rH)rrctodorr _on_timeouts  z!as_completed.._on_timeoutcsEs dSj|j| rAdk rAjdS)N)removerrd)rH)rcrrrrrs   z$as_completed.._on_completionc3s0jEdH}|dkr&tj|jS)N)rrrrw)rH)rcrr _wait_for_ones  z#as_completed.._wait_for_one)rrrr$rrryrrrNZqueuesrrrsrranger)rrrrrrrH_r)rrcrrrrrs  c csv|dkrdV|S|dkr-tj}|j}|jj|tj||}z |EdHSWd|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrrrrZ_set_result_unless_cancelledrd)Zdelayrwrrxhrrrrs       cCs&tjdtddt|d|S)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future() stacklevelr9r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_s rcCstj|r:|dk r6||jk r6td|Stj|r|dkratj}|j|}|j r|j d=|St j rt j |rtt|d|StddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurerrz:An asyncio.Future, a coroutine or an awaitable is requiredr#)rrrrrr$rrZ create_taskr)rZPY35ruZ isawaitabler _wrap_awaitabler)rrr3rrrr +s     ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrBsrcs:eZdZdZddfddZddZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. rNcs tjd|||_dS)Nr)r'r( _children)r1childrenr)r/rrr(Tsz_GatheringFuture.__init__cCs@|jrdSd}x#|jD]}|jr d}q W|S)NFT)rcrrd)r1ZretZchildrrrrdXs   z_GatheringFuture.cancel)ryrzr{r|r(rdrr)r/rrLs rreturn_exceptionsFcs|s;|dkrtj}|jjgSixt|D]}tj|st|d|}|dkr|j}d|_ n9|}|dkr|j}n|j|k rt d||s zgather..rcsjr&|js"|jdS|jrXtj}sj|dSn>|jdk r|j}sj|dSn |j}||<d7krjdS)Nr) rcrrrrhrlrDZ_resultrm)irres) nchildren nfinishedouterresultsrrr_done_callbacks&            zgather.._done_callback)rrrrmrNrrr rr5rrr enumeratersrr)rrZcoros_or_futuresrrrrrr)rrrrrrrr bs8            csZt|d|}|jr"|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None rcs~jr&|js"|jdS|jr?jn;|j}|dk rgj|nj|jdS)N)rrrdrlrmrw)innerra)rrrrs       zshield.._done_callback)r rcrrrs)rrrrr)rrr s    csStjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcshy tjtdWnAtk rc}z!jrNj|WYdd}~XnXdS)Nr)rZ _chain_futurer roZset_running_or_notify_cancelrl)ra)r2rxrrrcallbacks    z*run_coroutine_threadsafe..callback)rr$r concurrentrr6Zcall_soon_threadsafe)r2rrr)r2rxrrr s   )$r|__all__Zconcurrent.futuresrrrurSrXrr}rMrrrrrr6rrrrrrrrrrrglobalsryr rrr r r rrrrsP        0    --8   T5PK!G9g""'__pycache__/queues.cpython-35.opt-1.pycnu[ Yf@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr3/opt/alt/python35/lib64/python3.5/asyncio/queues.pyrs c@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrs c@seZdZdZdddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS))ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rloopNcCs|dkrtj|_n ||_||_tj|_tj|_d|_t j d|j|_ |j j |j |dS)Nrr)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s     zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs7x0|r2|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs     zQueue._wakeup_nextcCs(djt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCsdj|j}t|ddr@|djt|j7}|jre|djt|j7}|jr|djt|j7}|jr|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts   z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs*|jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullmsz Queue.fullc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs    z Queue.putcCsO|jrt|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s    zQueue.put_nowaitc csx~|jr|jj}|jj|y |EdHWq|j|j ru|j ru|j|jYqXqW|jS)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7r8r( get_nowait)rgetterrrrgets   z Queue.getcCs2|jrt|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr<s   zQueue.get_nowaitcCsJ|jdkrtd|jd8_|jdkrF|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. 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 ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)r ValueErrorrr)rrrr task_dones  zQueue.task_doneccs%|jdkr!|jjEdHdS)aBlock 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 calls 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, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r>r<r@rBrrrrrs&            c@sFeZdZdZddZejddZejddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrDr%rEr"rrrrrs  c@s:eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs    JoinableQueue)r__all__rrFrr r Z coroutinesr ExceptionrrrrrZPY35rHr#rrrrs   PK!x*__pycache__/constants.cpython-35.opt-1.pycnu[ Yf@sdZdZdZdS)z Constants.N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYrr6/opt/alt/python35/lib64/python3.5/asyncio/constants.pysPK!Ѥ$__pycache__/protocols.cpython-35.pycnu[ Yf@sqdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@sFeZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr6/opt/alt/python35/lib64/python3.5/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs    c@s.eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>s  c@s.eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgs  c@s:eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrts   N)r__all__rrrrrrrrs   7) PK!*UPUP(__pycache__/streams.cpython-35.opt-1.pycnu[ Yf^ @sdZdddddddgZdd lZeed rOejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d#Z GdddeZGdddeZe d d dd de ddZe d d dd de ddZeed rze d dd de dd Ze d dd de dd ZGddde jZGd ddee jZGd!ddZGd"ddZd S)$zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs6tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__4/opt/alt/python35/lib64/python3.5/asyncio/streams.pyr s  zIncompleteReadError.__init__)__name__ __module__ __qualname____doc__rrr)rrrs cs(eZdZdZfddZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager!)rrrr-szLimitOverrunError.__init__)rrrr rrr)rrr's looplimitc +s|dkrtj}td|d|}t|d||jfdd|||EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) Nr$r#csS)Nrr)protocolrrKsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr#r$kwdsreader transport_writerr)r%rr2s  )c+sKdkrtjfdd}j||||EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncs.tdd}t|d}|S)Nr$r#)rr)r+r%)client_connected_cbr$r#rrfactoryks  zstart_server..factory)rr'Z create_server)r/r(r)r#r$r*r0r)r/r$r#rrPs  c+s|dkrtj}td|d|}t|d||jfdd||EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.Nr$r#csS)Nrr)r%rrr&sz&open_unix_connection..)rr'rrZcreate_unix_connectionr)pathr#r$r*r+r,r-r.r)r%rr ws  &c+sHdkrtjfdd}j|||EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncs.tdd}t|d}|S)Nr$r#)rr)r+r%)r/r$r#rrr0s  z"start_unix_server..factory)rr'Zcreate_unix_server)r/r1r#r$r*r0r)r/r$r#rr s  c@s[eZdZdZdddZddZddZd d Zed d Z dS) FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCsF|dkrtj|_n ||_d|_d|_d|_dS)NF)rr'_loop_paused _drain_waiter_connection_lost)rr#rrrrs     zFlowControlMixin.__init__cCs,d|_|jjr(tjd|dS)NTz%r pauses writing)r4r3 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCscd|_|jjr(tjd||j}|dk r_d|_|js_|jddS)NFz%r resumes writing)r4r3r7rr8r5done set_result)rwaiterrrrresume_writings     zFlowControlMixin.resume_writingcCsud|_|jsdS|j}|dkr/dSd|_|jrHdS|dkrd|jdn |j|dS)NT)r6r4r5r:r; set_exception)rexcr<rrrconnection_losts       z FlowControlMixin.connection_lostccsP|jrtd|js"dS|j}|jj}||_|EdHdS)NzConnection lost)r6ConnectionResetErrorr4r5r3 create_future)rr<rrr _drain_helpers     zFlowControlMixin._drain_helper) rrrr rr9r=r@rrCrrrrr2s   r2csdeZdZdZddfddZddZfddZd d Zd d ZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs;tjd|||_d|_||_d|_dS)Nr#F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr/r#)rrrrs    zStreamReaderProtocol.__init__cCs|jj||jddk |_|jdk rt|||j|j|_|j|j|j}tj |r|jj |dS)NZ sslcontext) rD set_transportget_extra_inforGrFrr3rEr Z iscoroutineZ create_task)rr,resrrrconnection_mades   z$StreamReaderProtocol.connection_madecsa|jdk r;|dkr+|jjn|jj|tj|d|_d|_dS)N)rDfeed_eofr>rr@rE)rr?)rrrr@s  z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rD feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rDrLrG)rrrr eof_receiveds  z!StreamReaderProtocol.eof_received) rrrr rrKr@rOrPrr)rrrs   c@seZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs(||_||_||_||_dS)N) _transport _protocol_readerr3)rr,r%r+r#rrrrs   zStreamWriter.__init__cCsM|jjd|jg}|jdk r<|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrQrSappendjoin)rinforrr__repr__szStreamWriter.__repr__cCs|jS)N)rQ)rrrrr,!szStreamWriter.transportcCs|jj|dS)N)rQwrite)rrNrrrrY%szStreamWriter.writecCs|jj|dS)N)rQ writelines)rrNrrrrZ(szStreamWriter.writelinescCs |jjS)N)rQ write_eof)rrrrr[+szStreamWriter.write_eofcCs |jjS)N)rQ can_write_eof)rrrrr\.szStreamWriter.can_write_eofcCs |jjS)N)rQclose)rrrrr]1szStreamWriter.closeNcCs|jj||S)N)rQrI)rnamedefaultrrrrI4szStreamWriter.get_extra_infoccsi|jdk r0|jj}|dk r0||jdk rS|jjrSdV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rS exceptionrQZ is_closingrRrC)rr?rrrdrain7s  zStreamWriter.drain)rrrr rrXpropertyr,rYrZr[r\r]rIrrarrrrr s        c@s0eZdZedddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZedddZed'ddZed d!Zejred"d#Zed$d%Zejr,d&d#ZdS)(rNcCs|dkrtd||_|dkr?tj|_n ||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr'r3 bytearray_buffer_eof_waiter _exceptionrQr4)rr$r#rrrrRs          zStreamReader.__init__cCsdg}|jr,|jdt|j|jrB|jd|jtkre|jd|j|jr|jd|j|jr|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rT) rfrUrrgrd_DEFAULT_LIMITrhrirQr4rV)rrWrrrrXes          zStreamReader.__repr__cCs|jS)N)ri)rrrrr`wszStreamReader.exceptioncCsD||_|j}|dk r@d|_|js@|j|dS)N)rirh cancelledr>)rr?r<rrrr>zs      zStreamReader.set_exceptioncCs;|j}|dk r7d|_|js7|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rhrlr;)rr<rrr_wakeup_waiters     zStreamReader._wakeup_waitercCs ||_dS)N)rQ)rr,rrrrHszStreamReader.set_transportcCs;|jr7t|j|jkr7d|_|jjdS)NF)r4rrfrdrQresume_reading)rrrr_maybe_resume_transports! z$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rgrm)rrrrrLs zStreamReader.feed_eofcCs|jo|j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rgrf)rrrrat_eofszStreamReader.at_eofc Cs|s dS|jj||j|jdk r|j rt|jd|jkry|jjWntk rd|_Yn Xd|_dS)NrT) rfextendrmrQr4rrdZ pause_readingNotImplementedError)rrNrrrrMs   zStreamReader.feed_datac csq|jdk rtd||jr>d|_|jj|jj|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzH%s() called while another coroutine is already waiting for incoming dataF)rh RuntimeErrorr4rQrnr3rB)rZ func_namerrr_wait_for_datas     zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rX}z |jSWYdd}~Xntk r}za|jj||jr|jd|j|=n |jj|j t |j dWYdd}~XnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. s Nr) r readuntilrrrrf startswithr!clearrorcargs)rsepseplenlineerrrreadlines   &zStreamReader.readlines ccsYt|}|dkr$td|jdk r<|jd}xt|j}|||kr|jj||}|dkrP|d|}||jkrtd||jrt|j}|jj t |d|j dEdHqEW||jkrtd||jd||}|jd||=|j t|S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitruz2Separator is found, but chunk is longer than limit) rrcrirffindrdrrgbytesrwrrtro)rZ separatorrzoffsetZbuflenZisepchunkrrrrus:          zStreamReader.readuntilr ccs|jdk r|j|dkr(dS|dkryg}x/|j|jEdH}|s[P|j|q=Wdj|S|j r|j r|jdEdHt|jd|}|jd|=|j |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrread) rirrdrUrVrfrgrtrro)rnZblocksblockrNrrrrJs$     zStreamReader.readccs |dkrtd|jdk r0|j|dkr@dSx_t|j|kr|jrt|j}|jjt|||jdEdHqCWt|j|krt|j}|jjn)t|jd|}|jd|=|j |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rcrirrfrgrrwrrtro)rrZ incompleterNrrrr}s&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs'|jEdH}|dkr#t|S)Nr)r}StopAsyncIteration)rvalrrr __anext__s zStreamReader.__anext__cCs|S)Nr)rrrrrsr~)rrrrkrrXr`r>rmrHrorLrprMrrtr}rurrr ZPY35rrZPY352rrrrrPs,          [2*  i)r __all__Zsockethasattrrqr r rrrlogrrkEOFErrorr Exceptionrrrr r ZProtocolr2rrrrrrrsB      " B3GPK!⣇+__pycache__/subprocess.cpython-35.opt-2.pycnu[ ] @s ddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejddZedddddddddejddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsjeZdZfddZddZddZddZd d Zd d Zd dZ S)SubprocessStreamProtocolcsRtjd|||_d|_|_|_d|_d|_g|_dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__//opt/alt/python35/lib64/python3.5/subprocess.pyrs    z!SubprocessStreamProtocol.__init__cCs|jjg}|jdk r2|jd|j|jdk rU|jd|j|jdk rx|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__sz!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk retjd|jd|j|_|jj||jj d|jd}|dk rtjd|jd|j|_ |j j||jj d|jd}|dk rtj |d|ddd|j|_ dS)Nrrr rprotocolreader) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&     z(SubprocessStreamProtocol.connection_madecCsS|dkr|j}n|dkr0|j}nd}|dk rO|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@s     z+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr<|j}|dk r+|j|j|dS|dkrT|j}n|dkrl|j}nd}|dkr|dkr|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eof set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$             z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr0)rrrrprocess_exitedas z'SubprocessStreamProtocol.process_exitedcCs8t|jdkr4|jr4|jjd|_dS)Nr)lenrrrr-)rrrrr0es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname__rr r)r,r3r4r0rr)rrr s    r c@seZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCsR||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrls      zProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)N)r_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr=szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr?szProcess.terminatecCs|jjdS)N)rkill)rrrrr@sz Process.killccs|jj}|jj||r>tjd|t|y|jjEdHWnDtt fk r}z|rtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr5ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrCr1rrr _feed_stdins &zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr*|j}n |j}|jjrm|dkrTdnd}tjd|||jEdH}|jjr|dkrdnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&rAr rCreadr-)rr*r(streamnameoutputrrr _read_streams    zProcess._read_streamNccs|dk r|j|}n |j}|jdk rK|jd}n |j}|jdk rx|jd}n |j}tj|||d|jEdH\}}}|jEdH||fS)Nrr!r ) rGrHrrMrrZgatherr&r<)rrFrrrrrr communicates    zProcess.communicate)rr6r7rr propertyr:r r<r=r?r@rGrHrMrNrrrrr8ks     r8c +sodkrtjfdd}j||d|d|d||EdH\}} t|| S)NcstddS)Nrr )r r)rr rrs z)create_subprocess_shell..rrr)rget_event_loopZsubprocess_shellr8) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs  rrrr rc /srdkrtjfdd}j|||d|d|d||EdH\} } t| | S)NcstddS)Nrr )r r)rr rrrPs z(create_subprocess_exec..rrr)rrQZsubprocess_execr8) Zprogramrrrr rargsrSrTr(r"r)rr rrs    )__all__ subprocessrrrrZ coroutinesr logr PIPESTDOUTDEVNULLZFlowControlMixinZSubprocessProtocolr r8Z_DEFAULT_LIMITrrrrrrs(      X]    PK!Sq]e]e sslproto.pynu[PK!/(W e__init__.pynu[PK! NNR'R' oktransports.pynu[PK!yPaa exceptions.pynu[PK!n base_tasks.pynu[PK!fTYTY |events.pynu[PK!3  subprocess.pynu[PK!mX3 3 __main__.pynu[PK!  ~(base_futures.pynu[PK!ҰɥNN2proactor_events.pynu[PK!#)!!$__pycache__/protocols.cpython-38.pycnu[PK!مTT*__pycache__/constants.cpython-38.opt-1.pycnu[PK!#)!!*i__pycache__/protocols.cpython-38.opt-1.pycnu[PK!) yy,x__pycache__/base_events.cpython-38.opt-1.pycnu[PK!XFY  %M__pycache__/exceptions.cpython-38.pycnu[PK!kނxx*__pycache__/staggered.cpython-38.opt-1.pycnu[PK!? (x__pycache__/runners.cpython-38.opt-1.pycnu[PK!fmfm0z__pycache__/selector_events.cpython-38.opt-2.pycnu[PK!,PP"@__pycache__/streams.cpython-38.pycnu[PK!֬$Ap__pycache__/log.cpython-38.opt-2.pycnu[PK!J]J]0_q__pycache__/proactor_events.cpython-38.opt-1.pycnu[PK! //% __pycache__/transports.cpython-38.pycnu[PK!E2!2!'S__pycache__/trsock.cpython-38.opt-1.pycnu[PK!%if[[0(__pycache__/proactor_events.cpython-38.opt-2.pycnu[PK!/v//+B__pycache__/transports.cpython-38.opt-1.pycnu[PK!r ss0tH__pycache__/selector_events.cpython-38.opt-1.pycnu[PK!d5yy-__pycache__/base_futures.cpython-38.opt-1.pycnu[PK!مTT$r__pycache__/constants.cpython-38.pycnu[PK!^1$__pycache__/log.cpython-38.opt-1.pycnu[PK!cndd,___pycache__/base_events.cpython-38.opt-2.pycnu[PK!_P+l__pycache__/base_tasks.cpython-38.opt-2.pycnu[PK!mmtt*!t__pycache__/selector_events.cpython-38.pycnu[PK!M!`!`)__pycache__/windows_events.cpython-38.pycnu[PK!-+H__pycache__/transports.cpython-38.opt-2.pycnu[PK!Zy y #d__pycache__/__main__.cpython-38.pycnu[PK!2 2 'p__pycache__/trsock.cpython-38.opt-2.pycnu[PK!f Vq(g__pycache__/windows_utils.cpython-38.pycnu[PK!b5?? E__pycache__/locks.cpython-38.pycnu[PK!.__pycache__/windows_utils.cpython-38.opt-2.pycnu[PK!~(r__pycache__/runners.cpython-38.opt-2.pycnu[PK!)__pycache__/__init__.cpython-38.opt-1.pycnu[PK!6l[P++" __pycache__/futures.cpython-38.pycnu[PK!EK{{-:(__pycache__/base_futures.cpython-38.opt-2.pycnu[PK!ոlUU'/__pycache__/queues.cpython-38.opt-2.pycnu[PK!b5??&E__pycache__/locks.cpython-38.opt-1.pycnu[PK!@[{ )__pycache__/__init__.cpython-38.opt-2.pycnu[PK!")+ + )1__pycache__/format_helpers.cpython-38.pycnu[PK!x*0&__pycache__/unix_events.cpython-38.pycnu[PK!%%$, __pycache__/staggered.cpython-38.pycnu[PK!!88(;= __pycache__/streams.cpython-38.opt-2.pycnu[PK!{`^`^*)v __pycache__/proactor_events.cpython-38.pycnu[PK!{77/ __pycache__/format_helpers.cpython-38.opt-2.pycnu[PK!!SS)y __pycache__/sslproto.cpython-38.opt-1.pycnu[PK!_P+1 __pycache__/base_tasks.cpython-38.opt-1.pycnu[PK!OO(9 __pycache__/streams.cpython-38.opt-1.pycnu[PK!Ҕ+ __pycache__/coroutines.cpython-38.opt-1.pycnu[PK!b^^  __pycache__/tasks.cpython-38.pycnu[PK!XFY  + __pycache__/exceptions.cpython-38.opt-1.pycnu[PK!s̓*&9&9)+ __pycache__/sslproto.cpython-38.opt-2.pycnu[PK!_P%F __pycache__/base_tasks.cpython-38.pycnu[PK!hGB+N __pycache__/subprocess.cpython-38.opt-1.pycnu[PK!مTT*k __pycache__/constants.cpython-38.opt-2.pycnu[PK!? "^n __pycache__/runners.cpython-38.pycnu[PK!x}$$*Zv __pycache__/base_subprocess.cpython-38.pycnu[PK!//+ __pycache__/subprocess.cpython-38.opt-2.pycnu[PK!r ' __pycache__/queues.cpython-38.opt-1.pycnu[PK!FP[[&8 __pycache__/base_events.cpython-38.pycnu[PK!;``/ __pycache__/windows_events.cpython-38.opt-1.pycnu[PK!d5yy'I __pycache__/base_futures.cpython-38.pycnu[PK!Ehh staggered.pynu[PK! DD futures.pynu[PK! *)) coroutines.pynu[PK!̻.F__pycache__/windows_utils.cpython-36.opt-1.pycnu[PK!2z$[__pycache__/log.cpython-36.opt-2.pycnu[PK!/gg,\__pycache__/unix_events.cpython-36.opt-2.pycnu[PK!@uo#o#0__pycache__/base_subprocess.cpython-36.opt-2.pycnu[PK!]TT+__pycache__/base_tasks.cpython-36.opt-1.pycnu[PK!96AA*3__pycache__/proactor_events.cpython-36.pycnu[PK!.*55"R2__pycache__/futures.cpython-36.pycnu[PK!A.jj.fh__pycache__/windows_utils.cpython-36.opt-2.pycnu[PK!g5TsTs0.{__pycache__/selector_events.cpython-36.opt-1.pycnu[PK!o`JJ __pycache__/tasks.cpython-36.pycnu[PK!ȻYzDzD+9__pycache__/test_utils.cpython-36.opt-1.pycnu[PK!& $ c c!~__pycache__/events.cpython-36.pycnu[PK!K__NN)__pycache__/sslproto.cpython-36.opt-1.pycnu[PK!G^@vv,1__pycache__/unix_events.cpython-36.opt-1.pycnu[PK!$pJ..&__pycache__/tasks.cpython-36.opt-2.pycnu[PK!= __pycache__/log.cpython-36.pycnu[PK!.5?+ __pycache__/subprocess.cpython-36.opt-1.pycnu[PK! :t?t?0__pycache__/proactor_events.cpython-36.opt-2.pycnu[PK!II&2__pycache__/tasks.cpython-36.opt-1.pycnu[PK!ݸBa#}__pycache__/__init__.cpython-36.pycnu[PK!w<`?`?+__pycache__/test_utils.cpython-36.opt-2.pycnu[PK!= $@__pycache__/log.cpython-36.opt-1.pycnu[PK!=( ! !+}__pycache__/coroutines.cpython-36.opt-1.pycnu[PK! E E%__pycache__/test_utils.cpython-36.pycnu[PK! / /+X(__pycache__/transports.cpython-36.opt-1.pycnu[PK!`hh$W__pycache__/protocols.cpython-36.pycnu[PK!RZR   +|o__pycache__/coroutines.cpython-36.opt-2.pycnu[PK!+k44(__pycache__/futures.cpython-36.opt-1.pycnu[PK! VC '__pycache__/queues.cpython-36.opt-1.pycnu[PK!**Q__pycache__/constants.cpython-36.opt-2.pycnu[PK!n][3434(__pycache__/streams.cpython-36.opt-2.pycnu[PK!^  $__pycache__/constants.cpython-36.pycnu[PK!nmm0{__pycache__/selector_events.cpython-36.opt-2.pycnu[PK!35)__pycache__/__init__.cpython-36.opt-2.pycnu[PK!c=+"__pycache__/subprocess.cpython-36.opt-2.pycnu[PK!~^g<g<&g__pycache__/locks.cpython-36.opt-1.pycnu[PK!@LL($__pycache__/streams.cpython-36.opt-1.pycnu[PK!Tj*=2__pycache__/protocols.cpython-36.opt-2.pycnu[PK!~^g<g< J;__pycache__/locks.cpython-36.pycnu[PK!['x__pycache__/compat.cpython-36.opt-1.pycnu[PK!~D.(C{__pycache__/windows_utils.cpython-36.pycnu[PK!^  *__pycache__/constants.cpython-36.opt-1.pycnu[PK!Dԙԙ,__pycache__/base_events.cpython-36.opt-1.pycnu[PK![!D,__pycache__/compat.cpython-36.pycnu[PK!a0&/__pycache__/base_events.cpython-36.pycnu[PK!|-__pycache__/base_futures.cpython-36.opt-2.pycnu[PK!F { {,__pycache__/base_events.cpython-36.opt-2.pycnu[PK!UW4=$=$*M__pycache__/base_subprocess.cpython-36.pycnu[PK!(pMM"q__pycache__/streams.cpython-36.pycnu[PK!c""&ۿ__pycache__/locks.cpython-36.opt-2.pycnu[PK! VC !__pycache__/queues.cpython-36.pycnu[PK!;+jwjw&: __pycache__/unix_events.cpython-36.pycnu[PK!]TT%{ __pycache__/base_tasks.cpython-36.pycnu[PK!{(+/+/% __pycache__/transports.cpython-36.pycnu[PK!X޷%# __pycache__/subprocess.cpython-36.pycnu[PK!~ߦw!w!%/ __pycache__/coroutines.cpython-36.pycnu[PK!4OO# __pycache__/sslproto.cpython-36.pycnu[PK!D'?!__pycache__/base_futures.cpython-36.pycnu[PK!  A A09H!__pycache__/proactor_events.cpython-36.opt-1.pycnu[PK!`hh*!__pycache__/protocols.cpython-36.opt-1.pycnu[PK! NkTT/g!__pycache__/windows_events.cpython-36.opt-1.pycnu[PK!_قJ'!__pycache__/queues.cpython-36.opt-2.pycnu[PK!g}rbb' "__pycache__/events.cpython-36.opt-1.pycnu[PK!#m}LL+n"__pycache__/base_tasks.cpython-36.opt-2.pycnu[PK!(iv"__pycache__/futures.cpython-36.opt-2.pycnu[PK! NkTT)"__pycache__/windows_events.cpython-36.pycnu[PK!ݸBa)"__pycache__/__init__.cpython-36.opt-1.pycnu[PK!t44)h"__pycache__/sslproto.cpython-36.opt-2.pycnu[PK!D- #__pycache__/base_futures.cpython-36.opt-1.pycnu[PK!4X##02)#__pycache__/base_subprocess.cpython-36.opt-1.pycnu[PK!h{DD'oM#__pycache__/events.cpython-36.opt-2.pycnu[PK!wll'Ē#__pycache__/compat.cpython-36.opt-2.pycnu[PK!lOO/#__pycache__/windows_events.cpython-36.opt-2.pycnu[PK!aFss*#__pycache__/selector_events.cpython-36.pycnu[PK!L+sY$__pycache__/transports.cpython-36.opt-2.pycnu[PK!pCP r$compat.pynu[PK!zd88 :u$test_utils.pynu[PK!3cc):$__pycache__/__init__.cpython-35.opt-1.pycnu[PK!b*$__pycache__/selector_events.cpython-35.pycnu[PK!5&&(1%__pycache__/futures.cpython-35.opt-2.pycnu[PK!6QQ";X%__pycache__/streams.cpython-35.pycnu[PK!"q??".%__pycache__/futures.cpython-35.pycnu[PK!Ek@@0%__pycache__/selector_events.cpython-35.opt-1.pycnu[PK!fJ'J'*=i&__pycache__/base_subprocess.cpython-35.pycnu[PK!+4%4%&&__pycache__/locks.cpython-35.opt-2.pycnu[PK! .k&__pycache__/windows_utils.cpython-35.opt-1.pycnu[PK!c&j&__pycache__/unix_events.cpython-35.pycnu[PK!浀8oo,}M'__pycache__/unix_events.cpython-35.opt-2.pycnu[PK!Vv1&q'__pycache__/base_events.cpython-35.pycnu[PK!/>>'`(__pycache__/queues.cpython-35.opt-2.pycnu[PK!sHH'x(__pycache__/events.cpython-35.opt-2.pycnu[PK!Ѥ*(__pycache__/protocols.cpython-35.opt-1.pycnu[PK!|sCC0(__pycache__/proactor_events.cpython-35.opt-2.pycnu[PK!Ƿ00%)__pycache__/transports.cpython-35.pycnu[PK!m>e'M)__pycache__/compat.cpython-35.opt-2.pycnu[PK!wS8S8&P)__pycache__/tasks.cpython-35.opt-2.pycnu[PK!_~r88+)__pycache__/subprocess.cpython-35.opt-1.pycnu[PK!&>>(%)__pycache__/futures.cpython-35.opt-1.pycnu[PK!3cc#~)__pycache__/__init__.cpython-35.pycnu[PK!X(4)__pycache__/windows_utils.cpython-35.pycnu[PK!0ѬTT#*__pycache__/sslproto.cpython-35.pycnu[PK!ٕZeZe'U*__pycache__/events.cpython-35.opt-1.pycnu[PK!8ɣ,N*__pycache__/base_events.cpython-35.opt-1.pycnu[PK!\7kwFwF*M]+__pycache__/proactor_events.cpython-35.pycnu[PK!99)+__pycache__/sslproto.cpython-35.opt-2.pycnu[PK!J,y+__pycache__/base_events.cpython-35.opt-2.pycnu[PK!n *a,__pycache__/protocols.cpython-35.opt-2.pycnu[PK!qG'-k,__pycache__/compat.cpython-35.opt-1.pycnu[PK!ߟ!!)n,__pycache__/__init__.cpython-35.opt-2.pycnu[PK!7&&0r,__pycache__/base_subprocess.cpython-35.opt-1.pycnu[PK!r,6$E,__pycache__/log.cpython-35.opt-1.pycnu[PK!x$,__pycache__/constants.cpython-35.pycnu[PK!SS)ӛ,__pycache__/sslproto.cpython-35.opt-1.pycnu[PK!x(@(@+,__pycache__/test_utils.cpython-35.opt-2.pycnu[PK!cz=$k0-__pycache__/log.cpython-35.opt-2.pycnu[PK!,F*1-__pycache__/constants.cpython-35.opt-2.pycnu[PK!")+2-__pycache__/transports.cpython-35.opt-2.pycnu[PK!G9g""!M-__pycache__/queues.cpython-35.pycnu[PK!< y("("+dp-__pycache__/coroutines.cpython-35.opt-2.pycnu[PK!WEE0-__pycache__/proactor_events.cpython-35.opt-1.pycnu[PK!;SrZrZ/-__pycache__/windows_events.cpython-35.opt-1.pycnu[PK! 1ee!3.__pycache__/events.cpython-35.pycnu[PK!H@tn77(̙.__pycache__/streams.cpython-35.opt-2.pycnu[PK!(>>&.__pycache__/locks.cpython-35.opt-1.pycnu[PK!-FF% /__pycache__/test_utils.cpython-35.pycnu[PK!_##+@X/__pycache__/coroutines.cpython-35.opt-1.pycnu[PK!_HEHE+{/__pycache__/test_utils.cpython-35.opt-1.pycnu[PK!̔VV/V/__pycache__/windows_events.cpython-35.opt-2.pycnu[PK!(>> 0__pycache__/locks.cpython-35.pycnu[PK!2q##%V0__pycache__/coroutines.cpython-35.pycnu[PK!]00+1__pycache__/transports.cpython-35.opt-1.pycnu[PK!