mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 11:51:19 +00:00
refactor: switch mp-method to forkserver globally
This commit is contained in:
@@ -18,7 +18,12 @@ from freqtrade.commands import Arguments
|
||||
from freqtrade.constants import DOCS_LINK
|
||||
from freqtrade.exceptions import ConfigurationError, FreqtradeException, OperationalException
|
||||
from freqtrade.loggers import setup_logging_pre
|
||||
from freqtrade.system import asyncio_setup, gc_set_threshold, print_version_info
|
||||
from freqtrade.system import (
|
||||
asyncio_setup,
|
||||
gc_set_threshold,
|
||||
print_version_info,
|
||||
set_mp_start_method,
|
||||
)
|
||||
|
||||
|
||||
logger = logging.getLogger("freqtrade")
|
||||
@@ -44,6 +49,7 @@ def main(sysargv: list[str] | None = None) -> None:
|
||||
elif "func" in args:
|
||||
logger.info(f"freqtrade {__version__}")
|
||||
gc_set_threshold()
|
||||
set_mp_start_method()
|
||||
return_code = args["func"](args)
|
||||
else:
|
||||
# No subcommand was issued.
|
||||
|
||||
@@ -7,7 +7,7 @@ import logging
|
||||
import sys
|
||||
import warnings
|
||||
from datetime import UTC, datetime
|
||||
from multiprocessing import Manager, get_all_start_methods, set_start_method
|
||||
from multiprocessing import Manager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -125,12 +125,6 @@ class HyperOptimizer:
|
||||
local_queue must be a global and passed to the child process via inheritance.
|
||||
"""
|
||||
global log_queue
|
||||
try:
|
||||
sms = get_all_start_methods()
|
||||
if "forkserver" in sms:
|
||||
set_start_method("forkserver")
|
||||
except RuntimeError:
|
||||
pass # start method has already been set
|
||||
m = Manager()
|
||||
log_queue = m.Queue()
|
||||
logger.info(f"manager queue {type(log_queue)}")
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
from freqtrade.system.asyncio_config import asyncio_setup
|
||||
from freqtrade.system.gc_setup import gc_set_threshold
|
||||
from freqtrade.system.set_mp_start_method import set_mp_start_method
|
||||
from freqtrade.system.version_info import print_version_info
|
||||
|
||||
|
||||
__all__ = ["asyncio_setup", "gc_set_threshold", "print_version_info"]
|
||||
__all__ = ["asyncio_setup", "gc_set_threshold", "print_version_info", "set_mp_start_method"]
|
||||
|
||||
14
freqtrade/system/set_mp_start_method.py
Normal file
14
freqtrade/system/set_mp_start_method.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from multiprocessing import get_all_start_methods, get_start_method, set_start_method
|
||||
|
||||
|
||||
def set_mp_start_method():
|
||||
"""
|
||||
Set multiprocessing start method to not be fork.
|
||||
forkserver will become the default in 3.14 - and is deprecated in 3.13
|
||||
"""
|
||||
try:
|
||||
sms = get_all_start_methods()
|
||||
if "forkserver" in sms and get_start_method(True) is None:
|
||||
set_start_method("forkserver")
|
||||
except RuntimeError:
|
||||
pass
|
||||
Reference in New Issue
Block a user