Skip to content

test_asyncio: test_sendfile_close_peer_in_the_middle_of_receiving() of ProactorEventLoop logs InvalidStateError error #78015

Closed

Description

@twisteroidambassador
BPO 33834
Nosy @vstinner, @asvetlov, @1st1, @twisteroidambassador, @neyuru
Superseder
  • bpo-35682: asyncio: bug in _ProactorBasePipeTransport._force_close()
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-01-08.15:16:18.102>
    created_at = <Date 2018-06-11.14:03:22.645>
    labels = ['type-bug', '3.8', 'expert-asyncio']
    title = 'test_asyncio: test_sendfile_close_peer_in_the_middle_of_receiving() of ProactorEventLoop logs InvalidStateError error'
    updated_at = <Date 2019-01-08.15:16:18.101>
    user = 'https://github.com/twisteroidambassador'

    bugs.python.org fields:

    activity = <Date 2019-01-08.15:16:18.101>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-08.15:16:18.102>
    closer = 'vstinner'
    components = ['asyncio']
    creation = <Date 2018-06-11.14:03:22.645>
    creator = 'twisteroid ambassador'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33834
    keywords = []
    message_count = 4.0
    messages = ['319303', '320588', '329216', '333233']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'asvetlov', 'yselivanov', 'twisteroid ambassador', 'neyuru']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '35682'
    type = 'behavior'
    url = 'https://bugs.python.org/issue33834'
    versions = ['Python 3.8']

    Activity

    1. twisteroidambassador commented on Jun 11, 2018

      twisteroidambassadormannequin
      MannequinAuthor

      When running the built-in regression tests, although test_sendfile_close_peer_in_the_middle_of_receiving on ProactorEventLoop completes successfully, an InvalidStateError is logged.

      Console output below:

      test_sendfile_close_peer_in_the_middle_of_receiving (test.test_asyncio.test_events.ProactorEventLoopTests) ... Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)
      handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)>
      Traceback (most recent call last):
        File "<snip>\cpython\lib\asyncio\windows_events.py", line 428, in finish_recv
          return ov.getresult()
      OSError: [WinError 64] The specified network name is no longer available
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<snip>\cpython\lib\asyncio\proactor_events.py", line 255, in _loop_reading
          data = fut.result()
        File "<snip>\cpython\lib\asyncio\windows_events.py", line 732, in _poll
          value = callback(transferred, key, ov)
        File "<snip>\cpython\lib\asyncio\windows_events.py", line 432, in finish_recv
          raise ConnectionResetError(*exc.args)
      ConnectionResetError: [WinError 64] The specified network name is no longer available
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<snip>\cpython\lib\asyncio\events.py", line 88, in _run
          self._context.run(self._callback, *self._args)
        File "<snip>\cpython\lib\asyncio\proactor_events.py", line 282, in _loop_reading
          self._force_close(exc)
        File "<snip>\cpython\lib\asyncio\proactor_events.py", line 117, in _force_close
          self._empty_waiter.set_exception(exc)
      concurrent.futures._base.InvalidStateError: invalid state
      ok
    2. vstinner commented on Jun 27, 2018

      @vstinner
      Member

      bpo-33981 has been marked as a duplicate of this issue. Copy of messages:

      msg320583 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-27 14:26

      Python 3.8 (master) on Windows 10:

      C:\vstinner\python\master>python -m test test_asyncio -m test_sendfile_close_peer_in_the_middle_of_receiving -v
      Running Debug|x64 interpreter...
      == CPython 3.8.0a0 (heads/wip:dd08b85c84, Jun 26 2018, 12:47:56) [MSC v.1914 64 bit (AMD64)]
      == Windows-10-10.0.16299-SP0 little-endian
      == cwd: C:\vstinner\python\master\build\test_python_7020
      == CPU count: 2
      == encodings: locale=cp1252, FS=utf-8
      Run tests sequentially
      0:00:00 [1/1] test_asyncio
      test_sendfile_close_peer_in_the_middle_of_receiving (test.test_asyncio.test_events.ProactorEventLoopTests) ... Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)
      handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)>
      Traceback (most recent call last):
        File "C:\vstinner\python\master\lib\asyncio\windows_events.py", line 428, in finish_recv
          return ov.getresult()
      OSError: [WinError 64] The specified network name is no longer available
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "C:\vstinner\python\master\lib\asyncio\proactor_events.py", line 255, in _loop_reading
          data = fut.result()
        File "C:\vstinner\python\master\lib\asyncio\windows_events.py", line 732, in _poll
          value = callback(transferred, key, ov)
        File "C:\vstinner\python\master\lib\asyncio\windows_events.py", line 432, in finish_recv
          raise ConnectionResetError(*exc.args)
      ConnectionResetError: [WinError 64] The specified network name is no longer available
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "C:\vstinner\python\master\lib\asyncio\events.py", line 88, in _run
          self._context.run(self._callback, *self._args)
        File "C:\vstinner\python\master\lib\asyncio\proactor_events.py", line 282, in _loop_reading
          self._force_close(exc)
        File "C:\vstinner\python\master\lib\asyncio\proactor_events.py", line 117, in _force_close
          self._empty_waiter.set_exception(exc)
      concurrent.futures._base.InvalidStateError: invalid state
      ok
      test_sendfile_close_peer_in_the_middle_of_receiving (test.test_asyncio.test_events.SelectEventLoopTests) ... ok

      Ran 2 tests in 0.111s

      OK

      == Tests result: SUCCESS ==

      1 test OK.

      Total duration: 453 ms
      Tests result: SUCCESS

      msg320586 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-27 14:30

      See also bpo-32710: "test_asyncio leaked [4, 4, 3] memory blocks, sum=11 on AMD64 Windows8.1 Refleaks 3.x".

      msg320587 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-27 14:31

      Oh, it's a duplicate of bpo-33834.

    3. changed the title [-]Test for ProactorEventLoop logs InvalidStateError[/-] [+]test_asyncio: test_sendfile_close_peer_in_the_middle_of_receiving() of ProactorEventLoop logs InvalidStateError error[/+] on Jun 27, 2018
    4. neyuru commented on Nov 4, 2018

      neyurumannequin
      Mannequin

      While building 3.6.7. Path set to 3.6.7 working directory

      Running PGInstrument|x64 interpreter...
      Run tests sequentially
      Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)
      handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...ne, 64, None)>)>
      Traceback (most recent call last):
        File "E:\cpython\lib\asyncio\windows_events.py", line 429, in finish_recv
          return ov.getresult()
      OSError: [WinError 64] El nombre de red especificado ya no está disponible
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "E:\cpython\lib\asyncio\proactor_events.py", line 256, in _loop_reading
          data = fut.result()
        File "E:\cpython\lib\asyncio\windows_events.py", line 733, in _poll
          value = callback(transferred, key, ov)
        File "E:\cpython\lib\asyncio\windows_events.py", line 433, in finish_recv
          raise ConnectionResetError(*exc.args)
      ConnectionResetError: [WinError 64] El nombre de red especificado ya no está disponible
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "E:\cpython\lib\asyncio\events.py", line 81, in _run
          self._context.run(self._callback, *self._args)
        File "E:\cpython\lib\asyncio\proactor_events.py", line 283, in _loop_reading
          self._force_close(exc)
        File "E:\cpython\lib\asyncio\proactor_events.py", line 118, in _force_close
          self._empty_waiter.set_exception(exc)
      asyncio.exceptions.InvalidStateError: invalid state
      An open stream object is being garbage collected; call "stream.close()" explicitly.
      Task was destroyed but it is pending!
      task: <Task pending name='Task-2689' coro=<<async_generator_athrow without __name__>()>>
      Task was destroyed but it is pending!
      task: <Task pending name='Task-2691' coro=<<async_generator_athrow without __name__>()>>
      Task was destroyed but it is pending!
      task: <Task pending name='Task-2696' coro=<<async_generator_athrow without __name__>()>>
    5. vstinner commented on Jan 8, 2019

      @vstinner
      Member

      Duplicate of bpo-35682 and fixed by:

      commit 80fda71
      Author: Victor Stinner <vstinner@redhat.com>
      Date: Tue Jan 8 02:46:59 2019 +0100

      bpo-35682: Fix _ProactorBasePipeTransport._force_close() (GH-11462)
      
      bpo-32622, bpo-35682: Fix asyncio.ProactorEventLoop.sendfile(): don't
      attempt to set the result of an internal future if it's already done.
      
      Fix asyncio _ProactorBasePipeTransport._force_close(): don't set the
      result of _empty_waiter if it's already done.
      
    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions