Lib/test/mp_preload.py
raw| 1 | import multiprocessing |
| 2 | |
| 3 | multiprocessing.Lock() |
| 4 | |
| 5 | |
| 6 | def f(): |
| 7 | print("ok") |
| 8 | |
| 9 | |
| 10 | if __name__ == "__main__": |
| 11 | ctx = multiprocessing.get_context("forkserver") |
| 12 | modname = "test.mp_preload" |
| 13 | # Make sure it's importable |
| 14 | __import__(modname) |
| 15 | ctx.set_forkserver_preload([modname]) |
| 16 | proc = ctx.Process(target=f) |
| 17 | proc.start() |
| 18 | proc.join() |