Commit Graph

80 Commits

Author SHA1 Message Date
Victor Stinner 770e48d017 asyncio: sync with Tulip
* 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
2014-07-11 11:58:33 +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 bfff45d611 asyncion, Tulip issue 181: BaseEventLoop.create_datagram_endpoint() now waits
until protocol.connection_made() has been called. Document also why transport
constructors use a waiter.
2014-07-08 23:57:31 +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 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 f328c7dc69 asyncio, Tulip issue 171: BaseEventLoop.close() now raises an exception if the
event loop is running. You must first stop the event loop and then wait until
it stopped, before closing it.
2014-06-23 01:02:37 +02:00
Victor Stinner c73701de72 asyncio: Refactor tests: add a base TestCase class 2014-06-18 01:36:32 +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 27d411255a Issue #21651: Fix ResourceWarning when running asyncio tests on Windows.
Patch written by Claudiu Popa.
2014-06-04 00:23:26 +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 1fd03a4a22 Issue #21155: asyncio.EventLoop.create_unix_server() now raises a ValueError if
path and sock are specified at the same time.
2014-04-07 11:18:54 +02:00
Victor Stinner e6a537976e asyncio, Tulip issue 157: Improve test_events.py, avoid run_briefly() which is
not reliable
2014-03-06 01:00:36 +01:00
Victor Stinner eeeebcd816 asyncio: Synchronize with Tulip
* Issue #159: Fix windows_utils.socketpair()

  - Use "127.0.0.1" (IPv4) or "::1" (IPv6) host instead of "localhost", because
    "localhost" may be a different IP address
  - Reject also invalid arguments: only AF_INET/AF_INET6 with SOCK_STREAM (and
    proto=0) are supported

* Reject add/remove reader/writer when event loop is closed.
* Fix ResourceWarning warnings
2014-03-06 00:52:53 +01:00
Victor Stinner 658103f84e asyncio: simplify test_events.py, don't use non local variables and don't call
assert methods in coroutines.

