Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use multiprocessing at all? #464

Answered by kernc
rubslopes asked this question in Q&A
Discussion options

Is there a tutorial? I searched a lot but I couldn't find one. But running the optimizer gives the message For multiprocessing support in Backtest.optimize() set multiprocessing start method to 'fork'.

I am a Mac user.

Thank you!

You must be logged in to vote

See Contexts and Start Methods in Python multiprocessing docs.

Replies: 3 comments 3 replies

Comment options

See Contexts and Start Methods in Python multiprocessing docs.

You must be logged in to vote
1 reply
Comment options

Thanks!

For anyone wondering, simply include this in your code:

import multiprocessing as mp
mp.set_start_method('fork')

This only works on Unix systems.

Answer selected by rubslopes
Comment options

tried this. getting: RuntimeError: context has already been set

You must be logged in to vote
1 reply
Comment options

You should run mp.set_start_method('fork') only once when importing. Don't run it again.

Comment options

import multiprocessing as mp
try:
 # mp.set_start_method("spawn", force=True)
 # print("spawned")
 mp.set_start_method("fork", force=True)
 print("forked")
except RuntimeError:
 pass
You must be logged in to vote
1 reply
Comment options

It works also on iOS (MacBook Pro)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /