Opened 4 years ago

Last modified 18 months ago

#31169 closed New feature

Parallel test mode not working on MacOS with recent versions of Python 3 — at Version 1

Reported by: Brandon Navra Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Ichlasul Affan, Ryan Siemens, Adam Wróbel Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Brandon Navra)

Python 3.8 on MacOS has changed the default start method for the multiprocessing module from fork to spawn: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods.

When running tests with the --parallel flag, this causes the worker processes to fail with django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. as they no longer have a copy of the parent memory state. It can also cause the workers to fail to find the cloned dbs ( {{django.db.utils.OperationalError: FATAL: database "xxx_1" does not exist}} ) as the db test prefix is missing.

I have attached a patch which changes django.test.runner._init_worker (the worker initialiser for ParallelTestSuite) to run django.setup() and set the db name to one with the test_ prefix.

Change History (2)

comment:1 by Brandon Navra, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top