File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 6767
6868from . import lib # noqa: F401
6969from ._plotting import set_bokeh_output # noqa: F401
70+ from ._util import try_
7071from .backtesting import Backtest , Strategy # noqa: F401
7172
7273
7374# Add overridable backtesting.Pool used for parallel optimization
7475def Pool (processes = None , initializer = None , initargs = ()):
7576 import multiprocessing as mp
77+ import sys
78+ # Revert performance related change in Python>=3.14
79+ if sys .platform .startswith ('linux' ) and mp .get_start_method (allow_none = True ) != 'fork' :
80+ try_ (lambda : mp .set_start_method ('fork' ))
7681 if mp .get_start_method () == 'spawn' :
7782 import warnings
7883 warnings .warn (
Original file line number Diff line number Diff line change @@ -1039,10 +1039,13 @@ class TestDocs(TestCase):
10391039 DOCS_DIR = os .path .join (os .path .dirname (__file__ ), '..' , '..' , 'doc' )
10401040
10411041 @unittest .skipUnless (os .path .isdir (DOCS_DIR ), "docs dir doesn't exist" )
1042+ @unittest .skipUnless (sys .platform .startswith ('linux' ), "test_examples requires mp.start_method=fork" )
10421043 def test_examples (self ):
1044+ import backtesting
10431045 examples = glob (os .path .join (self .DOCS_DIR , 'examples' , '*.py' ))
10441046 self .assertGreaterEqual (len (examples ), 4 )
1045- with chdir (gettempdir ()):
1047+ with chdir (gettempdir ()), \
1048+ patch (backtesting , 'Pool' , mp .get_context ('fork' ).Pool ):
10461049 for file in examples :
10471050 with self .subTest (example = os .path .basename (file )):
10481051 run_path (file )
You can’t perform that action at this time.
0 commit comments