summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/windows_events.py
Commit message (Collapse)AuthorAgeFilesLines
* Correct “an” → “a” with “Unicode”, “user”, “UTF”, etcMartin Panter2016-04-151-1/+1
| | | | This affects documentation, code comments, and a debugging messages.
* asyncio: async() function is deprecated in favour of ensure_future().Yury Selivanov2015-05-111-1/+1
|
* Issue #23353, asyncio: Workaround CPython bug #23353Victor Stinner2015-02-021-2/+9
| | | | | 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-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* asyncio, Tulip issue 204: Fix IocpProactor.recv()Victor Stinner2015-01-261-7/+13
| | | | | | | | | If ReadFile() fails with ERROR_BROKEN_PIPE, the operation is not pending: don't register the overlapped. I don't know if WSARecv() can fail with ERROR_BROKEN_PIPE. Since Overlapped.WSARecv() already handled ERROR_BROKEN_PIPE, let me guess that it has the same behaviour than ReadFile().
* Issue #23095, asyncio: Fix _WaitHandleFuture.cancel()Victor Stinner2015-01-261-20/+17
| | | | | If UnregisterWaitEx() fais with ERROR_IO_PENDING, it doesn't mean that the wait is unregistered yet. We still have to wait until the wait is cancelled.
* Issue #23293, asyncio: Rewrite IocpProactor.connect_pipe() as a coroutineVictor Stinner2015-01-261-21/+18
| | | | | | | 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().
* asyncio: Fix ProactorEventLoop.start_serving_pipe()Victor Stinner2015-01-261-1/+13
| | | | | If a client connected before the server was closed: drop the client (close the pipe) and exit.
* Issue #23293, asyncio: Cleanup IocpProactor.close()Victor Stinner2015-01-261-6/+1
| | | | | The special case for connect_pipe() is not more needed. connect_pipe() doesn't use overlapped operations anymore.
* asyncio, Tulip issue 204: Fix IocpProactor.accept_pipe()Victor Stinner2015-01-221-24/+17
| | | | | | | | Overlapped.ConnectNamedPipe() now returns a boolean: True if the pipe is connected (if ConnectNamedPipe() failed with ERROR_PIPE_CONNECTED), False if the connection is in progress. This change removes multiple hacks in IocpProactor.
* Issue #23293, asyncio: Rewrite IocpProactor.connect_pipe()Victor Stinner2015-01-221-17/+26
| | | | | | | | Add _overlapped.ConnectPipe() which tries to connect to the pipe for asynchronous I/O (overlapped): call CreateFile() in a loop until it doesn't fail with ERROR_PIPE_BUSY. Use an increasing delay between 1 ms and 100 ms. Remove Overlapped.WaitNamedPipeAndConnect() which is no more used.
* asyncio: IocpProactor.close() doesn't cancel anymore futures which are alreadyVictor Stinner2015-01-221-3/+7
| | | | cancelled
* Issue #23095, asyncio: IocpProactor.close() must not cancel pendingVictor Stinner2015-01-211-0/+6
| | | | _WaitCancelFuture futures
* Issue #23095, asyncio: Rewrite _WaitHandleFuture.cancel()Victor Stinner2015-01-211-34/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change fixes a race conditon related to _WaitHandleFuture.cancel() leading to Python crash or "GetQueuedCompletionStatus() returned an unexpected event" logs. Before, the overlapped object was destroyed too early, it was possible that the wait completed whereas the overlapped object was already destroyed. Sometimes, a different overlapped was allocated at the same address, leading to unexpected completition. _WaitHandleFuture.cancel() now waits until the wait is cancelled to clear its reference to the overlapped object. To wait until the cancellation is done, UnregisterWaitEx() is used with an event instead of UnregisterWait(). To wait for this event, a new _WaitCancelFuture class was added. It's a simplified version of _WaitCancelFuture. For example, its cancel() method calls UnregisterWait(), not UnregisterWaitEx(). _WaitCancelFuture should not be cancelled. The overlapped object is kept alive in _WaitHandleFuture until the wait is unregistered. Other changes: * Add _overlapped.UnregisterWaitEx() * Remove fast-path in IocpProactor.wait_for_handle() to immediatly set the result if the wait already completed. I'm not sure that it's safe to call immediatly UnregisterWaitEx() before the completion was signaled. * Add IocpProactor._unregistered() to forget an overlapped which may never be signaled, but may be signaled for the next loop iteration. It avoids to block forever IocpProactor.close() if a wait was cancelled, and it may also avoid some "... unexpected event ..." warnings.
* asyncio: Close the transport on subprocess creation failureVictor Stinner2015-01-151-1/+6
|
* asyncio: Truncate to 80 columnsVictor Stinner2015-01-081-1/+2
|
* asyncio: IocpProactor.wait_for_handle() test now also checks the result of theVictor Stinner2014-12-191-0/+5
| | | | future
* asyncio: sync with TulipVictor Stinner2014-12-181-1/+1
| | | | | | | | | | | | | | | | * Fix a race condition in BaseSubprocessTransport._try_finish(). If the process exited before the _post_init() method was called, scheduling the call to _call_connection_lost() with call_soon() is wrong: connection_made() must be called before connection_lost(). Reuse the BaseSubprocessTransport._call() method to schedule the call to _call_connection_lost() to ensure that connection_made() and connection_lost() are called in the correct order. * Add repr(PipeHandle) * Fix typo
* asyncio: sync with TulipVictor Stinner2014-08-251-6/+25
| | | | | | | | | | | | | | | | | | | | | | | * 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: sync with TulipVictor Stinner2014-07-291-30/+54
| | | | | | | | | | | | | | | | | | | | | | | | * _WaitHandleFuture.cancel() now notify IocpProactor through the overlapped object that the wait was cancelled. * Optimize IocpProactor.wait_for_handle() gets the result if the wait is signaled immediatly. * Enhance representation of Future and Future subclasses - Add "created at filename:lineno" in the representation - Add Future._repr_info() method which can be more easily overriden than Future.__repr__(). It should now be more easy to enhance Future representation without having to modify each subclass. For example, _OverlappedFuture and _WaitHandleFuture get the new "created at" information. - Use reprlib to format Future result, and function arguments when formatting a callback, to limit the length of the representation. * Fix repr(_WaitHandleFuture) * _WaitHandleFuture and _OverlappedFuture: hide frames of internal calls in the source traceback. * Cleanup ProactorIocp._poll(): set the timeout to 0 after the first call to GetQueuedCompletionStatus() * test_locks: close the temporary event loop and check the condition lock * Remove workaround in test_futures, no more needed
* asyncio, tulip issue 196: ProactorIocp._register() now registers the overlappedVictor Stinner2014-07-271-15/+38
| | | | | | | | | | | | | | | | in the _cache dictionary, even if we already got the result. We need to keep a reference to the overlapped object, otherwise the memory may be reused and GetQueuedCompletionStatus() may use random bytes and behaves badly. There is still a hack for ConnectNamedPipe(): the overlapped object is not register into _cache if the overlapped object completed directly. Log also an error in debug mode in ProactorIocp._loop() if we get an unexpected event. Add a protection in ProactorIocp.close() to avoid blocking, even if it should not happen. I still don't understand exactly why some the completion of some overlapped objects are not notified.
* Tulip issue 196: _OverlappedFuture.set_result() now clears its reference to theVictor Stinner2014-07-251-5/+11
| | | | | overlapped object. IocpProactor._poll() now also ignores false alarms: GetQueuedCompletionStatus() returns the overlapped but it is still pending.
* asyncio: sync with TulipVictor Stinner2014-07-251-0/+5
| | | | | | | | * Tulip issue #196: IocpProactor._poll() clears the reference to the overlapped operation when the operation is done. It would be better to clear the reference in a new _OverlappedFuture.set_result() method, but it cannot be done yet because of a weird bug. * BaseSelectorEventLoop._write_to_self() now logs errors in debug mode.
* asyncio: sync with TulipVictor Stinner2014-07-251-21/+50
| | | | | | | | | | | | * Fix _WaitHandleFuture.cancel(): return the result of the parent cancel() method. * _OverlappedFuture.cancel() now clears its reference to the overlapped object. Make also the _OverlappedFuture.ov attribute private. * Check if _WaitHandleFuture completed before unregistering it in the callback. Add also _WaitHandleFuture._poll() and repr(_WaitHandleFuture). * _WaitHandleFuture now unregisters its wait handler if WaitForSingleObject() raises an exception. * _OverlappedFuture.set_exception() now cancels the overlapped operation.
* asyncio: sync with TulipVictor Stinner2014-07-241-20/+46
| | | | | | | | | | | | | | | | | | | | | | Improve stability of the proactor event loop, especially operations on overlapped objects: * Tulip issue 195: Don't call UnregisterWait() twice if a _WaitHandleFuture is cancelled twice to fix a crash. * IocpProactor.close(): cancel futures to cancel overlapped operations, instead of cancelling directly overlapped operations. Future objects may not call ov.cancel() if the future was cancelled or if the overlapped was already cancelled. The cancel() method of the future may also catch exceptions. Log also errors on cancellation. * tests: rename "f" to "fut" * Add a __repr__() method to IocpProactor * Add a destructor to IocpProactor which closes it * _OverlappedFuture.cancel() doesn't cancel the overlapped anymore if it is done: if it is already cancelled or completed. Log also an error if the cancellation failed. * Add the address of the overlapped object in repr(_OverlappedFuture) * _OverlappedFuture truncates the source traceback to hide the call to the parent constructor (useless in debug).
* asyncio: sync with TulipVictor Stinner2014-07-121-0/+12
| | | | | | | | | | | | | | | | | | | * 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.
* asyncio: sync with Tulip, add a new asyncio.coroutines moduleVictor Stinner2014-06-281-5/+6
|
* asyncio/windows_events.py: use more revelant names to overlapped callbacksVictor Stinner2014-02-261-10/+10
| | | | For example: "finish_recv", not just "finish".
* asyncio: remove unused imports and unused variables noticed by pyflakesVictor Stinner2014-02-201-1/+0
|
* asyncio: Fix spelling and typos.Yury Selivanov2014-02-191-1/+1
| | | | Thanks to Vajrasky Kok for discovering some of them.
* asyncio: New error handling API. Issue #20681.Yury Selivanov2014-02-181-2/+6
|
* asyncio: Remove more relics of resolution/granularity.Guido van Rossum2014-02-091-1/+0
|
* Issue #20455: Add a resolution attribute to IocpProactor (1 ms)Victor Stinner2014-01-311-0/+1
|
* Issue #20455: asyncio: use the same code to round a timeout than the selectorsVictor Stinner2014-01-311-4/+9
| | | | | | module Sort also imports
* asyncio: Fix _make_subprocess_transport(): pass extra value to the constructor.Victor Stinner2014-01-291-1/+1
|
* Merge latest Tulip into asyncioAndrew Svetlov2014-01-261-3/+0
|
* Cleanup properly proactor event loopVictor Stinner2014-01-101-4/+13
| | | | | | | | | * store the "self reading" future when the "self pipe" is closed (when the event loop is closed) * store "accept" futures to cancel them when we stop serving * close the "accept socket" if the "accept future" is cancelled Fix many warnings which can be seen when unit tests are run in verbose mode.
* Issue #19740: Use WaitForSingleObject() instead of trusting TimerOrWaitFired.Richard Oudkerk2013-11-241-2/+9
|
* asyncio: Refactor SIGCHLD handling. By Anthony Baire.Guido van Rossum2013-11-041-2/+15
|
* asyncio: Various style nits.Guido van Rossum2013-11-011-0/+16
|
* asyncio: Add support for running subprocesses on Windows with the IOCP event ↵Guido van Rossum2013-10-301-5/+29
| | | | loop (Richard Oudkerk).
* asyncio: Make the IOCP proactor support "waitable" handles (Richard Oudkerk).Guido van Rossum2013-10-301-0/+40
|
* Rename the logger to plain "logger".Guido van Rossum2013-10-171-3/+3
|
* Initial checkin of asyncio package (== Tulip, == PEP 3156).Guido van Rossum2013-10-171-0/+375