Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/zmq/eventloop/minitornado/__pycache__/ioloop.cpython-39.pyc
Ðазад
a a�h�� � @ s� d Z ddlmZmZmZmZ ddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlZddlZddlZddlmZmZ ddlmZmZ ddlmZ ddlmZmZmZ zddl Z W n e!y� dZ Y n0 zddl"Z"W n e!�y ddl#Z"Y n0 dd l$m%Z%m&Z& d Z'G dd� de(�Z)G d d� de�Z*G dd� de*�Z+G dd� de,�Z-G dd� de,�Z.dS )a� An I/O event loop for non-blocking sockets. Typical applications will use a single `IOLoop` object, in the `IOLoop.instance` singleton. The `IOLoop.start` method should usually be called at the end of the ``main()`` function. Atypical applications may use more than one `IOLoop`, such as one `IOLoop` per thread, or per `unittest` case. In addition to I/O events, the `IOLoop` can also schedule time-based events. `IOLoop.add_timeout` is a non-blocking alternative to `time.sleep`. � )�absolute_import�division�print_function�with_statementN� )�TracebackFuture� is_future)�app_log�gen_log)� stack_context)�Configurable�errno_from_exception�timedelta_to_seconds)�set_close_exec�Wakerg �@c @ s e Zd ZdS )�TimeoutErrorN)�__name__� __module__�__qualname__� r r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/zmq/eventloop/minitornado/ioloop.pyr C s r c @ s� e Zd ZdZdZdZdZdZdZdZ dZ d Zd ZeZ eZeeB Ze�� Ze�� Zedd� �Zed d� �Zdd� Zedd� �ZedRdd��Zdd� Zedd� �Zedd� �Zedd� �ZdSdd �Z dTd"d#�Z!d$d%� Z"d&d'� Z#d(d)� Z$d*d+� Z%d,d-� Z&d.d/� Z'd0d1� Z(d2d3� Z)d4d5� Z*dUd6d7�Z+d8d9� Z,d:d;� Z-d<d=� Z.d>d?� Z/d@dA� Z0dBdC� Z1dDdE� Z2dFdG� Z3dHdI� Z4dJdK� Z5dLdM� Z6dNdO� Z7dPdQ� Z8dS )V�IOLoopa� A level-triggered I/O loop. We use ``epoll`` (Linux) or ``kqueue`` (BSD and Mac OS X) if they are available, or else we fall back on select(). If you are implementing a system that needs to handle thousands of simultaneous connections, you should use a system that supports either ``epoll`` or ``kqueue``. Example usage for a simple TCP server: .. testcode:: import errno import functools import tornado.ioloop import socket def connection_ready(sock, fd, events): while True: try: connection, address = sock.accept() except socket.error as e: if e.args[0] not in (errno.EWOULDBLOCK, errno.EAGAIN): raise return connection.setblocking(0) handle_connection(connection, address) if __name__ == '__main__': sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) sock.bind(("", port)) sock.listen(128) io_loop = tornado.ioloop.IOLoop.current() callback = functools.partial(connection_ready, sock) io_loop.add_handler(sock.fileno(), callback, io_loop.READ) io_loop.start() .. testoutput:: :hide: By default, a newly-constructed `IOLoop` becomes the thread's current `IOLoop`, unless there already is a current `IOLoop`. This behavior can be controlled with the ``make_current`` argument to the `IOLoop` constructor: if ``make_current=True``, the new `IOLoop` will always try to become current and it raises an error if there is already a current instance. If ``make_current=False``, the new `IOLoop` will not try to become current. .. versionchanged:: 4.2 Added the ``make_current`` keyword argument to the `IOLoop` constructor. r � � � � i i @l r c C sH t td�sBtj�" t td�s$t� t_W d � n1 s80 Y tjS )a1 Returns a global `IOLoop` instance. Most applications have a single, global `IOLoop` running on the main thread. Use this method to get this instance from another thread. In most other cases, it is better to use `current()` to get the current thread's `IOLoop`. � _instanceN)�hasattrr �_instance_lockr r r r r �instance� s &zIOLoop.instancec C s t td�S )z8Returns true if the singleton instance has been created.r )r r r r r r �initialized� s zIOLoop.initializedc C s t �� rJ �| t _dS )z�Installs this `IOLoop` object as the singleton instance. This is normally not necessary as `instance()` will create an `IOLoop` on demand, but you may want to call `install` to use a custom subclass of `IOLoop`. N)r r r ��selfr r r �install� s zIOLoop.installc C s t td�rt`dS )zKClear the global `IOLoop` instance. .. versionadded:: 4.0 r N)r r r r r r r �clear_instance� s zIOLoop.clear_instanceTc C s&