Commit graph

678 commits

Author SHA1 Message Date
João Júnior 558c49bcf3 bpo-34728: Remove deprecate *loop* argument in asyncio.sleep (GH-9415)
* Insert the warn in the asyncio.sleep when the loop argument is used

* Insert the warn in the asyncio.wait and asyncio.wait_for when the loop argument is used

* Better format of the code

* Add news file

* change calls for get_event_loop() to calls for get_running_loop()

* Change message to be more clear in News

* Improve the comments in test_tasks
2018-09-24 05:51:22 -04:00
Andrew Svetlov 11194c877c
bpo-34666: Implement stream.awrite() and stream.aclose() (GH-9274) 2018-09-13 16:53:49 -07:00
Andrew Svetlov 0dd71807a9
bpo-34630: Skip logging SSL certificate errors by asyncio code (GH-9169) 2018-09-12 14:03:54 -07:00
Andrew Svetlov a5d1eb8d8b
bpo-34638: Store a weak reference to stream reader to break strong references loop (GH-9201)
Store a weak reference to stream readerfor breaking strong references

It breaks the strong reference loop between reader and protocol and allows to detect and close the socket if the stream is deleted (garbage collected)
2018-09-12 11:43:04 -07:00
Andrew Svetlov 0baa72f4b2
bpo-34622: Extract asyncio exceptions into a separate module (GH-9141) 2018-09-11 10:13:04 -07:00
Alex Grönholm cca4eec3c0 bpo-34270: Make it possible to name asyncio tasks (GH-8547)
Co-authored-by: Antti Haapala <antti.haapala@anttipatterns.com>
2018-08-08 17:06:47 -04:00
MartinAltmayer 944451cd8d bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) 2018-07-31 10:06:12 -04:00
twisteroid ambassador 9045199c5a bpo-33833: Fix ProactorSocketTransport AssertionError (#7893) 2018-07-30 21:58:50 +03:00
Elvis Pranskevichus 22d25085db bpo-34075: Deprecate non-ThreadPoolExecutor in loop.set_default_executor() (GH-8533)
Various asyncio internals expect that the default executor is a
`ThreadPoolExecutor`, so deprecate passing anything else to
`loop.set_default_executor()`.
2018-07-30 12:42:43 +02:00
Yury Selivanov d904c238ca
bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993) 2018-06-28 21:59:32 -04:00
Yury Selivanov 12f482e0ae
bpo-30805: Avoid race condition with debug logging (GH-7545)
Supersedes https://github.com/python/cpython/pull/2490
2018-06-08 18:24:37 -04:00
Victor Stinner ff6c077292
bpo-33694: Fix typo in helper function name (GH-7522)
_feed_data_to_bufferred_proto() renamed to
_feed_data_to_buffered_proto() ("bufferred" => "buffered").

Typo spotted by Nathaniel J. Smith.
2018-06-08 10:32:06 +02:00
Yury Selivanov 8f4042964d
bpo-33792: Add selector and proactor windows policies (GH-7487) 2018-06-07 20:44:57 -04:00
Victor Stinner 79790bc35f
bpo-33694: Fix race condition in asyncio proactor (GH-7498)
The cancellation of an overlapped WSARecv() has a race condition
which causes data loss because of the current implementation of
proactor in asyncio.

No longer cancel overlapped WSARecv() in _ProactorReadPipeTransport
to work around the race condition.

Remove the optimized recv_into() implementation to get simple
implementation of pause_reading() using the single _pending_data
attribute.

Move _feed_data_to_bufferred_proto() to protocols.py.

