Commit Graph

484 Commits

Author SHA1 Message Date
Victor Stinner 2ba8ece5be asyncio: allow None as wait timeout
Fix GH#325: Allow to pass None as a timeout value to disable timeout logic.

Change written by Andrew Svetlov and merged by Guido van Rossum.
2016-04-01 21:39:09 +02:00
Yury Selivanov e076ffb068 asyncio: Remove duplicate bind addresses in create_server.
Patch by Sebastien Bourdeauducq (issue #26338)
2016-03-02 11:17:01 -05:00
Yury Selivanov 1bd030788d asyncio: Prevent StopIteration from being thrown into a Future
Patch by Chris Angelico (issue #26221)
2016-03-02 11:03:28 -05:00
Yury Selivanov dce63234c5 asyncio: Fix @coroutine to recognize CoroWrapper (issue #25647)
Patch by Vladimir Rutsky.
2016-03-02 10:49:16 -05:00
Yury Selivanov 0c6a34409e asyncio, selectors: Update to the upstream version 2016-03-02 10:37:59 -05:00
Serhiy Storchaka 94a619d48b Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
2016-02-11 13:11:44 +02:00
Victor Stinner 0df5313458 test_asyncio: fix test_timeout_time()
Accept time delta up to 0.12 second, instead of 0.11, for the "AMD64 FreeBSD
9.x" buildbot slave.
2016-02-01 12:39:50 +01:00
Gregory P. Smith a3a58331a5 Make the error message regex more lenient so that it matches both
"certificate verify failed " and "CERTIFICATE_VERIFY_FAILED " as
some SSL libraries use different text than OpenSSL.
2016-01-15 17:30:24 -08:00
Gregory P. Smith c7b05a409d Make the error message regex more lenient so that it matches both
"certificate verify failed " and "CERTIFICATE_VERIFY_FAILED " as
some SSL libraries use different text than OpenSSL.
2016-01-15 17:29:45 -08:00
Yury Selivanov b4b8a0ef3e Merge 3.4 (Issue #26050) 2016-01-11 12:30:56 -05:00
Yury Selivanov d9d0e864b9 Issue #26050: Add asyncio.StreamReader.readuntil() method.
Patch by Марк Коренберг.
2016-01-11 12:28:19 -05:00
Andrew Svetlov b86abb79aa merge 3.4 2016-01-11 09:09:10 +02:00
Andrew Svetlov c07b16b40f Sync with asyncio repo 2016-01-11 08:42:49 +02:00
Yury Selivanov c4e27e277c Merge 3.4 2015-12-16 20:41:25 -05:00
Yury Selivanov ea4ce1c776 asyncio/tests: Fix a ResourceWarning due to unclosed loop 2015-12-16 20:41:11 -05:00
Yury Selivanov 152c408ed6 Merge 3.4 2015-12-16 20:23:37 -05:00
Yury Selivanov 3cd863c86e asyncio/tests: Fix ResourceWarnings related to unclosed transports 2015-12-16 20:23:26 -05:00
Yury Selivanov bcf8afd015 Merge 3.4 2015-12-16 19:51:19 -05:00
Yury Selivanov 5f68ca66bf asyncio/tests: Fix some ResourceWarnings 2015-12-16 19:51:09 -05:00
Yury Selivanov e277a3dc51 Merge 3.4 2015-12-16 19:40:11 -05:00
Yury Selivanov aa78adc589 asyncio/tests: Fix deprecation warning 2015-12-16 19:40:03 -05:00
Yury Selivanov a3f82bad16 Merge 3.4 2015-12-16 19:35:39 -05:00
Yury Selivanov ec45226eeb Normalize whitespace 2015-12-16 19:35:30 -05:00
Yury Selivanov 631546cf92 Merge 3.4 2015-12-16 19:31:40 -05:00
Yury Selivanov d5c2a62100 asyncio: Skip getaddrinfo if host is already resolved.
getaddrinfo takes an exclusive lock on some platforms, causing clients to queue
up waiting for the lock if many names are being resolved concurrently. Users
may want to handle name resolution in their own code, for the sake of caching,
using an alternate resolver, or to measure DNS duration separately from
connection duration. Skip getaddrinfo if the "host" passed into
create_connection is already resolved.

See https://github.com/python/asyncio/pull/302 for details.

Patch by A. Jesse Jiryu Davis.
2015-12-16 19:31:17 -05:00
Guido van Rossum 1a316e82f6 Sync asyncio with upstream git repo (conditional import in test_pep492.py). 2015-12-12 17:01:47 -08:00
Yury Selivanov d3ded40a53 Merge 3.4 2015-12-11 11:34:11 -05:00
Yury Selivanov 0ac3a0cd79 asyncio: Make Tasks check if Futures are attached to the same event loop
See https://github.com/python/asyncio/pull/303 for details
2015-12-11 11:33:59 -05:00
Yury Selivanov 7888e67027 Merge 3.4 2015-12-11 11:33:08 -05:00
Yury Selivanov dddc781998 asyncio: Sync with github 2015-12-11 11:32:59 -05:00
Yury Selivanov 0f3c9765d4 asyncio: Fix with github
See https://github.com/python/asyncio/pull/295 for details
2015-11-20 12:57:34 -05:00
Yury Selivanov a211a7a0e7 asyncio.tests: Fix whitespace 2015-11-20 12:43:52 -05:00
Yury Selivanov b485bb416c asyncio: Sync with github 2015-11-20 12:39:43 -05:00
Yury Selivanov 875e4fbcca Merge 3.4 2015-11-20 12:57:47 -05:00
Yury Selivanov e342b8e8fe Merge 3.4 2015-11-20 12:44:03 -05:00
Yury Selivanov abe61079de Merge 3.4 2015-11-20 12:39:51 -05:00
Guido van Rossum 82f9feaf10 Issue #25593: Change semantics of EventLoop.stop(). (Merge 3.4->3.5) 2015-11-19 13:33:34 -08:00
Guido van Rossum 41f69f4cc7 Issue #25593: Change semantics of EventLoop.stop(). 2015-11-19 13:28:47 -08:00
Yury Selivanov 576fe71c12 asyncio: Error if awaiting in parallel on the same coroutine
See https://github.com/python/asyncio/pull/293 for details.
2015-11-18 12:40:26 -05:00
Yury Selivanov 5498f2b6bf Merge 3.4 2015-11-17 12:20:02 -05:00
Yury Selivanov 5d7e3b6cd2 asyncio: Cleanup Future API
See https://github.com/python/asyncio/pull/292 for details.
2015-11-17 12:19:41 -05:00
Yury Selivanov 1334f83de2 Merge 3.4 2015-11-16 12:43:35 -05:00
Yury Selivanov 5bb1afb332 asyncio: Add Transport.is_closing()
See https://github.com/python/asyncio/pull/291 for details.
2015-11-16 12:43:21 -05:00
Yury Selivanov c73771afd8 Merge 3.4 2015-11-13 12:29:03 -05:00
Yury Selivanov abe9625eeb asyncio: Fix sporadic failing unittests in debug mode 2015-11-13 12:28:48 -05:00
Yury Selivanov 7931be403d Merge 3.4 2015-11-05 14:29:19 -05:00
Yury Selivanov ade0412613 asyncio: Optimize asyncio.sleep(0) 2015-11-05 14:29:04 -05:00
Guido van Rossum 25c578d0a6 Fix whitespace. 2015-10-19 12:00:25 -07:00
Guido van Rossum 06d48dbea8 Fix whitespace. 2015-10-19 12:00:04 -07:00
Guido van Rossum 030f489df7 Issue #25441: asyncio: Raise error from drain() when socket is closed. (Merge 3.4->3.5) 2015-10-19 11:54:04 -07:00
Guido van Rossum c44ecdf687 Issue #25441: asyncio: Raise error from drain() when socket is closed. 2015-10-19 11:49:30 -07:00
Guido van Rossum 609081186d Issue #23972: Fix tests for Windows and Debian. (Merge 3.4->3.5) 2015-10-06 08:24:44 -07:00
Guido van Rossum 36bbd0f239 Issue #23972: Fix tests for Windows and Debian. 2015-10-06 08:24:10 -07:00
Guido van Rossum 5db034acfa Docs and one small improvement for issue #25304, by Vincent Michel. (Merge 3.4->3.5.) 2015-10-05 16:23:13 -07:00
Guido van Rossum 601953b679 Docs and one small improvement for issue #25304, by Vincent Michel. 2015-10-05 16:20:00 -07:00
Guido van Rossum eda1955d82 Issue #23972: updates to asyncio datagram API. By Chris Laws. (Merge 3.4->3.5.) 2015-10-05 09:19:11 -07:00
Guido van Rossum b9bf913ab3 Issue #23972: updates to asyncio datagram API. By Chris Laws. 2015-10-05 09:15:28 -07:00
Guido van Rossum 0d9bef927b Issue #25304: Add asyncio.run_coroutine_threadsafe(). By Vincent Michel. (Merge 3.4->3.5.) 2015-10-03 08:34:34 -07:00
Guido van Rossum 841d9ee41a Issue #25304: Add asyncio.run_coroutine_threadsafe(). By Vincent Michel. 2015-10-03 08:31:42 -07:00
Yury Selivanov 43d71e2512 asyncio: Make ensure_future() accept all kinds of awaitables. 2015-10-02 15:05:59 -04:00
Yury Selivanov 620279b9ac asyncio: ensure_future() now understands awaitables 2015-10-02 15:00:19 -04:00
Guido van Rossum 28d982dfc5 Also rewrote the guts of asyncio.Semaphore (patch by manipopopo). (Merge 3.4->3.5.) 2015-09-29 12:00:01 -07:00
Guido van Rossum d455a50773 Also rewrote the guts of asyncio.Semaphore (patch by manipopopo). 2015-09-29 11:54:45 -07:00
Andrew Svetlov e4be3c2597 Merge 3.4 -> 3.5 2015-09-29 18:36:44 +03:00
Andrew Svetlov d94c1b92ed Fix StreamReader.__repr__ 2015-09-29 18:36:00 +03:00
Guido van Rossum d2f184652c Issue #25233: Rewrite the guts of Queue to be more understandable and correct. (Merge 3.4->3.5.) 2015-09-28 07:44:49 -07:00
Guido van Rossum 99f96c5451 Issue #25233: Rewrite the guts of Queue to be more understandable and correct. 2015-09-28 07:42:34 -07:00
Victor Stinner e355604447 Merge 3.4 (Issue #23630, fix test_asyncio) 2015-09-21 22:29:30 +02:00
Victor Stinner 582b17c2c5 Issue #23630: Fix test_asyncio on Windows
The proactor event loop requires also to mock loop._stop_serving.
2015-09-21 22:28:44 +02:00
Victor Stinner e63f1a65ed Merge 3.4 (test_asyncio) 2015-09-21 22:20:36 +02:00
Victor Stinner 72e1eae7bb Issue #25114: Fix test_asyncio
ssl.SSLContext() does not always disable compression. Fix unit test.
2015-09-21 22:20:19 +02:00
Victor Stinner 7b58a2bb1d Merge 3.4 (asyncio) 2015-09-21 18:41:05 +02:00
Victor Stinner 5e4a7d8dc7 Issue #23630, asyncio: host parameter of loop.create_server() can now be a
sequence of strings. Patch written by Yann Sionneau.
2015-09-21 18:33:43 +02:00
Victor Stinner d1fcca8ada Merge 3.4 (asyncio) 2015-09-21 18:08:06 +02:00
Victor Stinner f7dc7fb74d Issue #25114, asyncio: add ssl_object extra info to SSL transports
This info is required on Python 3.5 and newer to get specific information on
the SSL object, like getting the binary peer certificate (instead of getting
it as text).
2015-09-21 18:06:17 +02:00
Yury Selivanov 7ca6c55a4e Issue #24867: Fix asyncio.Task.get_stack() for 'async def' coroutines 2015-08-17 14:46:51 -04:00
Yury Selivanov 233983380d Issue #24867: Fix Task.get_stack() for 'async def' coroutines 2015-08-14 15:30:59 -04:00
Yury Selivanov 131426ebe3 Merge 3.4 (issues #24835, #24763) 2015-08-09 18:21:58 -04:00
Yury Selivanov 9632ea2f26 Issue #24763: Fix asyncio test on Windows (fix reverted change)
See also issue #24835
2015-08-09 18:21:25 -04:00
Yury Selivanov 159fbdd805 Issue #23812: Fix getter-cancellation with many pending getters code path 2015-08-06 14:03:38 -04:00
Yury Selivanov 3fc0f2d288 Issue #23812: Fix asyncio.Queue.get() to avoid loosing items on cancellation.
Patch by Gustavo J. A. M. Carneiro.
2015-08-05 13:52:33 -04:00
Yury Selivanov 2a8911c0b7 asyncio: Sync with upstream (compat module) 2015-08-04 15:56:33 -04:00
Victor Stinner 9a82bd45cd Issue #24763: Fix asyncio test on Windows 2015-07-31 23:36:00 +02:00
Victor Stinner 6fb1e740c6 Fix ResourceWarning in asyncio.BaseSubprocessTransport
Issue #24763: Fix resource warnings when asyncio.BaseSubprocessTransport
constructor fails, if subprocess.Popen raises an exception for example.

Patch written by Martin Richard, test written by me.
2015-07-31 17:49:43 +02: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
Yury Selivanov e03f42717c Merge 3.4 (issue #23812) 2015-08-06 14:04:12 -04:00
Yury Selivanov 6d0c4c38d1 asyncio.test_pep492: Add a test for asyncio.iscoroutinefunction 2015-08-05 14:47:33 -04:00
Yury Selivanov 22506d24ee Issue #23812: Fix asyncio.Queue.get() to avoid loosing items on cancellation.
Patch by Gustavo J. A. M. Carneiro.
2015-08-05 13:55:54 -04:00
Yury Selivanov 78c89eb0ac Merge 3.4 2015-08-04 15:56:53 -04:00
Victor Stinner a0a28b076a Merge 3.4 (asyncio test) 2015-07-31 23:36:15 +02:00
Victor Stinner a7a4c41411 Merge 3.4 (asyncio) 2015-07-31 17:50:13 +02:00
Victor Stinner 389e3d768d Merge 3.4 2015-07-25 02:43:31 +02:00
Victor Stinner fb578f0a05 Merge 3.4 (asyncio) 2015-07-09 23:14:50 +02:00
Victor Stinner e6ecea53c8 asyncio: sync with github asyncio
* queues: get coroutine from asyncio.coroutines, not from asyncio.tasks
* tets: replace tulip with asyncio in comments
2015-07-09 23:13:50 +02:00
Yury Selivanov 00e3372358 Issue #24325, #24400: Add more unittests for types.coroutine; tweak wrapper implementation. 2015-06-24 11:44:51 -04:00
Yury Selivanov fcba97242b Issue #24495, #24400: Test asyncio.Task.repr in debug mode 2015-06-24 10:55:12 -04:00
Yury Selivanov 5ac716251f Fix asyncio unittests in debug mode 2015-06-24 10:47:44 -04:00
Yury Selivanov 8f1c99321b Issue #24400: Fix CoroWrapper for 'async def' coroutines 2015-06-24 10:32:22 -04:00
Yury Selivanov 29a602a140 Issue #24400: Fix CoroWrapper for 'async def' coroutines 2015-06-24 10:30:14 -04:00
Yury Selivanov e42cc38639 Issue 24017: Add a test for CoroWrapper and 'async def' coroutines 2015-05-31 21:44:05 -04:00
Yury Selivanov 439c5fe3ae Issue 24004: Fix DeprecationWarning in a unittest 2015-05-31 11:28:35 -04:00
Yury Selivanov ad583a8e6d Issue 24004: Add a unittest for @asyncio.coroutine supporting Awaitables 2015-05-30 21:04:37 -04:00
Yury Selivanov 56fc614025 Issue 24315: Make collections.abc.Coroutine derived from Awaitable 2015-05-29 09:01:29 -04:00
Yury Selivanov c41632a856 asyncio/tests: Drop unused import. 2015-05-13 15:37:48 -04:00
Yury Selivanov 6c792bd65a asyncio: Add a test for asyncio.iscoroutine().
Test that asyncio.iscoroutine() supports 'async def' coroutines and
collections.abc.Coroutine types.
2015-05-13 15:34:12 -04:00
Yury Selivanov 33c6b569b7 Issue 24179: Support 'async for' for asyncio.StreamReader. 2015-05-13 14:23:29 -04:00
Yury Selivanov 29f88c22e6 Issue 24178: support 'async with' for asyncio locks. 2015-05-13 14:10:38 -04:00
Yury Selivanov 1af2bf75a2 asyncio: Support PEP 492. Issue #24017. 2015-05-11 22:27:25 -04:00
Yury Selivanov 59eb9a4da5 asyncio: async() function is deprecated in favour of ensure_future(). 2015-05-11 14:48:38 -04:00
Yury Selivanov 740169cd24 Sync asyncio changes from the main repo. 2015-05-11 14:23:38 -04:00
Guido van Rossum 0a9933ebf3 Asyncio issue 222 / PR 231 (Victor Stinner) -- fix @coroutine functions without __name__. 2015-05-02 18:38:24 -07:00
Guido van Rossum 0bd16bc4cd Fix asyncio issue 235: Queue subclass bug caused by JoinableQueue merge. 2015-04-20 09:24:24 -07:00
Victor Stinner 79fd962652 asyncio: Fix _SelectorTransport.__repr__() if the event loop is closed 2015-03-27 15:20:08 +01:00
Victor Stinner e7a2f64435 asyncio: Fix warning in test_close_kill_running()
Read process exit status to avoid the "Caught subprocess termination from
unknown pid" message.
2015-02-17 23:36:02 +01:00
Victor Stinner 4088ad9dce Issue #23475, asyncio: Fix test_close_kill_running()
Really kill the child process, don't mock completly the Popen.kill() method.

This change fix memory leaks and reference leaks.
2015-02-17 22:54:11 +01:00
Victor Stinner 4cb814c7e1 asyncio, Tulip issue 220: Merge JoinableQueue with Queue.
Merge JoinableQueue with Queue. To more closely match the standard Queue,
asyncio.Queue has "join" and "task_done". JoinableQueue is deleted.

Docstring for Queue.join shouldn't mention threads.

Restore JoinableQueue as a deprecated alias for Queue. To more closely match
the standard Queue, asyncio.Queue has "join" and "task_done".  JoinableQueue
remains as a deprecated alias for Queue to avoid needlessly breaking too much
code that depended on it.

Patch written by A. Jesse Jiryu Davis <jesse@mongodb.com>.
2015-02-17 22:53:28 +01:00
Serhiy Storchaka 85c3033670 Use os.devnull instead of hardcoded '/dev/null'. 2015-02-15 13:58:23 +02:00
Victor Stinner 8e36812e27 asyncio: BaseSubprocessTransport.close() doesn't try to kill the process if it
already finished
2015-02-10 14:49:32 +01:00
Victor Stinner 2fc2313038 asyncio: Only call _check_resolved_address() in debug mode
* _check_resolved_address() is implemented with getaddrinfo() which is slow
* If available, use socket.inet_pton() instead of socket.getaddrinfo(), because
  it is much faster

Microbenchmark (timeit) on Fedora 21 (Python 3.4, Linux 3.17, glibc 2.20) to
validate the IPV4 address "127.0.0.1" or the IPv6 address "::1":

* getaddrinfo() 10.4 usec per loop
* inet_pton(): 0.285 usec per loop

On glibc older than 2.14, getaddrinfo() always requests the list of all local
IP addresses to the kernel (using a NETLINK socket). getaddrinfo() has other
known issues, it's better to avoid it when it is possible.
2015-02-04 14:51:23 +01:00
Victor Stinner f2e43cbbd4 Issue #23347, asyncio: send_signal(), terminate(), kill() don't check if the
transport was closed. The check broken a Tulip example and this limitation is
arbitrary. Check if _proc is None should be enough.

Enhance also close(): do nothing when called the second time.
2015-01-30 01:20:44 +01:00
Victor Stinner 0698638d79 asyncio: Fix ResourceWarning in test_subprocess.test_proc_exit() 2015-01-30 00:11:42 +01:00
Victor Stinner 47cd10d7a9 asyncio: sync with Tulip
Issue #23347: send_signal(), kill() and terminate() methods of
BaseSubprocessTransport now check if the transport was closed and if the
process exited.

Issue #23347: Refactor creation of subprocess transports. Changes on
BaseSubprocessTransport:

* Add a wait() method to wait until the child process exit
* The constructor now accepts an optional waiter parameter. The _post_init()
  coroutine must not be called explicitly anymore. It makes subprocess
  transports closer to other transports, and it gives more freedom if we want
  later to change completly how subprocess transports are created.
* close() now kills the process instead of kindly terminate it: the child
  process may ignore SIGTERM and continue to run. Call explicitly terminate()
  and wait() if you want to kindly terminate the child process.
* close() now logs a warning in debug mode if the process is still running and
  needs to be killed
* _make_subprocess_transport() is now fully asynchronous again: if the creation
  of the transport failed, wait asynchronously for the process eixt. Before the
  wait was synchronous. This change requires close() to *kill*, and not
  terminate, the child process.
* Remove the _kill_wait() method, replaced with a more agressive close()
  method. It fixes _make_subprocess_transport() on error.
  BaseSubprocessTransport.close() calls the close() method of pipe transports,
  whereas _kill_wait() closed directly pipes of the subprocess.Popen object
  without unregistering file descriptors from the selector (which caused severe
  bugs).

These changes simplifies the code of subprocess.py.
2015-01-30 00:05:19 +01:00
Victor Stinner 978a9afc6a Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transport
is not explicitly closed. Close also explicitly transports in test_sslproto.
2015-01-29 17:50:58 +01:00
Victor Stinner 2934262fd3 asyncio: sync with Tulip
* Cleanup gather(): use cancelled() method instead of using private Future
  attribute
* Fix _UnixReadPipeTransport and _UnixWritePipeTransport. Only start reading
  when connection_made() has been called.
* Issue #23333: Fix BaseSelectorEventLoop._accept_connection(). Close the
  transport on error. In debug mode, log errors using call_exception_handler()
2015-01-29 14:15:19 +01:00
Victor Stinner 47bbea7124 asyncio: sync with Tulip
* _SelectorTransport constructor: extra parameter is now optional
* Fix _SelectorDatagramTransport constructor. Only start reading after
  connection_made() has been called.
* Fix _SelectorSslTransport.close(). Don't call protocol.connection_lost() if
  protocol.connection_made() was not called yet: if the SSL handshake failed or
  is still in progress. The close() method can be called if the creation of the
  connection is cancelled, by a timeout for example.
2015-01-29 02:56:05 +01:00
Victor Stinner fa73779b0a asyncio: Fix _SelectorSocketTransport constructor
Only start reading when connection_made() has been called:
protocol.data_received() must not be called before protocol.connection_made().
2015-01-29 00:36:51 +01:00
Victor Stinner b507cbaac5 asyncio: Fix SSLProtocol.eof_received()
Wake-up the waiter if it is not done yet.
2015-01-29 00:35:56 +01:00
Victor Stinner ff018e406c asyncio: sync with Tulip
* Remove unused SSLProtocol._closing attribute
* test_sslproto: skip test if ssl module is missing
* Python issue #23208: Don't use the traceback of the current handle if we
  already know the traceback of the source. The handle may be more revelant,
  but having 3 tracebacks (handle, source, exception) becomes more difficult to
  read. The handle may be preferred later but it requires more work to make
  this choice.
2015-01-28 00:30:40 +01:00
Victor Stinner e0fd157ba0 Issue #23293, asyncio: Rewrite IocpProactor.connect_pipe() as a coroutine
Use a coroutine with asyncio.sleep() instead of call_later() to ensure that the
schedule call is cancelled.

Add also a unit test cancelling connect_pipe().
2015-01-26 15:04:03 +01:00
Victor Stinner 442b0adccd asyncio: pyflakes, remove unused import
tests: Remove unused function; inline another function
2015-01-21 23:39:16 +01:00
Victor Stinner cd0f7f9832 asyncio: Enhance BaseProactorEventLoop._loop_self_reading()
* Handle correctly CancelledError: just exit
* On error, log the exception and exit

Don't try to close the event loop, it is probably running and so it cannot be
closed.
2015-01-21 23:38:37 +01:00
Victor Stinner f716d8b7a5 Issue #22685: Fix test_pause_reading() of asyncio/test_subprocess
Override the connect_read_pipe() method of the loop to mock immediatly
pause_reading() and resume_reading() methods.

The test failed randomly on FreeBSD 9 buildbot and on Windows using trollius.
2015-01-15 22:52:59 +01:00
Victor Stinner 922bc2ca12 Closes #23219: cancelling asyncio.wait_for() now cancels the task 2015-01-15 16:29:10 +01:00
Victor Stinner ab8848bc2a asyncio: Close transports in tests
* Use test_utils.run_briefly() to execute pending calls to really close
  transports
* sslproto: mock also _SSLPipe.shutdown(), it's need to close the transport
* pipe test: the test doesn't close explicitly the PipeHandle, so ignore
  the warning instead
* test_popen: use the context manager ("with p:") to explicitly close pipes
2015-01-15 14:24:55 +01:00
Victor Stinner 02392c9282 Issue #23243: Close explicitly transports in asyncio tests 2015-01-15 13:18:32 +01:00
Victor Stinner 33cb0396e8 Issue #23243: Close explicitly event loops in asyncio tests 2015-01-15 13:17:34 +01:00
Victor Stinner 41ed958ee6 Issue #23243: Fix asyncio._UnixWritePipeTransport.close()
Do nothing if the transport is already closed. Before it was not possible to
close the transport twice.
2015-01-15 13:16:50 +01:00
Victor Stinner 29ad0111bd asyncio: sync with Tulip
* PipeHandle now uses None instead of -1 for a closed handle
* Sort imports in windows_utils.
* Fix test_events on Python older than 3.5. Skip SSL tests on the
  ProactorEventLoop if ssl.MemoryIO is missing
* Fix BaseEventLoop._create_connection_transport(). Close the transport if the
  creation of the transport (if the waiter) gets an exception.
* _ProactorBasePipeTransport now sets _sock to None when the transport is
  closed.
* Fix BaseSubprocessTransport.close(). Ignore pipes for which the protocol is
  not set yet (still equal to None).
* TestLoop.close() now calls the close() method of the parent class
  (BaseEventLoop).
* Cleanup BaseSelectorEventLoop: create the protocol on a separated line for
  readability and ease debugging.
* Fix BaseSubprocessTransport._kill_wait(). Set the _returncode attribute, so
  close() doesn't try to terminate the process.
* Tests: explicitly close event loops and transports
* UNIX pipe transports: add closed/closing in repr(). Add "closed" or "closing"
  state in the __repr__() method of _UnixReadPipeTransport and
  _UnixWritePipeTransport classes.
2015-01-15 00:04:21 +01:00
Victor Stinner 177e9f0855 Issue #23197, asyncio: On SSL handshake failure, check if the waiter is
cancelled before setting its exception.

* Add unit tests for this case.
* Cleanup also sslproto.py
2015-01-14 16:56:20 +01:00
Victor Stinner f651a60407 Python issue #23173: sync with Tulip
* If an exception is raised during the creation of a subprocess, kill the
  subprocess (close pipes, kill and read the return status). Log an error in
  such case.
* Fix SubprocessStreamProtocol.connection_made() to handle cancelled waiter.
  Add unit test cancelling subprocess methods.
2015-01-14 02:10:33 +01:00
Victor Stinner 231b404cb0 Issue #22560: New SSL implementation based on ssl.MemoryBIO
The new SSL implementation is based on the new ssl.MemoryBIO which is only
available on Python 3.5. On Python 3.4 and older, the legacy SSL implementation
(using SSL_write, SSL_read, etc.) is used. The proactor event loop only
supports the new implementation.

The new asyncio.sslproto module adds _SSLPipe, SSLProtocol and
_SSLProtocolTransport classes. _SSLPipe allows to "wrap" or "unwrap" a socket
(switch between cleartext and SSL/TLS).

Patch written by Antoine Pitrou. sslproto.py is based on gruvi/ssl.py of the
gruvi project written by Geert Jansen.

This change adds SSL support to ProactorEventLoop on Python 3.5 and newer!

It becomes also possible to implement STARTTTLS: switch a cleartext socket to
SSL.
2015-01-14 00:19:09 +01:00
Victor Stinner 9036e49ba1 Tulip issue 184: Fix test_pipe() on Windows
Pass explicitly the event loop to StreamReaderProtocol.
2015-01-13 16:13:06 +01:00
Victor Stinner 70db9e428a asyncio: sync with Tulip
* Tulip issue 184: FlowControlMixin constructor now get the event loop if the
  loop parameter is not set. Add unit tests to ensure that constructor of
  StreamReader and StreamReaderProtocol classes get the event loop.
* Remove outdated TODO/XXX
2015-01-09 21:32:05 +01:00
Victor Stinner 15cc678d89 asyncio: Truncate to 80 columns 2015-01-09 00:09:10 +01:00
Victor Stinner 212994e4e2 Issue #23140, asyncio: Simplify the unit test 2015-01-06 01:22:45 +01:00
Victor Stinner c447ba04e7 Issue #23140, asyncio: Fix cancellation of Process.wait(). Check the state of
the waiter future before setting its result.
2015-01-06 01:13:49 +01:00
Victor Stinner 956de691f8 Issue #22926: In debug mode, call_soon(), call_at() and call_later() methods of
asyncio.BaseEventLoop now use the identifier of the current thread to ensure
that they are called from the thread running the event loop.

Before, the get_event_loop() method was used to check the thread, and no
exception was raised when the thread had no event loop. Now the methods always
raise an exception in debug mode when called from the wrong thread. It should
help to notice misusage of the API.
2014-12-26 21:07:52 +01:00
Victor Stinner d7ff5a5375 asyncio: sync with Tulip
* Fix pyflakes warnings: remove unused imports and variables
* asyncio.test_support now uses test.support and test.script_helper if available
2014-12-26 21:16:42 +01:00
Victor Stinner 4d825b45a0 asyncio: IocpProactor.wait_for_handle() test now also checks the result of the
future
2014-12-19 17:10:44 +01:00
Victor Stinner dc7765d12c asyncio: sync with Tulip 2014-12-18 12:29:53 +01:00