I'd do it after forking.
>
> In particular, I don't know how Django sets up its database
> connection.
A connection is created the first time you access a database and then
closed when the response is sent back (or, in standalone cases, when you
either explicitly close it or when the process ends).
> Do forked processes share one connection or does each
> process have their own connection?
The most precise answer is "it depends", but the simplest answer is that
they would be shared and it wouldn't behave as you expect. Don't do
that. Forked processes share file descriptors, for example (well,
they're duplicated, not shared), so if the connection uses a file
descriptor, which it will, that is duplicated.
> Are there pros and cons to each?
Creating the connection after forking will work. Creating the connection
before forking will likely lead to lots of difficult to diagnose race
conditions and the like.
Regards,
Malcolm
If you are still in need of a Django expert, have you checked out https://datepalm.engineering to see if they can help?
They are Django experts from what I understand, and based in the US.