[Fixed]-Apps aren't loaded yet exception occurs when using multi-processing in Django


This post can solve the problem.

Django upgrading to 1.9 error “AppRegistryNotReady: Apps aren’t loaded yet.”

I had found this answer before, but not actually solve my problems at that time.

After I repeated test, I have to add these codes before import another model,
otherwise, child-process will booting failed and give the error.

import django
from another.app import models


For others that might stumble upon this in future:

If you encounter this issue while running Python 3.8 and trying to use multiprocessing package, chances are that it is due to the sub processed are ‘spawned’ instead of ‘forked’. This is a change with Python 3.8 on Mac OS where the default process start method is changed from ‘fork’ to ‘spawn’.
This is a known issue with Django.

To get around it:

import multiprocessing as mp

Leave a comment