summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/unix_events.py
Commit message (Collapse)AuthorAgeFilesLines
* asyncio: Sync with upstream (compat module)Yury Selivanov2015-08-041-2/+3
|
* Issue #23353, asyncio: Workaround CPython bug #23353Victor Stinner2015-02-021-2/+10
| | | | | Don't use yield/yield-from in an except block of a generator. Store the exception and handle it outside the except block.
* Issue #23347, asyncio: Make BaseSubprocessTransport.wait() privateVictor Stinner2015-01-291-1/+1
|
* asyncio: sync with TulipVictor Stinner2015-01-291-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transportVictor Stinner2015-01-291-0/+19
| | | | is not explicitly closed. Close also explicitly transports in test_sslproto.
* asyncio: sync with TulipVictor Stinner2015-01-291-6/+11
| | | | | | | | | * 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()
* asyncio: SSL transports now clear their reference to the waiterVictor Stinner2015-01-281-2/+2
| | | | | | | * Rephrase also the comment explaining why the waiter is not awaken immediatly. * SSLProtocol.eof_received() doesn't instanciate ConnectionResetError exception directly, it will be done by Future.set_exception(). The exception is not used if the waiter was cancelled or if there is no waiter.
* asyncio: Close the transport on subprocess creation failureVictor Stinner2015-01-151-1/+5
|
* Issue #23243: Fix asyncio._UnixWritePipeTransport.close()Victor Stinner2015-01-151-1/+1
| | | | | Do nothing if the transport is already closed. Before it was not possible to close the transport twice.
* asyncio: sync with TulipVictor Stinner2015-01-141-2/+12
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* asyncio: sync with TulipVictor Stinner2015-01-091-4/+1
| | | | | | | * 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
* asyncio: Truncate to 80 columnsVictor Stinner2015-01-081-1/+2
|
* asyncio, tulip issue 209: Fix subprocess for close_fds=False on Python 3.3Victor Stinner2014-12-111-0/+22
| | | | Mark the write end of the stdin pipe as non-inheritable.
* Closes #22922: More EventLoop methods fail if the loop is closed. Initial patchVictor Stinner2014-12-041-0/+1
| | | | | | | written by Torsten Landschoff. create_task(), call_at(), call_soon(), call_soon_threadsafe() and run_in_executor() now raise an error if the event loop is closed.
* asyncio: Coroutine objects are now rejected with a TypeError by the followingVictor Stinner2014-11-201-2/+3
| | | | | | | | | | | | | | 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).
* - Issue #22841: Reject coroutines in asyncio add_signal_handler().Guido van Rossum2014-11-141-0/+3
| | | | Patch by Ludovic.Gasc.
* asyncio: Move loop attribute to _FlowControlMixinVictor Stinner2014-11-051-2/+1
| | | | | | | | | Move the _loop attribute from the constructor of _SelectorTransport, _ProactorBasePipeTransport and _UnixWritePipeTransport classes to the constructor of the _FlowControlMixin class. Add also an assertion to explicit that the parent class must ensure that the loop is defined (not None)
* asyncio.unix_events: Move import statement to match tulip codeYury Selivanov2014-09-251-1/+2
|
* asyncio: sync with TulipVictor Stinner2014-08-251-3/+11
| | | | | | | | | | | | | | | | | | | | | | | * PipeServer.close() now cancels the "accept pipe" future which cancels the overlapped operation. * Fix _SelectorTransport.__repr__() if the transport was closed * Fix debug log in BaseEventLoop.create_connection(): get the socket object from the transport because SSL transport closes the old socket and creates a new SSL socket object. Remove also the _SelectorSslTransport._rawsock attribute: it contained the closed socket (not very useful) and it was not used. * Issue #22063: socket operations (sock_recv, sock_sendall, sock_connect, sock_accept) of the proactor event loop don't raise an exception in debug mode if the socket are in blocking mode. Overlapped operations also work on blocking sockets. * Fix unit tests in debug mode: mock a non-blocking socket for socket operations which now raise an exception if the socket is blocking. * _fatal_error() method of _UnixReadPipeTransport and _UnixWritePipeTransport now log all exceptions in debug mode * Don't log expected errors in unit tests * Tulip issue 200: _WaitHandleFuture._unregister_wait() now catchs and logs exceptions. * Tulip issue 200: Log errors in debug mode instead of simply ignoring them.
* asyncio: Use the new os.set_blocking() function of Python 3.5 if availableVictor Stinner2014-07-291-4/+8
|
* asyncio: sync with TulipVictor Stinner2014-07-231-3/+3
| | | | | * Tulip issue 194: Don't use sys.getrefcount() in unit tests * signal.set_wakeup_fd() can now raise an OSError on Python 3.5
* Python issue #21645, Tulip issue 192: Rewrite signal handlingVictor Stinner2014-07-171-2/+18
| | | | | | | | | | | | | | | | | | | 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.
* asyncio: sync with TulipVictor Stinner2014-07-141-1/+12
| | | | | | | | | | | | | | | | | | | | * Tulip issue #184: Log subprocess events in debug mode - Log stdin, stdout and stderr transports and protocols - Log process identifier (pid) - Log connection of pipes - Log process exit - Log Process.communicate() tasks: feed stdin, read stdout and stderr - Add __repr__() method to many classes related to subprocesses * Add BaseSubprocessTransport._pid attribute. Store the pid so it is still accessible after the process exited. It's more convinient for debug. * create_connection(): add the socket in the "connected to" debug log * Clean up some docstrings and comments. Remove unused unimplemented _read_from_self().
* asyncio: sync with TulipVictor Stinner2014-07-121-0/+36
| | | | | | | | | | | | | | | | | | | * Tulip issue #183: log socket events in debug mode - Log most important socket events: socket connected, new client, connection reset or closed by peer (EOF), etc. - Log time elapsed in DNS resolution (getaddrinfo) - Log pause/resume reading - Log time of SSL handshake - Log SSL handshake errors - Add a __repr__() method to many classes * Fix ProactorEventLoop() in debug mode. ProactorEventLoop._make_self_pipe() doesn't call call_soon() directly because it checks for the current loop which fails, because the method is called to build the event loop. * Cleanup _ProactorReadPipeTransport constructor. Not need to set again _read_fut attribute to None, it is already done in the base class.
* asyncion, Tulip issue 181: BaseEventLoop.create_datagram_endpoint() now waitsVictor Stinner2014-07-081-0/+2
| | | | | until protocol.connection_made() has been called. Document also why transport constructors use a waiter.
* Closes #21886, #21447: Fix a race condition in asyncio when setting the resultVictor Stinner2014-07-051-2/+2
| | | | | of a Future with call_soon(). Add an helper, a private method, to set the result only if the future was not cancelled.
* asyncio: sync with TulipVictor Stinner2014-07-021-1/+1
| | | | | | | | | | * _UnixSubprocessTransport: fix file mode of stdin. Open stdin in write mode, not in read mode * Examples: close the event loop at exit * More reliable CoroWrapper.__del__. If the constructor is interrupted by KeyboardInterrupt or the coroutine objet is destroyed lately, some the _source_traceback attribute doesn't exist anymore. * repr(Task): include also the future the task is waiting for
* asyncio: sync with Tulip, add a new asyncio.coroutines moduleVictor Stinner2014-06-281-4/+4
|
* asyncio, Tulip issue 171: BaseEventLoop.close() now raises an exception if theVictor Stinner2014-06-221-1/+1
| | | | | event loop is running. You must first stop the event loop and then wait until it stopped, before closing it.
* Tulip issue 83, Python issue #21252: Fill some XXX docstrings in asyncioVictor Stinner2014-06-051-2/+2
|
* Issue #21119: asyncio now closes sockets on errorsVictor Stinner2014-06-031-0/+3
| | | | | | Fix ResourceWarning: create_connection(), create_datagram_endpoint() and create_unix_server() methods of event loop now close the newly created socket on error.
* Issue #21155: asyncio.EventLoop.create_unix_server() now raises a ValueError ifVictor Stinner2014-04-071-0/+4
| | | | path and sock are specified at the same time.
* asyncio: remove unused imports and unused variables noticed by pyflakesVictor Stinner2014-02-201-1/+0
|
* asyncio: Fix spelling and typos.Yury Selivanov2014-02-191-2/+2
| | | | Thanks to Vajrasky Kok for discovering some of them.
* asyncio, Tulip issue 143: UNIX domain methods, fix ResourceWarning andVictor Stinner2014-02-191-4/+4
| | | | | DeprecationWarning warnings. create_unix_server() closes the socket on any error, not only on OSError.
* asyncio, Tulip issue 139: Improve error messages on "fatal errors"Victor Stinner2014-02-191-7/+7
| | | | | 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").
* asyncio.transports: Make _ProactorBasePipeTransport use _FlowControlMixinYury Selivanov2014-02-181-1/+1
|
* asyncio: New error handling API. Issue #20681.Yury Selivanov2014-02-181-5/+21
|
* asyncio: Add support for UNIX Domain Sockets.Yury Selivanov2014-02-181-2/+73
|
* asyncio: Tulip issue 112: Inline make_handle() into Handle constructorVictor Stinner2014-02-091-1/+1
|
* Issue #20400: Merge Tulip into Python: add the new asyncio.subprocess moduleVictor Stinner2014-02-011-6/+1
| | | | | | | | | | | | | | | | | | | | * Add a new asyncio.subprocess module * Add new create_subprocess_exec() and create_subprocess_shell() functions * The new asyncio.subprocess.SubprocessStreamProtocol creates stream readers for stdout and stderr and a stream writer for stdin. * The new asyncio.subprocess.Process class offers an API close to the subprocess.Popen class: - pid, returncode, stdin, stdout and stderr attributes - communicate(), wait(), send_signal(), terminate() and kill() methods * Remove STDIN (0), STDOUT (1) and STDERR (2) constants from base_subprocess and unix_events, to not be confused with the symbols with the same name of subprocess and asyncio.subprocess modules * _ProactorBasePipeTransport.get_write_buffer_size() now counts also the size of the pending write * _ProactorBaseWritePipeTransport._loop_writing() may now pause the protocol if the write buffer size is greater than the high water mark (64 KB by default)
* asyncio: Fix _UnixWritePipeTransport, raise BrokenPipeError when the pipe isVictor Stinner2014-01-311-1/+4
| | | | closed, but only if there was pending write
* asyncio: Fix _make_subprocess_transport(): pass extra value to the constructor.Victor Stinner2014-01-291-1/+1
|
* asyncio: Add write flow control to unix pipes.Guido van Rossum2014-01-291-3/+11
|
* asyncio: _fatal_error() of _UnixWritePipeTransport and ↵Victor Stinner2014-01-291-1/+2
| | | | | | _ProactorBasePipeTransport shouldn't log BrokenPipeError nor ConnectionResetError. (Same behaviour as _SelectorTransport._fatal_error().)
* Merge latest Tulip into asyncioAndrew Svetlov2014-01-261-3/+0
|
* asyncio: Fix race in FastChildWatcher (by its original author, Anthony Baire).Guido van Rossum2014-01-261-20/+16
|
* Update asyncio from the Tulip projectVictor Stinner2014-01-251-3/+5
| | | | | | | | | | | | | | | | 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
* asyncio: Minimal pty support in UNIX read pipe, by Jonathan Slenders.Guido van Rossum2014-01-101-2/+5
|
* asyncio: Fix race in subprocess transport, by Victor Stinner.Guido van Rossum2014-01-101-1/+2
|