Browse Source

多进程问题

Daniel 2 years ago
parent
commit
ff3372328e
2 changed files with 12 additions and 1 deletions
  1. 9 1
      QMT/qmt_real_hlfx.py
  2. 3 0
      docker.start.txt

+ 9 - 1
QMT/qmt_real_hlfx.py

@@ -1,10 +1,11 @@
 # coding:utf-8
-from jqdatasdk import *
+# from jqdatasdk import *
 import pandas as pd
 import pymysql
 from sqlalchemy import create_engine
 import threading
 from datetime import datetime as dt
+import datetime
 from jqdatasdk.technical_analysis import *
 from xtquant import xtdata, xtconstant
 from xtquant.xttype import StockAccount
@@ -13,6 +14,8 @@ import time
 import math
 import multiprocessing as mp
 import os
+import psutil
+import traceback
 #原始版本
 
 # auth('18616891214', 'Ea?*7f68nD.dafcW34d!')
@@ -90,6 +93,7 @@ class MyXtQuantTraderCallback(XtQuantTraderCallback):
 
 def err_call_back(err):
     print(f'问题在这里~ error:{str(err)}')
+    traceback.print_exc()
 
 
 def hlfx(data, stocks, pool_list):
@@ -300,6 +304,10 @@ def prepare():
 
 
 if __name__ == '__main__':
+    mp.freeze_support()
+    pus = psutil.Process()
+    pus.cpu_affinity([0, 1, 2, 3])
+
     path = r'c:\\qmt\\userdata_mini'
     # 生成session id 整数类型 同时运行的策略不能重复
     session_id = int(time.time())

+ 3 - 0
docker.start.txt

@@ -2,4 +2,7 @@ docker run -itd --name mysql8 -p 3307:3306 -e MYSQL_ROOT_PASSWORD=r6kEwqWU9!v3 -
 
 docker run -itd --name mysql82 -p 3312:3306 -e MYSQL_ROOT_PASSWORD=r6kEwqWU9!v3 mysql:8.0.28-oracle
 
+
+mysqldump -uroot -pr6kEwqWU9!v3 -P3307 --databases qmt_stocks_whole >d:/qmt_stocks_whole.sql
+
 # version order 1