pytest-dev / pytest-dev/pytest-xdist

EOFError when executiong pytest with --looponfail

Open
#625 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

Exception raised while running pytest -f with EXECNET_DEBUG=2

[2064] gw0 [receiver-thread] received <Message CHANNEL_DATA channel=2 lendata=73>
[2068] gw0-worker sent <Message CHANNEL_DATA channel=2 lendata=73>
[2064] gw0 [receiver-thread] received <Message CHANNEL_DATA channel=2 lendata=73>
[2068] gw0-worker sent <Message CHANNEL_DATA channel=2 lendata=73>
[2064] gw0 [receiver-thread] EOF without prior gateway termination message
[2064] gw0 [receiver-thread] finishing receiving thread
[2064] gw0 [receiver-thread] terminating execution
[2064] gw0 [receiver-thread] closing read
[2064] gw0 gateway.exit() called
[2064] gw0 --> sending GATEWAY_TERMINATE
[2064] gw0 [receiver-thread] closing write
[2064] gw0 failed to send <Message GATEWAY_TERMINATE channel=0 lendata=0> [Errno 32] Broken pipe
[2064] gw0 io-error: could not send termination sequence
[2064] gw0  exception: OSError('cannot send (already closed?)')
Traceback (most recent call last):
  File "/code/.venv/lib/python3.8/site-packages/execnet/gateway_base.py", line 432, in from_io
    header = io.read(9)  # type 1, channel 4, payload 4
  File "/code/.venv/lib/python3.8/site-packages/execnet/gateway_base.py", line 402, in read
    raise EOFError("expected %d bytes, got %d" % (numbytes, len(buf)))
EOFError: expected 9 bytes, got 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/code/.venv/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/code/.venv/lib/python3.8/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/code/.venv/lib/python3.8/site-packages/_pytest/config/__init__.py", line 162, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/code/.venv/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/code/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/code/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/code/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/code/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/code/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/code/.venv/lib/python3.8/site-packages/xdist/looponfail.py", line 35, in pytest_cmdline_main
    looponfail_main(config)
  File "/code/.venv/lib/python3.8/site-packages/xdist/looponfail.py", line 45, in looponfail_main
    remotecontrol.loop_once()
  File "/code/.venv/lib/python3.8/site-packages/xdist/looponfail.py", line 117, in loop_once
    result = self.runsession()
  File "/code/.venv/lib/python3.8/site-packages/xdist/looponfail.py", line 106, in runsession
    return self.channel.receive()
  File "/code/.venv/lib/python3.8/site-packages/execnet/gateway_base.py", line 749, in receive
    raise self._getremoteerror() or EOFError()
  File "/code/.venv/lib/python3.8/site-packages/execnet/gateway_base.py", line 967, in _thread_receiver
    msg = Message.from_io(io)
  File "/code/.venv/lib/python3.8/site-packages/execnet/gateway_base.py", line 437, in from_io
    raise EOFError("couldnt load message header, " + e.args[0])
EOFError: couldnt load message header, expected 9 bytes, got 0
[2064] === atexit cleanup <Group []> ===

Dependency tree

pytest-xdist==2.2.0
  - execnet [required: >=1.1, installed: 1.8.0]
    - apipkg [required: >=1.4, installed: 1.5]
  - pytest [required: >=6.0.0, installed: 6.2.2]
    - attrs [required: >=19.2.0, installed: 20.3.0]
    - iniconfig [required: Any, installed: 1.1.1]
    - packaging [required: Any, installed: 20.9]
      - pyparsing [required: >=2.0.2, installed: 2.4.7]
    - pluggy [required: <1.0.0a1,>=0.12, installed: 0.13.1]
    - py [required: >=1.8.2, installed: 1.10.0]
    - toml [required: Any, installed: 0.10.2]
  - pytest-forked [required: Any, installed: 1.3.0]
    - py [required: Any, installed: 1.10.0]
    - pytest [required: >=3.10, installed: 6.2.2]
      - attrs [required: >=19.2.0, installed: 20.3.0]
      - iniconfig [required: Any, installed: 1.1.1]
      - packaging [required: Any, installed: 20.9]
        - pyparsing [required: >=2.0.2, installed: 2.4.7]
      - pluggy [required: <1.0.0a1,>=0.12, installed: 0.13.1]
      - py [required: >=1.8.2, installed: 1.10.0]
      - toml [required: Any, installed: 0.10.2]

Project is fairly basic. Running in a ubuntu:focal container using a pipenv managed virtualenv.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing pytest -f with EXECNET_DEBUG=2 in the Ubuntu Focal/Pipenv setup described. Read xdist/looponfail.py around looponfail_main, loop_once, and runsession, then inspect the reported execnet/gateway_base.py receiver path; done means the EOFError and broken-pipe failure are resolved or clearly diagnosed with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.