1111import  subprocess 
1212import  contextlib 
1313from  pathlib  import  Path 
14- from  asyncio .subprocess  import  DEVNULL 
14+ from  asyncio .subprocess  import  DEVNULL ,  PIPE 
1515
1616from  tqsdk_zq_otg  import  get_zq_otg_path 
1717
@@ -46,9 +46,9 @@ async def get_addr(self):
4646 self ._zq_otg_proc .poll ()
4747 if  self ._zq_otg_proc  is  None  or  self ._zq_otg_proc .returncode  is  not None :
4848 if  sys .platform .startswith ("win" ):
49-  self ._zq_otg_proc  =  subprocess .Popen ([self ._zq_otg_exe , f"--config={ parameters }  , "--mode=cmd" ], stdin = DEVNULL , stdout = DEVNULL , stderr = DEVNULL , env = self ._zq_otg_env )
49+  self ._zq_otg_proc  =  subprocess .Popen ([self ._zq_otg_exe , f"--config={ parameters }  , "--mode=cmd" ], stdin = PIPE , stdout = DEVNULL , stderr = DEVNULL , env = self ._zq_otg_env )
5050 else :
51-  self ._zq_otg_proc  =  await  asyncio .create_subprocess_exec (self ._zq_otg_exe , f"--config={ parameters }  , "--mode=cmd" , stdin = DEVNULL , stdout = DEVNULL , stderr = DEVNULL , env = self ._zq_otg_env )
51+  self ._zq_otg_proc  =  await  asyncio .create_subprocess_exec (self ._zq_otg_exe , f"--config={ parameters }  , "--mode=cmd" , stdin = PIPE , stdout = DEVNULL , stderr = DEVNULL , env = self ._zq_otg_env )
5252
5353 for  i  in  range (30 ):
5454 if  port_file .exists ():
@@ -62,8 +62,7 @@ async def get_addr(self):
6262
6363 async  def  __aexit__ (self , exc_type , exc , tb ):
6464 if  self ._zq_otg_proc  is  not None :
65-  with  contextlib .suppress (ProcessLookupError ):
66-  self ._zq_otg_proc .send_signal (signal .CTRL_BREAK_EVENT  if  sys .platform .startswith ("win" ) else  signal .SIGTERM )
65+  self ._zq_otg_proc .stdin .close ()
6766 if  sys .platform .startswith ("win" ):
6867 self ._zq_otg_proc .wait ()
6968 else :
0 commit comments