Title: subprocess._loop deleted too soon causing exception when trying to read from pipe · Issue #484 · python/asyncio · GitHub
Open Graph Title: subprocess._loop deleted too soon causing exception when trying to read from pipe · Issue #484 · python/asyncio
X Title: subprocess._loop deleted too soon causing exception when trying to read from pipe · Issue #484 · python/asyncio
Description: From https://bugs.python.org/issue23242#msg284930 The following script is used to reproduce the bug: import asyncio async def execute(): process = await asyncio.create_subprocess_exec( "timeout", "0.1", "cat", "/dev/urandom", stdout=asyn...
Open Graph Description: From https://bugs.python.org/issue23242#msg284930 The following script is used to reproduce the bug: import asyncio async def execute(): process = await asyncio.create_subprocess_exec( "timeout", "...
X Description: From https://bugs.python.org/issue23242#msg284930 The following script is used to reproduce the bug: import asyncio async def execute(): process = await asyncio.create_subprocess_exec( "timeou...
Opengraph URL: https://github.com/python/asyncio/issues/484
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"subprocess._loop deleted too soon causing exception when trying to read from pipe","articleBody":"From https://bugs.python.org/issue23242#msg284930 \r\n\r\nThe following script is used to reproduce the bug:\r\n```python\r\nimport asyncio\r\n\r\nasync def execute():\r\n process = await asyncio.create_subprocess_exec(\r\n \"timeout\", \"0.1\", \"cat\", \"/dev/urandom\", stdout=asyncio.subprocess.PIPE)\r\n\r\n while True:\r\n data = await process.stdout.read(65536)\r\n print('read %d bytes' % len(data))\r\n if data:\r\n await asyncio.sleep(0.3)\r\n else:\r\n break\r\n\r\nasyncio.get_event_loop().run_until_complete(execute())\r\n```\r\nwill produce following output and terminate with exception:\r\n```\r\nread 65536 bytes\r\nread 65536 bytes\r\nTraceback (most recent call last):\r\n File \"read_subprocess.py\", line 18, in \u003cmodule\u003e\r\n asyncio.get_event_loop().run_until_complete(execute())\r\n File \"/usr/lib/python3.6/asyncio/base_events.py\", line 466, in run_until_complete\r\n return future.result()\r\n File \"read_subprocess.py\", line 9, in execute\r\n data = await process.stdout.read(65536)\r\n File \"/usr/lib/python3.6/asyncio/streams.py\", line 634, in read\r\n self._maybe_resume_transport()\r\n File \"/usr/lib/python3.6/asyncio/streams.py\", line 402, in _maybe_resume_transport\r\n self._transport.resume_reading()\r\n File \"/usr/lib/python3.6/asyncio/unix_events.py\", line 401, in resume_reading\r\n self._loop._add_reader(self._fileno, self._read_ready)\r\nAttributeError: 'NoneType' object has no attribute '_add_reader'\r\n```\r\n\r\nWhen the process exits https://github.com/python/asyncio/blob/master/asyncio/unix_events.py#L444 is called which sets this._loop = None\r\nNext time read() is called on the pipe the above exception is thrown.\r\nI have tried to fix this issue myself but would sometimes have read terminate too early and miss the last chunks of data.","author":{"url":"https://github.com/BotoX","@type":"Person","name":"BotoX"},"datePublished":"2017-01-13T20:51:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/484/asyncio/issues/484"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ed224ab9-747f-9503-beb9-03ba9bd3f38d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A52C:C76C3:4A7B43:664812:6969DDC9 |
| html-safe-nonce | f37fd421e7d265921889e0649a95f6835040f69a19b2d5e948a21f2fa2616bce |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTJDOkM3NkMzOjRBN0I0Mzo2NjQ4MTI6Njk2OUREQzkiLCJ2aXNpdG9yX2lkIjoiMjUxOTY1NDQyODY2NjYxNzI4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4dc3829c33df51f5df80ff68f35cad6e2e2f5eb99cee7419ce55c929e665211a |
| hovercard-subject-tag | issue:200727755 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/asyncio/484/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1de9fed2017f31302d411d29ef73de9444d239ff4f1401e0327f92a02999d36b/python/asyncio/issues/484 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1de9fed2017f31302d411d29ef73de9444d239ff4f1401e0327f92a02999d36b/python/asyncio/issues/484 |
| og:image:alt | From https://bugs.python.org/issue23242#msg284930 The following script is used to reproduce the bug: import asyncio async def execute(): process = await asyncio.create_subprocess_exec( "timeout", "... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BotoX |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/asyncio git https://github.com/python/asyncio.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 33739295 |
| octolytics-dimension-repository_nwo | python/asyncio |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33739295 |
| octolytics-dimension-repository_network_root_nwo | python/asyncio |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width