It also simplify merges from Tulip to Trollius (Python 2 does not support non
local variables).
2014-02-26 11:31:55 +01: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
Victor Stinner a90e8edaea asyncio: _check_resolved_address() must also accept IPv6 without flow_info and
scope_id: (host, port).
2014-02-20 21:59:38 +01:00
Victor Stinner 0211ed3e89 asyncio: ops, and now fix also the unit test for IPv6 address:
test_sock_connect_address()
2014-02-20 17:01:11 +01:00
Victor Stinner 4ac30f1792 Issue #20682: Oops, fix test_create_connection() of test_asyncio (fix my previous commit) 2014-02-19 18:32:03 +01:00
Victor Stinner 8c33ffd9b6 Close #20682: Fix UNIX sockets tests of test_asyncio on Mac OS X Tiger
On Mac OS X Tiger (and older), getsockname() returns a zero-length address for
UNIX socket, and so 'sockname' extra info is None.
2014-02-19 18:10:32 +01: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 8abac348a9 Issue #20682: test_asyncio, _basetest_create_connection() checks also the
sockname, as _basetest_create_ssl_connection().
2014-02-19 02:21:08 +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 9141bff144 Issue #20667: KqueueEventLoopTests.test_read_pty_output() hangs also on OpenBSD 5.5. 2014-02-18 09:13:47 +01:00
Victor Stinner 5afffeab73 Issue #20667: test_asyncio: Skip KqueueEventLoopTests.test_read_pty_output() on
OpenBSD older than 5.5
2014-02-18 01:30:03 +01:00
Victor Stinner 1ff0ee0be2 Fix test_asyncio/test_events.py: skip IPv6 if IPv6 is disabled on the host 2014-02-13 10:46:05 +01:00
Victor Stinner 28773465e6 ayncio, Tulip issue 129: BaseEventLoop.sock_connect() now raises an error if
the address is not resolved (hostname instead of an IP address) for AF_INET and
AF_INET6 address families.
2014-02-13 09:24:37 +01:00
Victor Stinner 13b493e8a7 Issue #20495: Skip test_read_pty_output() of test_asyncio on FreeBSD older than
FreeBSD 8
2014-02-11 18:40:56 +01:00
Victor Stinner 6cf5c96630 Issue #20505: BaseEventLoop uses again the resolution of the clock to decide if
scheduled tasks should be executed or not.
2014-02-10 23:42:32 +01:00
Victor Stinner cf736f4e98 Issue #20505: Use even shorter sleep in test_timeout_rounding() to make the
test more reliable (= fail more often on Windows with HPET enabled).
2014-02-10 19:17:46 +01:00
Victor Stinner 1c143b19c8 Issue #20505: Add debug info to analyze sporaric failures of
test_timeout_rounding() on Windows XP buildbots.
2014-02-10 11:47:50 +01:00
Victor Stinner dc62b7e261 asyncio: Tulip issue 112: Inline make_handle() into Handle constructor 2014-02-10 00:45:44 +01:00
Victor Stinner 85310a50a9 Issue #20505: Remove resolution and _granularity from selectors and asyncio
* Remove selectors.BaseSelector.resolution attribute
* Remove asyncio.BaseEventLoop._granularity attribute
2014-02-07 23:34:58 +01:00
Victor Stinner 1703bbbf89 Oops, undo unwanted changes in test_asyncio: mistakes of my the last sync with
Tulip (changeset d7ac90c0463a)
2014-02-03 23:59:52 +01:00
Victor Stinner 9dd39f524d Issue #20472: test_asyncio: skip PTY tests on Mac OS X older than 10.6 2014-02-03 00:32:13 +01:00
Victor Stinner 915bcb0111 Issue #20400: Merge Tulip into Python: add the new asyncio.subprocess module
* 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)
2014-02-01 22:49:59 +01:00
Victor Stinner 1144214639 Issue #20452: test_asyncio checks also the granularity 2014-02-01 02:17:54 +01:00
Victor Stinner 49d0f4e428 Issue #20452: Remove debug code, no more needed 2014-01-31 12:59:43 +01:00
Victor Stinner dcd9740ad2 Issue #20452: select and selectors round (again) timeout away from zero for
poll and epoll

Improve also debug info to analyze the issue
2014-01-31 12:12:53 +01:00
Victor Stinner 31f65044a9 Issue #20452: Oops, fix debug code :-/
Add also event more debug info
2014-01-31 10:55:55 +01:00
Victor Stinner 0278032110 Issue #20452: add more info in case of test_asyncio failure to try to debug the
failure on buildbot "x86 Ubuntu Shared 3.x"
2014-01-31 09:29:35 +01:00
Victor Stinner e623a12297 asyncio: subprocess_shell() and subprocess_exec() now raise ValueError instead of assert.
Moreover, bufsize different than 0 is now considered as an error.
2014-01-29 14:35:15 -08:00
Victor Stinner 669eeaf933 Merge latest Tulip into asyncio
- Make the new granularity attribute private
- Simplify BaseEventLoop._run_once(): avoid math.ceil(), use simple arithmetic
  instead
2014-01-26 00:02:31 +01:00
Victor Stinner 128ee220e2 asyncio: Don't export BaseEventLoop, BaseSelectorEventLoop nor
BaseProactorEventLoop

Import them from submodules if you really need them.
2014-01-25 22:22:18 +01: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
Victor Stinner f67255ab94 Issue #20311: asyncio: Add a granularity attribute to BaseEventLoop: maximum
between the resolution of the BaseEventLoop.time() method and the resolution of
the selector. The granuarility is used in the scheduler to round time and
deadline.
2014-01-25 15:01:33 +01:00
Victor Stinner 8ce6e1100e Close #20365: Skip test_asyncio.test_events.test_read_pty_output() on Mac OS X
older than 10.9 (Maverick). kqueue doesn't support character devices (PTY) on
Mac OS X older than 10.9.
2014-01-23 17:26:06 +01:00
Guido van Rossum 02757ea7e9 asyncio: Minimal pty support in UNIX read pipe, by Jonathan Slenders. 2014-01-10 13:30:04 -08:00