Browse Source

指定cpu

Daniel 1 year ago
parent
commit
b55327551a
1 changed files with 3 additions and 0 deletions
  1. 3 0
      backtrader/230503_bt.py

+ 3 - 0
backtrader/230503_bt.py

@@ -12,6 +12,7 @@ from datetime import datetime as dt
 import multiprocessing as mp
 from backtrader.feeds import PandasData
 import platform
+import psutil
 # import multiprocessing
 # import matplotlib
 
@@ -266,6 +267,8 @@ def backtrader(list_date, table_list, result, result_change, result_change_fall,
 if __name__ == '__main__':
     starttime = dt.now()
     print(starttime)
+    pus = psutil.Process()
+    pus.cpu_affinity([0, 1, 2, 3, 4, 5, 6, 7])
     # print(type(platform.node()))
     # engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/hlfx?charset=utf8', poolclass=NullPool)