test_shutdown_timeout_handler_not_set() might have a race between the
SHUT_WR message and `eof` asyncio event. This fix changes to use the
eof_received() callback triggered by SHUT_WR. Refs #412 2nd issue.
The waiter given to SSLProtocol should be woke up before the first
data callback, especially for `start_tls()` where the user protocol's
`connection_made()` won't be called and the waiter wakeup is the only
time the user have access to the new SSLTransport for the first time.
The user may want to e.g. check ALPN before handling the first data,
it's better that uvloop doesn't force the user to check this by
themselves.
Because `context.run()` doesn't hold reference to the callable, when
e.g. the protocol is written in Cython, the callbacks were not
guaranteed to hold the protocol reference. This PR fixes the issue by
explicitly add a reference before `context.run()` calls.
Refs edgedb/edgedb#2222
This aligns uvloop with the same behavior in asyncio - when stdin,
stdout or stderr is None, the subprocess will use FD 0, 1 or 2 now
instead of sys.stdin, sys.stdout or sys.stderr.
Fixes#136
* Don't stop the loop in run_until_complete on SystemExit & KeyboardInterrupt
* Add unit test (based on CPython's equivalent)
* Fix the test to resume its coverage.
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
Co-authored-by: Fantix King <fantix.king@gmail.com>
This is a combined fix to correct contexts from which protocal callbacks
are invoked. In short, callbacks like data_received() should always be
invoked from consistent contexts which are copied from the context where
the underlying UVHandle is created or started.
The new test case covers also asyncio, but skipping the failing ones.
* Also add subprocess test case using Path object
* uvloop already handles path-like cwd correctly, so I just
copy-and-pasted the same logic to _init_args() method.
* The standard library uses "isinstance(obj, os.PathLike)" to check
if an object is path-like, but os.PathLike exists as of Python 3.6.
Since uvloop needs to support Python 3.5, we should use manual check
for existence of the __fspath__ attribute.
* According to the official Python documentation:
- https://docs.python.org/3/library/subprocess.html#subprocess.Popen
The subprocess.Popen() constructor support path-like objects since
Python 3.6 on POSIX and since Python 3.8 on Windows.
- https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_exec
This page does not mention about path-like objects,
but as of Python 3.8, it DOES support path-like objects.