Remove set_protocol() method which became useless.
2018-06-08 00:25:52 +02:00
Yury Selivanov 415bc46a78
bpo-33769: start_tls: Fix error message; cancel callbacks on error (GH-7403)
In addition to that, mark SSLTransport as "closed" in its "abort()" method to prevent bogus warnings.
2018-06-05 08:59:58 -04:00
Yury Selivanov 9602643120
bpo-33734: asyncio/ssl: a bunch of bugfixes (#7321)
* Fix AttributeError (not all SSL exceptions have 'errno' attribute)

* Increase default handshake timeout from 10 to 60 seconds
* Make sure start_tls can be cancelled correctly
* Make sure any error in SSLProtocol gets propagated (instead of just being logged)
2018-06-04 11:32:35 -04:00
jhaydaman 0a28c0d12e bpo-33238: Add InvalidStateError to concurrent.futures. (GH-7056)
Future.set_result and Future.set_exception now raise InvalidStateError
if the futures are not pending or running. This mirrors the behavior
of asyncio.Future, and prevents AssertionErrors in asyncio.wrap_future
when set_result is called multiple times.
2018-05-30 10:15:06 +03:00
Yury Selivanov 99279ad823
Revert "bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208)" (#7232)
This reverts commit 5d97b7bcc1.
2018-05-29 20:47:56 -04:00
Elvis Pranskevichus e2b340ab41 bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)
Currently, asyncio.wait_for(fut), upon reaching the timeout deadline,
cancels the future and returns immediately.  This is problematic for
when *fut* is a Task, because it will be left running for an arbitrary
amount of time.  This behavior is iself surprising and may lead to
related bugs such as the one described in bpo-33638:

    condition = asyncio.Condition()
    async with condition:
        await asyncio.wait_for(condition.wait(), timeout=0.5)

Currently, instead of raising a TimeoutError, the above code will fail
with `RuntimeError: cannot wait on un-acquired lock`, because
`__aexit__` is reached _before_ `condition.wait()` finishes its
cancellation and re-acquires the condition lock.

To resolve this, make `wait_for` await for the task cancellation.
The tradeoff here is that the `timeout` promise may be broken if the
task decides to handle its cancellation in a slow way.  This represents
a behavior change and should probably not be back-patched to 3.6 and
earlier.
2018-05-29 17:31:01 -04:00
Yury Selivanov 863b674909
bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209) 2018-05-29 17:20:02 -04:00
Yury Selivanov 5d97b7bcc1
bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208)
Original patch by Dan O'Reilly.
2018-05-29 15:38:07 -04:00
Victor Stinner 9551f77192
bpo-33353: test_asyncio use set_write_buffer_limits() (GH-7200)
Use transport.set_write_buffer_limits() in sendfile tests of
test_asyncio to make sure that the protocol is paused after sending
4 KiB. Previously,
test_sendfile_fallback_close_peer_in_the_middle_of_receiving() failed
on FreeBSD if the DATA was smaller than the default limit of 64 KiB.
2018-05-29 16:02:07 +02:00
Yury Selivanov 2179022d94 bpo-33654: Support protocol type switching in SSLTransport.set_protocol() (#7194) 2018-05-29 12:02:40 +03:00
Yury Selivanov f295587c45
bpo-33674: Pause the transport as early as possible (#7192) 2018-05-29 01:00:12 -04:00
Victor Stinner be00a5583a
bpo-33674: asyncio: Fix SSLProtocol race (GH-7175)
Fix a race condition in SSLProtocol.connection_made() of
asyncio.sslproto: start immediately the handshake instead of using
call_soon(). Previously, data_received() could be called before the
handshake started, causing the handshake to hang or fail.
2018-05-29 01:33:35 +02:00
Yury Selivanov 7165754b6b
bpo-32410: Avoid blocking on file IO in sendfile fallback code (GH-7172) 2018-05-28 18:31:55 -04:00
Yury Selivanov 416c1ebd98
bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174) 2018-05-28 17:54:02 -04:00
Yury Selivanov fdccfe09f0
bpo-33469: RuntimeError after closing loop that used run_in_executor (GH-7171) 2018-05-28 17:10:20 -04:00
Yury Selivanov 989b9e0e6d
bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161) 2018-05-28 16:27:34 -04:00
Yury Selivanov dbf102271f
bpo-33654: Support BufferedProtocol in set_protocol() and start_tls() (GH-7130)
In this commit:

* Support BufferedProtocol in set_protocol() and start_tls()
* Fix proactor to cancel readers reliably
* Update tests to be compatible with OpenSSL 1.1.1
* Clarify BufferedProtocol docs
* Bump TLS tests timeouts to 60 seconds; eliminate possible race from start_serving
* Rewrite test_start_tls_server_1
2018-05-28 14:31:28 -04:00
jimmylai e549c4be5f bpo-33505: Optimize asyncio.ensure_future by reordering if conditions (GH-6836) 2018-05-28 12:42:05 -04:00
twisteroid ambassador 23f587e395 bpo-31647: Fix write_eof() after close() for SelectorSocketTransport (GH-7149)
Fixed bug where calling write_eof() on a _SelectorSocketTransport after
it's already closed raises AttributeError.
2018-05-28 11:16:45 -04:00
Vlad Starostin a84d0b361a bpo-33263: Fix FD leak in _SelectorSocketTransport (GH-6450)
* bpo-33263 Fix FD leak in _SelectorSocketTransport. (GH-6450)

