Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent parallel test crash on macOS #739

Open
lennax opened this issue Dec 3, 2021 · 2 comments
Open

Intermittent parallel test crash on macOS #739

lennax opened this issue Dec 3, 2021 · 2 comments

Comments

@lennax
Copy link

lennax commented Dec 3, 2021

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 /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.

@asottile
Copy link
Member

asottile commented Dec 5, 2021

can you provide more information about how to reproduce this?

@lennax
Copy link
Author

lennax commented Dec 7, 2021

In hindsight, this should have been phrased as, "feature request: add ability to force macOS parallel workers to run in main thread".

I know that 99% of the time when someone says "this issue is specific to my setup and I can't reproduce it consistently", it's not a real issue.

However, while that is what I am saying, I sincerely believe it is indeed a real issue (that has caused issues for others in the past).

  1. pytest-xdist spawns workers on macOS that are not running in the main thread (Question: Is it expected, that the tests run in the main thread? #469)
  2. our crash condition occurs when a pytest-xdist worker is running in a thread that is not the main thread (as reported by others in the pytest-xdist issue)

What I'm hoping to obtain is assistance with figuring out how to restart workers that are not in the main thread, in the short term to fix our crash, and in the long term to help others in the future who may also have issues with non-main-thread workers. If a github issue is not the appropriate place to get this kind of assistance, please let me know a better place to post this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants