MCPcopy Index your code
hub / github.com/python/cpython / len_message

Method len_message

Lib/test/test_asyncio/test_subprocess.py:421–432  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

419 # asyncio issue #209: stdin must not be inheritable, otherwise
420 # the Process.communicate() hangs
421 async def len_message(message):
422 code = 'import sys; data = sys.stdin.read(); print(len(data))'
423 proc = await asyncio.create_subprocess_exec(
424 sys.executable, '-c', code,
425 stdin=asyncio.subprocess.PIPE,
426 stdout=asyncio.subprocess.PIPE,
427 stderr=asyncio.subprocess.PIPE,
428 close_fds=False,
429 )
430 stdout, stderr = await proc.communicate(message)
431 exitcode = await proc.wait()
432 return (stdout, exitcode)
433
434 output, exitcode = self.loop.run_until_complete(len_message(b'abc'))
435 self.assertEqual(output.rstrip(), b'3')

Callers

nothing calls this directly

Calls 2

communicateMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected