💾 Archived View for tris.fyi › pydoc › asyncio.events captured on 2022-07-16 at 15:02:43. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-01-08)
-=-=-=-=-=-=-
Event loop and event loop policy.
Abstract event loop.
add_reader(self, fd, callback, *args)
add_signal_handler(self, sig, callback, *args)
add_writer(self, fd, callback, *args)
call_at(self, when, callback, *args, context=None)
call_exception_handler(self, context)
call_later(self, delay, callback, *args, context=None)
call_soon(self, callback, *args, context=None)
call_soon_threadsafe(self, callback, *args, context=None)
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.
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.
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.
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, ssl_handshake_timeout=None, happy_eyeballs_delay=None, interleave=None)
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, 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.
create_future(self)
create_server(self, protocol_factory, host=None, port=None, *, family=<AddressFamily.AF_UNSPEC: 0>, flags=<AddressInfo.AI_PASSIVE: 1>, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, start_serving=True) 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. 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.
create_task(self, coro, *, name=None)
create_unix_connection(self, protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None)
create_unix_server(self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None, start_serving=True) 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 system 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.
default_exception_handler(self, context)
get_debug(self)
get_exception_handler(self)
get_task_factory(self)
getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0)
getnameinfo(self, sockaddr, flags=0)
is_closed(self) Returns True if the event loop was closed.
is_running(self) Return whether the event loop is currently running.
remove_reader(self, fd)
remove_signal_handler(self, sig)
remove_writer(self, fd)
run_forever(self) Run the event loop until stop() is called.
run_in_executor(self, executor, func, *args)
run_until_complete(self, future) Run the event loop until a Future is done. Return the Future's result, or raise its exception.
sendfile(self, transport, file, offset=0, count=None, *, fallback=True) Send a file through a transport. Return an amount of sent bytes.
set_debug(self, enabled)
set_default_executor(self, executor)
set_exception_handler(self, handler)
set_task_factory(self, factory)
shutdown_asyncgens(self) Shutdown all active asynchronous generators.
shutdown_default_executor(self) Schedule the shutdown of the default executor.
sock_accept(self, sock)
sock_connect(self, sock, address)
sock_recv(self, sock, nbytes)
sock_recv_into(self, sock, buf)
sock_sendall(self, sock, data)
sock_sendfile(self, sock, file, offset=0, count=None, *, fallback=None)
start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None) Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately.
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.
subprocess_exec(self, protocol_factory, *args, stdin=-1, stdout=-1, stderr=-1, **kwargs)
subprocess_shell(self, protocol_factory, cmd, *, stdin=-1, stdout=-1, stderr=-1, **kwargs)
time(self)
Abstract policy for accessing the event loop.
get_child_watcher(self) Get the watcher for child processes.
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.
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.
set_child_watcher(self, watcher) Set the watcher for child processes.
set_event_loop(self, loop) Set the event loop for the current context to loop.
Abstract server returned by create_server().
close(self) Stop serving. This leaves existing connections open.
get_loop(self) Get the event loop the Server object is attached to.
is_serving(self) Return True if the server is accepting connections.
serve_forever(self) Start accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled.
start_serving(self) Start accepting connections. This method is idempotent, so it can be called when the server is already being serving.
wait_closed(self) Coroutine to wait until service is closed.
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).
get_child_watcher(self) Get the watcher for child processes.
get_event_loop(self) Get the event loop for the current context. Returns an instance of EventLoop or raises an exception.
new_event_loop(self) Create a new event loop. You must call set_event_loop() to make this the current event loop.
set_child_watcher(self, watcher) Set the watcher for child processes.
set_event_loop(self, loop) Set the event loop.
Object returned by callback registration methods.
cancel(self)
cancelled(self)
Object returned by timed callback registration methods.
cancel(self)
cancelled(self)
when(self) Return a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time().
get_child_watcher() Equivalent to calling get_event_loop_policy().get_child_watcher().
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.
get_event_loop_policy() Get the current event loop policy.
get_running_loop() Return the running event loop. Raise a RuntimeError if there is none. This function is thread-specific.
new_event_loop() Equivalent to calling get_event_loop_policy().new_event_loop().
set_child_watcher(watcher) Equivalent to calling get_event_loop_policy().set_child_watcher(watcher).
set_event_loop(loop) Equivalent to calling get_event_loop_policy().set_event_loop(loop).
set_event_loop_policy(policy) Set the current event loop policy. If policy is None, the default policy is restored.