Commit Graph

34 Commits

Author SHA1 Message Date
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 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 2d99d93d11 asyncio: Coroutine objects are now rejected with a TypeError by the following
functions:

* add_signal_handler()
* call_at()
* call_later()
* call_soon()
* call_soon_threadsafe()
* run_in_executor()

Fix also the error message of add_signal_handler() (fix the name of the
function).
2014-11-20 15:03:52 +01:00
Guido van Rossum e36fcde383 - Issue #22841: Reject coroutines in asyncio add_signal_handler().
Patch by Ludovic.Gasc.
2014-11-14 11:45:47 -08:00
Victor Stinner f2ed889027 asyncio: Use the new os.set_blocking() function of Python 3.5 if available 2014-07-29 23:08:00 +02:00
Victor Stinner c4c464911a asyncio: sync with Tulip
* Tulip issue 194: Don't use sys.getrefcount() in unit tests
* signal.set_wakeup_fd() can now raise an OSError on Python 3.5
2014-07-23 18:21:45 +02:00
Victor Stinner fe5649c7b7 Python issue #21645, Tulip issue 192: Rewrite signal handling
Since Python 3.3, the C signal handler writes the signal number into the wakeup
file descriptor and then schedules the Python call using Py_AddPendingCall().

asyncio uses the wakeup file descriptor to wake up the event loop, and relies
on Py_AddPendingCall() to schedule the final callback with call_soon().

If the C signal handler is called in a thread different than the thread of the
event loop, the loop is awaken but Py_AddPendingCall() was not called yet. In
this case, the event loop has nothing to do and go to sleep again.
Py_AddPendingCall() is called while the event loop is sleeping again and so the
final callback is not scheduled immediatly.

This patch changes how asyncio handles signals. Instead of relying on
Py_AddPendingCall() and the wakeup file descriptor, asyncio now only relies on
the wakeup file descriptor. asyncio reads signal numbers from the wakeup file
descriptor to call its signal handler.
2014-07-17 22:43:40 +02:00
Victor Stinner 7b7120e159 asyncio: Enable the debug mode of event loops when the PYTHONASYNCIODEBUG
environment variable is set
2014-06-23 00:12:14 +02:00
Victor Stinner c73701de72 asyncio: Refactor tests: add a base TestCase class 2014-06-18 01:36:32 +02:00
Victor Stinner 223a624158 Issue #21119: asyncio now closes sockets on errors
Fix ResourceWarning: create_connection(), create_datagram_endpoint() and
create_unix_server() methods of event loop now close the newly created socket
on error.
2014-06-04 00:11:52 +02:00
Benjamin Peterson fa873f66c6 remove superfluous and useless line 2014-04-16 16:16:37 -04:00
Victor Stinner f5e37037cc asyncio: Fix pyflakes warnings: remove unused variables and imports 2014-02-26 11:07:42 +01:00
Victor Stinner 24ba203504 asyncio: Replace "unittest.mock" with "mock" in unit tests
Use "from unittest import mock". It should simplify my work to merge new tests
in Trollius, because Trollius uses "mock" backport for Python 2.
2014-02-26 10:25:02 +01:00
Yury Selivanov b41a42e316 asyncio: pep8-ify the code. 2014-02-18 22:56:15 -05:00
Yury Selivanov b0b0e628ee asyncio: Fix spelling and typos.
Thanks to Vajrasky Kok for discovering some of them.
2014-02-18 22:27:48 -05:00
Victor Stinner 884e40b982 asyncio, Tulip issue 143: UNIX domain methods, fix ResourceWarning and
DeprecationWarning warnings. create_unix_server() closes the socket on any
error, not only on OSError.
2014-02-19 01:45:59 +01:00
Victor Stinner 065ca25aae asyncio, Tulip issue 139: Improve error messages on "fatal errors"
Mention if the error was caused by a read or a write, and be more specific on
the object (ex: "pipe transport" instead of "transport").
2014-02-19 01:40:41 +01:00
Yury Selivanov ff827f08ac asyncio: New error handling API. Issue #20681. 2014-02-18 18:02:19 -05:00
Yury Selivanov 88a5bf0b2e asyncio: Add support for UNIX Domain Sockets. 2014-02-18 12:15:06 -05:00
Victor Stinner 8dffc456d7 Update asyncio from the Tulip project
Major changes:

- StreamReader.readexactly() now raises an IncompleteReadError if the
  end of stream is reached before we received enough bytes, instead of
  returning less bytes than requested.

- Unit tests use the main asyncio module instead of submodules like events

- _UnixWritePipeTransport now also supports character devices, as
  _UnixReadPipeTransport. Patch written by Jonathan Slenders.

- Export more symbols: BaseEventLoop, BaseProactorEventLoop,
  BaseSelectorEventLoop, Queue and Queue sublasses, Empty, Full
2014-01-25 15:32:06 +01:00
Guido van Rossum 14c3e14053 asyncio: Change mock pipe to mock socket. Hope to fix issue 19750. 2013-11-25 09:43:52 -08:00
Guido van Rossum 91d2c5674a asyncio: Refactor waitpid mocks. Patch by Anthony Baire. 2013-11-14 16:16:29 -08:00
Serhiy Storchaka e048addedc Issue #19589: Use specific asserts in asyncio tests. 2013-11-14 23:10:51 +02:00
Guido van Rossum 2bcae708d8 asyncio: Fix from Anthony Baire for CPython issue 19566 (replaces earlier fix). 2013-11-13 15:50:08 -08:00
Guido van Rossum 0b69fbc642 asyncio: Add close() back to Unix selector event loop, to remove all signal handlers. Should fix buildbot issues. 2013-11-06 20:25:50 -08:00
Guido van Rossum 0eaa5ac9b5 asyncio: Refactor SIGCHLD handling. By Anthony Baire. 2013-11-04 15:50:46 -08:00
Guido van Rossum 934f6ea7fb Switch subprocess stdin to a socketpair, attempting to fix issue #19293 (AIX hang). 2013-10-21 20:37:14 -07:00
Guido van Rossum 8da15cc218 asyncio: be more lenient if we don't understand status returned by waitpid().
This should have no effect, it's a "shouldn't happe" case.
Also tidied up some comments.
2013-10-21 15:00:44 -07:00
Antoine Pitrou cb1fe98f76 Make various asyncio test files individually runnable 2013-10-20 21:02:53 +02:00
Guido van Rossum 57497ad181 Rename Transport.pause/resume to pause_reading/pause_writing. Also relax timeout in test_call_later(). 2013-10-18 07:58:20 -07:00
Guido van Rossum fc29e0f37e Rename the logger to plain "logger". 2013-10-17 15:39:45 -07:00
Guido van Rossum 5ea7f93dcd Make asyncio tests run on Windows. 2013-10-17 14:23:17 -07:00
Guido van Rossum 27b7c7ebf1 Initial checkin of asyncio package (== Tulip, == PEP 3156). 2013-10-17 13:40:50 -07:00