From 66edd75a2b4f6982b1fd667a055dbcc84d81101a Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 18 Feb 2019 05:10:51 -0400 Subject: [PATCH] [Add] api.ctp: terminate task queue when exit() is called --- vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp | 5 ++--- vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp index a8398879..6e53c87c 100644 --- a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp +++ b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp @@ -570,7 +570,8 @@ int MdApi::join() int MdApi::exit() { this->active = false; - //this->task_thread.join(); + this->task_queue.terminate(); + this->task_thread.join(); this->api->RegisterSpi(NULL); this->api->Release(); @@ -808,8 +809,6 @@ public: PYBIND11_MODULE(vnctpmd, m) { - PyEval_InitThreads(); //导入时运行,保证先创建GIL - class_ mdapi(m, "MdApi"); mdapi .def(init<>()) diff --git a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp index 7f8d9ed4..6a29eb70 100644 --- a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp +++ b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp @@ -7921,7 +7921,8 @@ int TdApi::join() int TdApi::exit() { this->active = false; - //this->task_thread.join(); + this->task_queue.terminate(); + this->task_thread.join(); this->api->RegisterSpi(NULL); this->api->Release(); @@ -10631,8 +10632,6 @@ public: PYBIND11_MODULE(vnctptd, m) { - PyEval_InitThreads(); //导入时运行,保证先创建GIL - class_ TdApi(m, "TdApi"); TdApi .def(init<>())