From d375b0f7dc442df442cc817f9f61c7ae9cec2540 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 21 Nov 2017 15:18:02 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8Dstrptime=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/futuGateway/futuGateway.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vnpy/trader/gateway/futuGateway/futuGateway.py b/vnpy/trader/gateway/futuGateway/futuGateway.py index 49a5947d..ccef455b 100644 --- a/vnpy/trader/gateway/futuGateway/futuGateway.py +++ b/vnpy/trader/gateway/futuGateway/futuGateway.py @@ -5,6 +5,7 @@ ''' import json +import imp from collections import OrderedDict from threading import Thread from time import sleep @@ -428,7 +429,11 @@ class FutuGateway(VtGateway): tick.date = row['data_date'].replace('-', '') tick.time = row['data_time'] + + # 这里使用imp模块来解决strptime函数的多线程安全问题 + imp.acquire_lock() tick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S') + imp.release_lock() tick.openPrice = row['open_price'] tick.highPrice = row['high_price']