I'm trying to learn to use the multiprocessing module. Something rather strange is happening. The process I spawn doesn't finish, the script just finishes instantly.
from time import sleep
from x import a, b, c
import multiprocessing as mp
import sys
def s():
sleep(5)
if __name__ == '__main__':
p = mp.Process(target = s)
p.start()
p.join()
Instead of sleeping for 5s, the code just finishes. If I comment out the import it sleeps.
The x contains functions a, b, c, imports from math and a global variable. So looks something like this:
from math import sin,cos
g = 9.81
def a():
...
def b():
...
def c():
...
I haven't grasped the import logic properly, but I can't seem to figure out what is wrong, just makes no sense to me. I'm definitely not running any code in x.