Queue
=====
-.. class:: Queue(maxsize=0, \*, loop=None)
+.. class:: Queue(maxsize=0)
A first in, first out (FIFO) queue.
the queue is always known and can be returned by calling the
:meth:`qsize` method.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. coroutinefunction:: open_connection(host=None, port=None, \*, \
- loop=None, limit=None, ssl=None, family=0, \
- proto=0, flags=0, sock=None, local_addr=None, \
+ limit=None, ssl=None, family=0, proto=0, \
+ flags=0, sock=None, local_addr=None, \
server_hostname=None, ssl_handshake_timeout=None)
Establish a network connection and return a pair of
The returned *reader* and *writer* objects are instances of
:class:`StreamReader` and :class:`StreamWriter` classes.
- The *loop* argument is optional and can always be determined
- automatically when this function is awaited from a coroutine.
-
*limit* determines the buffer size limit used by the
returned :class:`StreamReader` instance. By default the *limit*
is set to 64 KiB.
The *ssl_handshake_timeout* parameter.
.. coroutinefunction:: start_server(client_connected_cb, host=None, \
- port=None, \*, loop=None, limit=None, \
+ port=None, \*, limit=None, \
family=socket.AF_UNSPEC, \
flags=socket.AI_PASSIVE, sock=None, \
backlog=100, ssl=None, reuse_address=None, \
:ref:`coroutine function <coroutine>`; if it is a coroutine function,
it will be automatically scheduled as a :class:`Task`.
- The *loop* argument is optional and can always be determined
- automatically when this method is awaited from a coroutine.
-
*limit* determines the buffer size limit used by the
returned :class:`StreamReader` instance. By default the *limit*
is set to 64 KiB.
.. rubric:: Unix Sockets
-.. coroutinefunction:: open_unix_connection(path=None, \*, loop=None, \
- limit=None, ssl=None, sock=None, \
- server_hostname=None, ssl_handshake_timeout=None)
+.. coroutinefunction:: open_unix_connection(path=None, \*, limit=None, \
+ ssl=None, sock=None, server_hostname=None, \
+ ssl_handshake_timeout=None)
Establish a Unix socket connection and return a pair of
``(reader, writer)``.
.. coroutinefunction:: start_unix_server(client_connected_cb, path=None, \
- \*, loop=None, limit=None, sock=None, \
- backlog=100, ssl=None, ssl_handshake_timeout=None, \
- start_serving=True)
+ \*, limit=None, sock=None, backlog=100, ssl=None, \
+ ssl_handshake_timeout=None, start_serving=True)
Start a Unix socket server.
=====================
.. coroutinefunction:: create_subprocess_exec(program, \*args, stdin=None, \
- stdout=None, stderr=None, loop=None, \
- limit=None, \*\*kwds)
+ stdout=None, stderr=None, limit=None, \*\*kwds)
Create a subprocess.
See the documentation of :meth:`loop.subprocess_exec` for other
parameters.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
.. coroutinefunction:: create_subprocess_shell(cmd, stdin=None, \
- stdout=None, stderr=None, loop=None, \
- limit=None, \*\*kwds)
+ stdout=None, stderr=None, limit=None, \*\*kwds)
Run the *cmd* shell command.
escape whitespace and special shell characters in strings that are going
to be used to construct shell commands.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
-
.. note::
Subprocesses are available for Windows if a :class:`ProactorEventLoop` is
Lock
====
-.. class:: Lock(\*, loop=None)
+.. class:: Lock()
Implements a mutex lock for asyncio tasks. Not thread-safe.
finally:
lock.release()
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. coroutinemethod:: acquire()
Acquire the lock.
Event
=====
-.. class:: Event(\*, loop=None)
+.. class:: Event()
An event object. Not thread-safe.
:meth:`clear` method. The :meth:`wait` method blocks until the
flag is set to *true*. The flag is set to *false* initially.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_sync_event:
Example::
Condition
=========
-.. class:: Condition(lock=None, \*, loop=None)
+.. class:: Condition(lock=None)
A Condition object. Not thread-safe.
``None``. In the latter case a new Lock object is created
automatically.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
The preferred way to use a Condition is an :keyword:`async with`
statement::
Semaphore
=========
-.. class:: Semaphore(value=1, \*, loop=None)
+.. class:: Semaphore(value=1)
A Semaphore object. Not thread-safe.
internal counter (``1`` by default). If the given value is
less than ``0`` a :exc:`ValueError` is raised.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
The preferred way to use a Semaphore is an :keyword:`async with`
statement::
BoundedSemaphore
================
-.. class:: BoundedSemaphore(value=1, \*, loop=None)
+.. class:: BoundedSemaphore(value=1)
A bounded semaphore object. Not thread-safe.
a :exc:`ValueError` in :meth:`~Semaphore.release` if it
increases the internal counter above the initial *value*.
-
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
---------
Sleeping
========
-.. coroutinefunction:: sleep(delay, result=None, \*, loop=None)
+.. coroutinefunction:: sleep(delay, result=None)
Block for *delay* seconds.
``sleep()`` always suspends the current task, allowing other tasks
to run.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_sleep:
Example of coroutine displaying the current date every second
Running Tasks Concurrently
==========================
-.. awaitablefunction:: gather(\*aws, loop=None, return_exceptions=False)
+.. awaitablefunction:: gather(\*aws, return_exceptions=False)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
sequence *concurrently*.
cancellation of one submitted Task/Future to cause other
Tasks/Futures to be cancelled.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_gather:
Example::
Shielding From Cancellation
===========================
-.. awaitablefunction:: shield(aw, \*, loop=None)
+.. awaitablefunction:: shield(aw)
Protect an :ref:`awaitable object <asyncio-awaitables>`
from being :meth:`cancelled <Task.cancel>`.
except CancelledError:
res = None
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
Timeouts
========
-.. coroutinefunction:: wait_for(aw, timeout, \*, loop=None)
+.. coroutinefunction:: wait_for(aw, timeout)
Wait for the *aw* :ref:`awaitable <asyncio-awaitables>`
to complete with a timeout.
If the wait is cancelled, the future *aw* is also cancelled.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
.. _asyncio_example_waitfor:
Example::
Waiting Primitives
==================
-.. coroutinefunction:: wait(aws, \*, loop=None, timeout=None,\
- return_when=ALL_COMPLETED)
+.. coroutinefunction:: wait(aws, \*, timeout=None, return_when=ALL_COMPLETED)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
iterable concurrently and block until the condition specified
``wait()`` directly is deprecated as it leads to
:ref:`confusing behavior <asyncio_example_wait_coroutine>`.
- .. deprecated-removed:: 3.8 3.10
-
- The *loop* parameter.
-
.. _asyncio_example_wait_coroutine:
.. note::
deprecated.
-.. function:: as_completed(aws, \*, loop=None, timeout=None)
+.. function:: as_completed(aws, \*, timeout=None)
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
iterable concurrently. Return an iterator of coroutines.
Raises :exc:`asyncio.TimeoutError` if the timeout occurs before
all Futures are done.
- .. deprecated-removed:: 3.8 3.10
- The *loop* parameter.
-
Example::
for coro in as_completed(aws):