Under particular circumstances _SelectorSocketTransport can try to add a reader
even the transport is already being closed. This can lead to FD leak and
invalid stated of the following connections. Fixed the SelectorSocketTransport
to add the reader only if the trasport is still active.
2018-05-21 11:13:45 +03:00
Christian Heimes d361e99868
bpo-32262: Fix typo in f-string (GH-7016)
Fix typo from commit 6370f345e1

Signed-off-by: Christian Heimes <christian@python.org>

<!--
Thanks for your contribution!
Please read this comment in its entirety. It's quite important.

# Pull Request title

It should be in the following format:

```
bpo-NNNN: Summary of the changes made
```

Where: bpo-NNNN refers to the issue number in the https://bugs.python.org.

Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue.

# Backport Pull Request title

If this is a backport PR (PR made against branches other than `master`),
please ensure that the PR title is in the following format:

```
[X.Y] <title from the original PR> (GH-NNNN)
```

Where: [X.Y] is the branch name, e.g. [3.6].

GH-NNNN refers to the PR number from `master`.

-->


<!-- issue-number: bpo-32262 -->
https://bugs.python.org/issue32262
<!-- /issue-number -->
2018-05-20 19:57:13 +02:00
Serhiy Storchaka 6655354afc
bpo-33584: Fix several minor bugs in asyncio. (GH-7003)
Fix the following bugs in the C implementation:

* get_future_loop() silenced all exceptions raised when look up the get_loop
  attribute, not just an AttributeError.
* enter_task() silenced all exceptions raised when look up the current task,
  not just a KeyError.
* repr() was called for a borrowed link in enter_task() and task_step_impl().
* str() was used instead of repr() in formatting one error message (in
  Python implementation too).
* There where few reference leaks in error cases.
2018-05-20 16:30:31 +03:00
CtrlZvi 4151061855 bpo-26819: Prevent proactor double read on resume (#6921)
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
2018-05-20 13:21:10 +03:00
Antoine Pitrou 9d3627e311
bpo-33332: Add signal.valid_signals() (GH-6581) 2018-05-04 13:00:50 +02:00
Serhiy Storchaka bac2d5ba30
Fix duplicating words words. (GH-6296)
Most of them have been added in 3.7.
2018-03-28 22:14:26 +03:00
Sam Dunster 65a34709f6 Fix senfile typo (#6265)
* Also in docs
2018-03-27 17:47:38 -07:00
Andrew Svetlov 5e80a71ab6
bpo-33037: Skip sending/receiving after SSL transport closing (GH-6044)
* Skip write()/data_received() if sslpipe is destroyed
2018-03-10 17:48:35 +02:00
Andrew Svetlov a19fb3c6aa
bpo-32622: Native sendfile on windows (#5565)
* Support sendfile on Windows Proactor event loop naively.
2018-02-25 19:32:14 +03: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 3d4dbd8f01
Implement TimerHandle.when() (#5473) 2018-02-01 19:59:32 +02:00
Yury Selivanov 07627e9a6a
bpo-32251: Fix docs (#5408) 2018-01-28 23:51:08 -05:00
Yury Selivanov 631fd38dbf
bpo-32251: Implement asyncio.BufferedProtocol. (#4755) 2018-01-28 16:30:26 -05:00
Yury Selivanov bec2372b7e
bpo-32327: Revert loop.run_in_executor behaviour: return a Future. (#5392)
I've run some tests on 3.7 asyncio and it appears that too many
things assume that run_in_executor returns a Future.
2018-01-28 14:09:40 -05:00
Yury Selivanov 2a2247ce5e
bpo-32622: Normalize ENOTCONN to ConnectionError on macOS (GH-5369)
On mac, sendfile throws ENOTCONN on a repeated sendfile call if
the connection is closed. Normalize it to behave like other systems.
2018-01-27 17:22:01 -05:00
Yury Selivanov b1a6ac4c40
bpo-32622: Enforce sendfile fallback policy for FALLBACK transports (#5364) 2018-01-27 15:52:52 -05:00
Andrew Svetlov 7c684073f9
bpo-32622: Implement loop.sendfile() (#5271) 2018-01-27 21:22:47 +02:00