| Server IP : 217.160.0.135 / Your IP : 216.73.217.37 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/zmq/eventloop/minitornado/__pycache__/ |
Upload File : |
�
mc�c�� � �� � d Z ddlmZmZmZmZ ddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZmZ ddlmZmZ ddlmZ ddlmZmZmZ ddl Z n
# e!$ r dZ Y nw xY w ddl"Z"n# e!$ r ddl#Z"Y nw xY wdd l$m%Z%m&Z& d
Z' G d� de(� � Z) G d
� de� � Z* G d� de*� � Z+ G d� de,� � Z- G d� 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 � � e Zd ZdS )�TimeoutErrorN)�__name__�
__module__�__qualname__� � �B/usr/lib/python3/dist-packages/zmq/eventloop/minitornado/ioloop.pyr r C s � � � � � ��Dr r c �� � e Zd ZdZdZdZdZdZdZdZ dZ
d Zd
ZeZ
eZeez Z ej � � Z ej � � Zed� � � Zed� � � Zd
� Zed� � � Zed0d�� � Zd� Zed� � � Zed� � � Zed� � � Zd1d�Z d2d�Z!d� Z"d� Z#d� Z$d� Z%d� Z&d� Z'd� Z(d � Z)d!� Z*d1d"�Z+d#� Z,d$� Z-d%� Z.d&� Z/d'� Z0d(� Z1d)� Z2d*� Z3d+� Z4d,� Z5d-� Z6d.� Z7d/� Z8dS )3�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 �� � t t d� � sQt j 5 t t d� � st � � t _ ddd� � n# 1 swxY w Y t j S )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 �instancezIOLoop.instance� s� � � �v�{�+�+� 0��&�
0�
0��v�{�3�3� 0�'-�x�x�F�$�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0� ��s �.A�A �#A c �, � t t d� � S )z8Returns true if the singleton instance has been created.r! )r"