Commit Graph

55 Commits

Author SHA1 Message Date
Andrew Svetlov f74ef458ab
bpo-32311: Implement asyncio.create_task() shortcut (#4848)
* Implement functionality
* Add documentation
2017-12-15 07:04:38 +02:00
Yury Selivanov a70232f288
bpo-32296: Implement asyncio.get_event_loop and _get_running_loop in C. (#4827)
asyncio.get_event_loop(), and, subsequently asyncio._get_running_loop()
are one of the most frequently executed functions in asyncio.  They also
can't be sped up by third-party event loops like uvloop.

When implemented in C they become 4x faster.
2017-12-13 14:49:42 -05:00
Yury Selivanov abae67ebc2
Add asyncio.get_running_loop() function. (#4782) 2017-12-11 10:07:44 -05:00
Yury Selivanov 6370f345e1
bpo-32262: Fix codestyle; use f-strings formatting where necessary. (#4775) 2017-12-10 18:36:12 -05:00
Andrew Svetlov 5f841b5538
bpo-32193: Convert asyncio to async/await usage (#4753)
* Convert asyncio/tasks.py to async/await

* Convert asyncio/queues.py to async/await

* Convert asyncio/test_utils.py to async/await

* Convert asyncio/base_subprocess.py to async/await

* Convert asyncio/subprocess.py to async/await

* Convert asyncio/streams.py to async/await

* Fix comments

* Convert asyncio/locks.py to async/await

* Convert asyncio.sleep to async def

* Add a comment

* Add missing news

* Convert stubs from AbstrctEventLoop to async functions

* Convert subprocess_shell/subprocess_exec

* Convert connect_read_pipe/connect_write_pip to async/await syntax

* Convert create_datagram_endpoint

* Convert create_unix_server/create_unix_connection

* Get rid of old style coroutines in unix_events.py

* Convert selector_events.py to async/await

* Convert wait_closed and create_connection

* Drop redundant line

* Convert base_events.py

* Code cleanup

* Drop redundant comments

* Fix indentation

* Add explicit tests for compatibility between old and new coroutines

* Convert windows event loop to use async/await

* Fix double awaiting of async function

* Convert asyncio/locks.py

* Improve docstring

* Convert tests to async/await

* Convert more tests

* Convert more tests

* Convert more tests

* Convert tests

* Improve test
2017-12-09 00:23:48 +02:00
Yury Selivanov 423fd362f8
bpo-32066: Support pathlib.Path in create_unix_connection; sock arg should be optional (#4447) 2017-11-20 17:26:28 -05:00
Antoine Pitrou 921e9432a1
bpo-31970: Reduce performance overhead of asyncio debug mode. (#4314)
* bpo-31970: Reduce performance overhead of asyncio debug mode.
2017-11-07 17:23:29 +01:00
Marat Sharafutdinov 69cfed1cd7 Add asyncio.Handle.cancelled() method (#2388) 2017-11-07 12:06:05 +03:00
Quentin Dawans fe4ea9cf1e bpo-31245: Asyncio unix socket datagram (#3164) 2017-10-30 09:43:02 -04:00
Antoine Pitrou 525f40d231 bpo-31819: Add AbstractEventLoop.sock_recv_into() (#4051)
* bpo-31819: Add AbstractEventLoop.sock_recv_into()

* Add NEWS

* Add doc
2017-10-19 15:46:40 -04:00
jimmylai 80bbe6a7b6 bpo-31350: Optimize get_event_loop and _get_running_loop (#3347)
* call remove_done_callback in finally section

* Optimize get_event_loop and _get_running_loop

* rename _loop_pid as loop_pid and add blurb news

* rename _loop_pid as loop_pid and add blurb news

* add back _RunningLoop

* Update 2017-09-05-10-30-48.bpo-31350.dXJ-7N.rst

* Update 2017-09-05-10-30-48.bpo-31350.dXJ-7N.rst
2017-09-05 20:36:59 -04:00
INADA Naoki 3e2ad8ec61 bpo-29617: Remove Python 3.3 support from asyncio (GH-232) 2017-04-25 10:57:18 +09:00
Yury Selivanov 902e9c50e3 asyncio: Optimize _get_running_loop() to call getpid() only when there's a loop 2017-03-02 23:58:07 -05:00
Yury Selivanov ba7e1f9a4e bpo-29703: asyncio: Fix creating new event loops in child processes. (#404) 2017-03-02 20:07:11 -05:00
Yury Selivanov 6ea2b8fc8b Issue #28613: Expose asyncio._get_running_loop() and _set_running_loop() 2016-11-07 19:00:46 -05:00
Yury Selivanov 600a349781 Issue #28613: Fix get_event_loop() to return the current loop
when called from coroutines or callbacks.
2016-11-04 14:29:28 -04:00
Yury Selivanov 491a912659 Issue #28600: Optimize loop.call_soon().
Run expensive type checks only in debug mode.  In addition, stop
supporting passing handles to loop.run_in_executor.
2016-11-03 15:09:24 -07:00
Yury Selivanov 45dccdad93 Issue #26654: Inspect functools.partial in asyncio.Handle.__repr__.
Patch by iceboy.
2016-09-15 15:58:15 -04:00
Yury Selivanov f6d991d885 asyncio: Sync with the upstream 2016-09-15 13:10:51 -04:00
Yury Selivanov 7661db6228 Issue #27041: asyncio: Add loop.create_future method 2016-05-16 15:38:39 -04:00
Yury Selivanov 7ed7ce6ee7 Issue #27040: Add loop.get_exception_handler method 2016-05-16 15:20:38 -04:00
Guido van Rossum b9bf913ab3 Issue #23972: updates to asyncio datagram API. By Chris Laws. 2015-10-05 09:15:28 -07: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 71080fc351 asyncio: Add asyncio.compat module
Move compatibility helpers for the different Python versions to a new
asyncio.compat module.
2015-07-25 02:23:21 +02: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
Victor Stinner 3a1c738e6c Issue #23074: asyncio.get_event_loop() now raises an exception if the thread
has no event loop even if assertions are disabled.
2014-12-18 01:20:10 +01:00
Yury Selivanov 592ada9b4b asyncio: Improve canceled timer handles cleanup. Closes issue #22448.
Patch by Joshua Moore-Oliva.
2014-09-25 12:07:56 -04:00
Victor Stinner 1b38bc65dd asyncio, Tulip issue 206: In debug mode, keep the callback in the
representation of Handle and TimerHandle after cancel().
2014-09-17 23:24:13 +02:00
Victor Stinner 313a980904 asyncio: sync with Tulip
* _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
2014-07-29 12:58:23 +02:00
Victor Stinner f68bd88aa6 asyncio: sync with Tulip
- Issues #21936, #21163: Fix sporadic failures of
  test_future_exception_never_retrieved()
- Handle.cancel() now clears references to callback and args
- In debug mode, repr(Handle) now contains the location where the Handle was
  created.
2014-07-10 22:32:58 +02:00
Victor Stinner 896a25ab30 asyncio: sync with Tulip
- 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
2014-07-08 11:29:25 +02:00
Victor Stinner 80f53aa9a0 asyncio, Tulip issue 137: In debug mode, save traceback where Future, Task and
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.
2014-06-27 13:52:20 +02:00
Victor Stinner 17b53f1301 asyncio: Handle error handler: enhance formatting of the callback 2014-06-26 01:35:45 +02:00
Victor Stinner 975735f729 asyncio, Tulip issue 177: Rewite repr() of Future, Task, Handle and TimerHandle
- Uniformize repr() output to format "<Class ...>"
- On Python 3.5+, repr(Task) uses the qualified name instead of the short name
  of the coroutine
2014-06-25 21:41:58 +02:00
Victor Stinner 307bccc6ff asyncio: Tulip issue 173: Enhance repr(Handle) and repr(Task)
repr(Handle) is shorter for function: "foo" instead of "<function foo at
0x...>". It now also includes the source of the callback, filename and line
number where it was defined, if available.

repr(Task) now also includes the current position in the code, filename and
line number, if available. If the coroutine (generator) is done, the line
number is omitted and "done" is added.
2014-06-12 18:39:26 +02:00
Victor Stinner f9e49dd346 Tulip issue 83, Python issue #21252: Fill some XXX docstrings in asyncio 2014-06-05 12:06:44 +02:00
Victor Stinner a5b257af22 Issue #21454: Fix asyncio.BaseEventLoop.connect_read_pipe doc
The function sets the the pipe to non-blocking mode.
2014-05-29 00:14:03 +02:00
Guido van Rossum 94ba146d11 asyncio: Add __weakref__ slots to Handle and CoroWrapper. Upstream issue #166. 2014-04-27 10:44:22 -07:00
Victor Stinner b4c9388947 asyncio: remove unused imports and unused variables noticed by pyflakes 2014-02-20 10:37:27 +01:00
Victor Stinner 0f3e6bca1b asyncio, Tulip issue #136: Add get/set_debug() methods to BaseEventLoopTests.
Add also a PYTHONASYNCIODEBUG environment variable to debug coroutines since
Python startup, to be able to debug coroutines defined directly in the asyncio
module.
2014-02-19 23:15:02 +01:00
Yury Selivanov dec1a45fd1 asyncio: Fix spelling and typos.
Thanks to Vajrasky Kok for discovering some of them.
2014-02-18 22:27:48 -05:00
Yury Selivanov 569efa2e4b asyncio: New error handling API. Issue #20681. 2014-02-18 18:02:19 -05:00
Yury Selivanov b057c52b01 asyncio: Add support for UNIX Domain Sockets. 2014-02-18 12:15:06 -05:00
Yury Selivanov b13177885f asyncio.events: Use __slots__ in Handle and TimerHandle 2014-02-12 17:01:52 -05:00
Victor Stinner dc62b7e261 asyncio: Tulip issue 112: Inline make_handle() into Handle constructor 2014-02-10 00:45:44 +01:00
Victor Stinner cf6f72e329 Fix typo in asyncio.AbstractServer documentation 2013-12-03 18:23:52 +01:00
Guido van Rossum 9204af42cc asyncio: Use Interface instead of ABC. Fixes issue 19726. 2013-11-30 15:35:42 -08:00
Guido van Rossum cced076218 asyncio: Fix get_event_loop() to call set_event_loop() when setting the loop. By Anthony Baire. 2013-11-27 10:37:13 -08:00
Guido van Rossum 0eaa5ac9b5 asyncio: Refactor SIGCHLD handling. By Anthony Baire. 2013-11-04 15:50:46 -08:00