summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
Commit message (Collapse)AuthorAgeFilesLines
* asyncio: BaseEventLoop: rename _owner to _thread_idVictor Stinner2015-02-051-6/+6
|
* asyncio: Only call _check_resolved_address() in debug modeVictor Stinner2015-02-041-16/+32
| | | | | | | | | | | | | | | | * _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.
* Issue #23243, asyncio: Emit a ResourceWarning when an event loop or a transportVictor Stinner2015-01-291-0/+11
| | | | is not explicitly closed. Close also explicitly transports in test_sslproto.
* asyncio: sync with TulipVictor Stinner2015-01-271-1/+2
| | | | | | | | | | * 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.
* Issue #23208, asyncio: Add BaseEventLoop._current_handleVictor Stinner2015-01-261-6/+19
| | | | | | | | | In debug mode, BaseEventLoop._run_once() now sets the BaseEventLoop._current_handle attribute to the handle currently executed. In release mode or when no handle is executed, the attribute is None. BaseEventLoop.default_exception_handler() displays the traceback of the current handle if available.
* asyncio: Close transports on errorVictor Stinner2015-01-261-3/+21
| | | | | Fix create_datagram_endpoint(), connect_read_pipe() and connect_write_pipe(): close the transport if the task is cancelled or on error.
* asyncio: BaseEventLoop._create_connection_transport() catchs any exception, notVictor Stinner2015-01-211-1/+1
| | | | only Exception
* asyncio: pyflakes, remove unused importVictor Stinner2015-01-211-1/+1
| | | | tests: Remove unused function; inline another function
* asyncio: sync with TulipVictor Stinner2015-01-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | * 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: Truncate to 80 columnsVictor Stinner2015-01-081-2/+2
|
* asyncio: _make_ssl_transport: make the waiter parameter optionalVictor Stinner2015-01-081-1/+1
|
* Issue #23046: Expose the BaseEventLoop class in the asyncio namespaceVictor Stinner2015-01-061-1/+1
|
* Issue #22926: In debug mode, call_soon(), call_at() and call_later() methods ofVictor Stinner2014-12-261-18/+20
| | | | | | | | | | 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.
* Issue #23074: asyncio.get_event_loop() now raises an exception if the threadVictor Stinner2014-12-181-1/+1
| | | | has no event loop even if assertions are disabled.
* Closes #22429, asyncio: Fix EventLoop.run_until_complete(), don't stop theVictor Stinner2014-12-051-2/+12
| | | | | event loop if a BaseException is raised, because the event loop is already stopped.
* Closes #22922: More EventLoop methods fail if the loop is closed. Initial patchVictor Stinner2014-12-041-0/+4
| | | | | | | 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-4/+7
| | | | | | | | | | | | | | 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 #22601: run_forever() now consumes BaseException of the temporary taskVictor Stinner2014-10-111-1/+9
| | | | | If the coroutine raised a BaseException, consume the exception to not log a warning. The caller doesn't have access to the local task.
* Issue #22448: asyncio, cleanup _run_once(), only iterate once to remove delayedVictor Stinner2014-09-301-4/+7
| | | | calls that were cancelled.
* asyncio: Improve canceled timer handles cleanup. Closes issue #22448.Yury Selivanov2014-09-251-7/+37
| | | | Patch by Joshua Moore-Oliva.
* asyncio: sync with TulipVictor Stinner2014-08-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* Issue #20055: Fix BaseEventLoop.stop() docstring, incomplete sentence.Victor Stinner2014-07-241-3/+3
| | | | Patch written by Saimadhav Heblikar.
* asyncio: sync with TulipVictor Stinner2014-07-141-39/+92
| | | | | | | | | | | | | | | | | | | | * 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-4/+52
| | | | | | | | | | | | | | | | | | | * 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: improve the documentation of serversVictor Stinner2014-07-111-1/+3
| | | | | | - Fix the documentation of Server.close(): it closes sockets - Replace AbstractServer with Server - Document Server.sockets attribute
* asyncio, Tulip issue 180: Make Server attributes and methods privateVictor Stinner2014-07-111-20/+21
| | | | | | | - loop, waiters and active_count attributes are now private - attach(), detach() and wakeup() methods are now private The sockets attribute remains public.
* asyncio: sync with TulipVictor Stinner2014-07-111-7/+14
| | | | | | | | | | * Tulip issue #182: Improve logs of BaseEventLoop._run_once() - Don't log non-blocking poll - Only log polling with a timeout if it gets events or if it timed out after more than 1 second. * Fix some pyflakes warnings: remove unused imports
* asyncio: sync with TulipVictor Stinner2014-07-101-1/+4
| | | | | | | - repr(Task) and repr(CoroWrapper) now also includes where these objects were created. If the coroutine is not a generator (don't use "yield from"), use the location of the function, not the location of the coro() wrapper. - Fix create_task(): truncate the traceback to hide the call to create_task().
* asyncion, Tulip issue 181: BaseEventLoop.create_datagram_endpoint() now waitsVictor Stinner2014-07-081-2/+5
| | | | | until protocol.connection_made() has been called. Document also why transport constructors use a waiter.
* asyncio: sync with TulipVictor Stinner2014-07-081-0/+6
| | | | | | | | | | | - Tulip issue 185: Add a create_task() method to event loops. The create_task() method can be overriden in custom event loop to implement their own task class. For example, greenio and Pulsar projects use their own task class. The create_task() method is now preferred over creating directly task using the Task class. - tests: fix a warning - fix typo in the name of a test function - Update AbstractEventLoop: add new event loop methods; update also the unit test
* Issue #21163: BaseEventLoop.run_until_complete() and test_utils.run_briefly()Victor Stinner2014-06-301-0/+7
| | | | | don't log the "destroy pending task" message anymore. The log is redundant for run_until_complete() and useless in run_briefly().
* asyncio: sync with TulipVictor Stinner2014-06-301-2/+2
| | | | | | | | | | | - Sort imports - Simplify/optimize iscoroutine(). Inline inspect.isgenerator(obj): replace it with isinstance(obj, types.GeneratorType) - CoroWrapper: check at runtime if Python has the yield-from bug #21209. If Python has the bug, check if CoroWrapper.send() was called by yield-from to decide if parameters must be unpacked or not. - Fix "Task was destroyed but it is pending!" warning in test_task_source_traceback()
* asyncio: sync with Tulip, add a new asyncio.coroutines moduleVictor Stinner2014-06-281-13/+15
|
* asyncio, Tulip issue 137: In debug mode, save traceback where Future, Task andVictor Stinner2014-06-271-3/+23
| | | | | | | | | | | Handle objects are created. Pass the traceback to call_exception_handler() in the 'source_traceback' key. The traceback is truncated to hide internal calls in asyncio, show only the traceback from user code. Add tests for the new source_traceback, and a test for the 'Future/Task exception was never retrieved' log.
* asyncio: Fix BaseEventLoop._assert_is_current_event_loop(): get_event_loop()Victor Stinner2014-06-231-2/+5
| | | | raises an exception if there is no current loop
* asyncio, Tulip issue 171: BaseEventLoop.close() now raises an exception if theVictor Stinner2014-06-221-0/+4
| | | | | event loop is running. You must first stop the event loop and then wait until it stopped, before closing it.
* asyncio, Tulip issue 172: only log selector timing in debug modeVictor Stinner2014-06-221-2/+1
|
* asyncio: Enable the debug mode of event loops when the PYTHONASYNCIODEBUGVictor Stinner2014-06-221-1/+2
| | | | environment variable is set
* asyncio: BaseEventLoop._assert_is_current_event_loop() now only raises anVictor Stinner2014-06-221-1/+2
| | | | | | | | | | | | exception if the current loop is not None. Guido van Rossum wrote: "The behavior that you can set the loop to None (and keep track of it explicitly) is part of the spec, and this should still be supported even in debug mode. The behavior that we raise an error if you are caught having multiple active loops per thread is just a debugging heuristic, and it shouldn't break code that follows the spec."
* asyncio, Tulip issue 105: in debug mode, log callbacks taking more than 100 msVictor Stinner2014-06-201-5/+27
| | | | to be executed.
* Tulip issue 83: document more asyncio functions in docstringsVictor Stinner2014-06-191-3/+18
|
* Issue #21326: Add a new is_closed() method to asyncio.BaseEventLoopVictor Stinner2014-06-101-0/+19
| | | | | | | | | | | Add BaseEventLoop._closed attribute and use it to check if the event loop was closed or not, instead of checking different attributes in each subclass of BaseEventLoop. run_forever() and run_until_complete() methods now raise a RuntimeError('Event loop is closed') exception if the event loop was closed. BaseProactorEventLoop.close() now also cancels "accept futures".
* Issue #21119: asyncio now closes sockets on errorsVictor Stinner2014-06-031-0/+8
| | | | | | Fix ResourceWarning: create_connection(), create_datagram_endpoint() and create_unix_server() methods of event loop now close the newly created socket on error.
* asyncio: Upstream issue #167: remove dead code, by Marc Schlaich.Guido van Rossum2014-05-101-5/+1
|
* asyncio: Ensure call_soon(), call_later() and call_at() are invoked on currentVictor Stinner2014-03-211-1/+22
| | | | | | loop in debug mode. Raise a RuntimeError if the event loop of the current thread is different. The check should help to debug thread-safetly issue. Patch written by David Foster.
* asyncio: _check_resolved_address() must also accept IPv6 without flow_info andVictor Stinner2014-02-201-1/+1
| | | | scope_id: (host, port).
* asyncio: Fix _check_resolved_address() for IPv6 addressVictor Stinner2014-02-201-2/+5
|
* asyncio, Tulip issue #136: Add get/set_debug() methods to BaseEventLoopTests.Victor Stinner2014-02-191-0/+7
| | | | | | Add also a PYTHONASYNCIODEBUG environment variable to debug coroutines since Python startup, to be able to debug coroutines defined directly in the asyncio module.
* asyncio: pep8-ify the code.Yury Selivanov2014-02-191-5/+6
|
* asyncio: New error handling API. Issue #20681.Yury Selivanov2014-02-181-2/+94
|