Commit Graph

47 Commits

Author SHA1 Message Date
Kristján Valur Jónsson 6b53d5fe04
gh-112202: Ensure that condition.notify() succeeds even when racing with Task.cancel() (#112201)
Also did a general cleanup of asyncio locks.py comments and docstrings.
2024-02-03 08:19:37 -08:00
Kristján Valur Jónsson 52161781a6
GH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition.wait() (#111694)
Also fix a race condition in `asyncio.Semaphore.acquire()` when cancelled.
2024-01-08 11:57:48 -08:00
Cyker Way 68c46ae68b
gh-97545: Make Semaphore run faster. (#97549) 2022-09-26 16:38:00 -07:00
Cyker Way 24e0379624
gh-90155: Fix bug in asyncio.Semaphore and strengthen FIFO guarantee (#93222)
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.

The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
2022-09-22 09:34:45 -07:00
Victor Stinner 259dd71c32
gh-84623: Remove unused imports in stdlib (#93773) 2022-06-13 16:28:41 +02:00
Duprat d03acd7270
bpo-43352: Add a Barrier object in asyncio lib (GH-24903)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-26 00:01:21 +02:00
Andrew Svetlov 32e77154dd
bpo-45997: Fix asyncio.Semaphore re-acquiring order (GH-31910)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-22 16:02:51 +02:00
Serhiy Storchaka 195a46d6ff
bpo-46796: Simplify handling of removed parameter "loop" in asyncio (GH-31431) 2022-02-21 13:25:52 +02:00
Joongi Kim 1a7892414e
bpo-45416: Fix use of asyncio.Condition() with explicit Lock objects (GH-28850)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-10-10 19:01:41 +03:00
Yurii Karabas b9127dd6ee
bpo-42392: Improve removal of *loop* parameter in asyncio primitives (GH-23499)
* Update code after merge review from 1st1

* Use a sentinel approach for loop parameter
Remove unnecessary _get_running_loop patching

* Use more clear function name (_verify_parameter_is_marker -> _verify_no_loop)

* Add init method to _LoopBoundMixin to check that loop param wasn't used
2020-11-25 06:50:44 -05:00
Yurii Karabas 0ec34cab9d
bpo-42392: Remove loop parameter form asyncio locks and Queue (#23420)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2020-11-24 20:08:54 +02:00
Andrew Svetlov 90d9ba6ef1
bpo-34793: Drop old-style context managers in asyncio.locks (GH-17533) 2020-02-01 13:12:52 +02:00
Andrew Svetlov 7264e92b71 bpo-36373: Fix deprecation warnings (GH-15889)
https://bugs.python.org/issue36373
2019-09-11 01:20:24 -07:00
Emmanuel Arias 537877d85d bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [locks] (GH-13920)
This PR deprecate explicit loop parameters in all public asyncio APIs

This issues is split to be easier to review.

Third step: locks.py





https://bugs.python.org/issue36373
2019-09-10 03:55:07 -07:00
Zackery Spytz 9aa78566fb bpo-34767: Do not always create a collections.deque() in asyncio.Lock() (GH-13834)
https://bugs.python.org/issue34767
2019-06-05 02:33:26 -07:00
Andrew Svetlov 68b34a7204 bpo-36921: Deprecate @coroutine for sake of async def (GH-13346)
The second attempt. Now deprecate `@coroutine` only, keep `yield from fut` as is.


https://bugs.python.org/issue36921
2019-05-16 07:52:10 -07:00
Andrew Svetlov 0baa72f4b2
bpo-34622: Extract asyncio exceptions into a separate module (GH-9141) 2018-09-11 10:13:04 -07:00
Bar Harel 5746510b7a bpo-32841: Fix cancellation in awaiting asyncio.Condition (#5665) 2018-02-14 11:18:11 +02:00
Bar Harel 2f79c01493 bpo-32734: Fix asyncio.Lock multiple acquire safety issue (GH-5466) 2018-02-02 17:04:00 -05:00
Andrew Svetlov 8874342cf3
bpo-32258: Replace 'yield from' to 'await' in asyncio docs (#4779)
* Replace 'yield from' to 'await' in asyncio docs

* Fix docstrings
2017-12-11 17:35:49 +02:00
Yury Selivanov 6370f345e1
bpo-32262: Fix codestyle; use f-strings formatting where necessary. (#4775) 2017-12-10 18:36:12 -05:00
Andrew Svetlov 28d8d14013
bpo-32253: Deprecate with statement and bare await for asyncio locks (GH-4764)
* Add test for 'with (yield from lock)'
* Deprecate with statement for asyncio locks
* Document the deprecation
2017-12-09 20:00:05 +02:00
Andrew Svetlov 5f841b5538
bpo-32193: Convert asyncio to async/await usage (#4753)
* Convert asyncio/tasks.py to async/await

* Convert asyncio/queues.py to async/await

* Convert asyncio/test_utils.py to async/await

* Convert asyncio/base_subprocess.py to async/await

* Convert asyncio/subprocess.py to async/await

* Convert asyncio/streams.py to async/await

* Fix comments

* Convert asyncio/locks.py to async/await

* Convert asyncio.sleep to async def

* Add a comment

* Add missing news

* Convert stubs from AbstrctEventLoop to async functions

* Convert subprocess_shell/subprocess_exec

* Convert connect_read_pipe/connect_write_pip to async/await syntax

* Convert create_datagram_endpoint

* Convert create_unix_server/create_unix_connection

* Get rid of old style coroutines in unix_events.py

* Convert selector_events.py to async/await

* Convert wait_closed and create_connection

* Drop redundant line

* Convert base_events.py

* Code cleanup

* Drop redundant comments

* Fix indentation

* Add explicit tests for compatibility between old and new coroutines

* Convert windows event loop to use async/await

* Fix double awaiting of async function

* Convert asyncio/locks.py

* Improve docstring

* Convert tests to async/await

* Convert more tests

* Convert more tests

* Convert more tests

* Convert tests

* Improve test
2017-12-09 00:23:48 +02:00
Victor Stinner 3f438a9fa0
asyncio: Remove asyncio/compat.py (#4606)
The asyncio/compat.py file was written to support Python < 3.5 and
Python < 3.5.2. But Python 3.5 doesn't accept bugfixes anymore, only
security fixes. There is no more need to backport bugfixes to Python
3.5, and so no need to have a single code base for Python 3.5, 3.6
and 3.7.

Say hello (again) to "async" and "await", who became real keywords in
Python 3.7 ;-)
2017-11-28 14:43:52 +01:00
Mathieu Sornay 894a654a9c Fix waiter cancellation in asyncio.Lock (#1031)
Avoid a deadlock when the waiter who is about to take the lock is
cancelled

Issue #27585
2017-06-09 16:17:40 -04:00
Guido van Rossum 83f5a3846c In asyncio.locks.Lock.acquire(): Avoid deadlock when a cancelled future is in self._waiters. 2016-08-23 09:39:03 -07:00
Yury Selivanov c92bf83a82 Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait.
Patch by David Coles.
2016-06-11 12:00:07 -04:00
Martin Panter 3ee6270262 Fix typos in code comment and documentation 2016-06-04 04:57:19 +00:00
Yury Selivanov 7661db6228 Issue #27041: asyncio: Add loop.create_future method 2016-05-16 15:38:39 -04:00
Guido van Rossum d455a50773 Also rewrote the guts of asyncio.Semaphore (patch by manipopopo). 2015-09-29 11:54:45 -07:00
Victor Stinner eaf16abc68 asyncio: sync with github
* Fix ResourceWarning warnings in test_streams
* Return True from StreamReader.eof_received() to fix
  http://bugs.python.org/issue24539 (but still needs a unittest).
  Add StreamReader.__repr__() for easy debugging.
* remove unused imports
* Issue #234: Drop JoinableQueue on Python 3.5+
2015-07-25 02:40:40 +02:00
Victor Stinner 71080fc351 asyncio: Add asyncio.compat module
Move compatibility helpers for the different Python versions to a new
asyncio.compat module.
2015-07-25 02:23:21 +02:00
Yury Selivanov d08c363c26 Sync asyncio code from default branch. 2015-05-13 15:15:56 -04:00
Victor Stinner d6dc7bdaf9 Issue #23456: Add missing @coroutine decorators in asyncio 2015-03-18 11:37:42 +01:00
Serhiy Storchaka 148679982f Issue #22369: Change "context manager protocol" to "context management protocol". 2014-09-10 23:43:41 +03:00
Andrew Svetlov f21fcd09c5 Accept optional lock object in Condition ctor (tulip issue #198) 2014-07-26 17:54:34 +03:00
Victor Stinner f951d28ac8 asyncio: sync with Tulip, add a new asyncio.coroutines module 2014-06-29 00:46:45 +02:00
Guido van Rossum ab3c88983b asyncio: Locks refactor: use a separate context manager; remove Semaphore._locked. 2014-01-25 16:51:57 -08:00
Guido van Rossum 2407f3bb1b asyncio: Don't special-case GeneratorExit in Condition.wait(). 2014-01-10 13:25:38 -08:00
Guido van Rossum 994bf4332f Shorten lines. 2013-12-19 12:47:38 -08:00
Victor Stinner 10a8e6ab7b asyncio: replace our with asynchronous in docstring 2013-12-02 14:31:43 +01:00
Victor Stinner c37dd614b6 asyncio: document locks 2013-12-02 14:31:16 +01:00
Guido van Rossum a58d1c32f8 asyncio: Add BoundedSemaphore to export list in locks.__all__. 2013-11-24 22:32:09 -08:00
Guido van Rossum 085869bfee asyncio: Change bounded semaphore into a subclass, like threading.[Bounded]Semaphore. 2013-11-23 15:09:16 -08:00
Guido van Rossum 9c55a58a1d asyncio: Make Semaphore(0) work properly. 2013-11-21 11:07:45 -08:00
Guido van Rossum ccea08462b asyncio: Locks improvements by Arnaud Faure: better repr(), change Conditio\
n structure.
2013-11-04 13:18:19 -08:00
Guido van Rossum 27b7c7ebf1 Initial checkin of asyncio package (== Tulip, == PEP 3156). 2013-10-17 13:40:50 -07:00