pytest-dev / pytest-dev/pytest-xdist

Intermittent parallel test crash on macOS

Open
#739 2 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

I see an intermittent parallel test crash on macOS 10.14.

pytest==6.2.2
pytest-cov==2.10.1
pytest-forked==1.3.0
pytest-xdist==2.2.1

Crashed Thread:        2
--
 
Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY
 
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
terminating with uncaught exception of type NSException
abort() called

It's very infrequent (<1/100) so it's been difficult to debug, but it's a problem for our CI.

This occurs because execnet does not guarantee that workers are started in the main thread (see pytest-dev/pytest-xdist/issues/469)

We believe it can be fixed by

  1. detecting when a worker is started in a not-main-thread
  2. restarting the worker until the worker is in the main thread

We have code to do 1, but need help doing 2.

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 reading the existing worker-start detection code and the related pytest-dev/pytest-xdist issue 469, then examine how execnet starts workers during parallel tests. Reproduce the macOS failure in CI if possible; done means workers started off the main thread are restarted until they run on the main thread, with coverage for the retry behavior.

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
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.