return transport, protocol
@tasks.coroutine
- def subprocess_exec(self, protocol_factory, program, *args, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=False, shell=False, bufsize=0,
- **kwargs):
+ def subprocess_exec(self, protocol_factory, program, *args,
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, universal_newlines=False,
+ shell=False, bufsize=0, **kwargs):
if universal_newlines:
raise ValueError("universal_newlines must be False")
if shell:
% type(arg).__name__)
protocol = protocol_factory()
transport = yield from self._make_subprocess_transport(
- protocol, popen_args, False, stdin, stdout, stderr, bufsize, **kwargs)
+ protocol, popen_args, False, stdin, stdout, stderr,
+ bufsize, **kwargs)
return transport, protocol
def set_exception_handler(self, handler):
return Process(transport, protocol, loop)
@tasks.coroutine
-def create_subprocess_exec(program, *args, stdin=None, stdout=None, stderr=None,
- loop=None, limit=streams._DEFAULT_LIMIT, **kwds):
+def create_subprocess_exec(program, *args, stdin=None, stdout=None,
+ stderr=None, loop=None,
+ limit=streams._DEFAULT_LIMIT, **kwds):
if loop is None:
loop = events.get_event_loop()
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
'sys.stdout.buffer.write(data)'))]
class SubprocessMixin:
+
def test_stdin_stdout(self):
args = PROGRAM_CAT
if sys.platform != 'win32':
# Unix
class SubprocessWatcherMixin(SubprocessMixin):
+
Watcher = None
def setUp(self):
self.loop.close()
policy.set_event_loop(None)
- class SubprocessSafeWatcherTests(SubprocessWatcherMixin, unittest.TestCase):
+ class SubprocessSafeWatcherTests(SubprocessWatcherMixin,
+ unittest.TestCase):
+
Watcher = unix_events.SafeChildWatcher
- class SubprocessFastWatcherTests(SubprocessWatcherMixin, unittest.TestCase):
+ class SubprocessFastWatcherTests(SubprocessWatcherMixin,
+ unittest.TestCase):
+
Watcher = unix_events.FastChildWatcher
+
else:
# Windows
class SubprocessProactorTests(SubprocessMixin, unittest.TestCase):
+
def setUp(self):
policy = asyncio.get_event_loop_policy()
self.loop = asyncio.ProactorEventLoop()
self.assertEqual(set(f.result() for f in done), {'a', 'b'})
def test_as_completed_duplicate_coroutines(self):
+
@asyncio.coroutine
def coro(s):
return s
def runner():
result = []
c = coro('ham')
- for f in asyncio.as_completed([c, c, coro('spam')], loop=self.loop):
+ for f in asyncio.as_completed([c, c, coro('spam')],
+ loop=self.loop):
result.append((yield from f))
return result
tr._close.assert_called_with(err)
m_logexc.assert_called_with(
test_utils.MockPattern(
- 'Fatal read error on pipe transport\nprotocol:.*\ntransport:.*'),
+ 'Fatal read error on pipe transport'
+ '\nprotocol:.*\ntransport:.*'),
exc_info=(OSError, MOCK_ANY, MOCK_ANY))
@unittest.mock.patch('os.read')
self.assertTrue(tr._closing)
m_logexc.assert_called_with(
test_utils.MockPattern(
- 'Fatal write error on pipe transport\nprotocol:.*\ntransport:.*'),
+ 'Fatal write error on pipe transport'
+ '\nprotocol:.*\ntransport:.*'),
exc_info=(OSError, MOCK_ANY, MOCK_ANY))
self.assertEqual(1, tr._conn_lost)
test_utils.run_briefly(self.loop)