@@ -98,7 +98,7 @@ def __init__(self, callback, poll_interval=0.1, **kwargs):
9898 super ().__init__ (** kwargs )
9999
100100 async def _run (self ):
101- await asyncio .gather (self ._emit (self ._cb ()))
101+ await asyncio .gather (* self ._emit (self ._cb ()))
102102 await asyncio .sleep (self ._poll )
103103
104104
@@ -355,26 +355,30 @@ def __init__(self, cmd, open_kwargs=None, with_stderr=False, with_end=True,
355355 super ().__init__ (** kwargs )
356356
357357 async def run (self ):
358+ import shlex
358359 import subprocess
359360 stderr = subprocess .STDOUT if self .with_stderr else None
360361 if isinstance (self .cmd , (list , tuple )):
361362 cmd , * args = self .cmd
362363 else :
363- cmd , args = self .cmd , ( )
364+ cmd , * args = shlex . split ( self .cmd )
364365 process = await asyncio .create_subprocess_exec (
365366 cmd , * args , stdout = subprocess .PIPE ,
366367 stderr = stderr , ** self .open_kwargs )
367368 while not self .stopped :
368369 try :
369370 out = await process .stdout .readuntil (b'\n ' )
370371 except asyncio .IncompleteReadError as err :
371- if self .with_end :
372+ if self .with_end and err . partial :
372373 out = err .partial
373374 else :
374375 break
376+ if process .returncode is not None :
377+ self .stopped = True
375378 await asyncio .gather (* self ._emit (out ))
376- process .terminate ()
377- await process .wait ()
379+ if process .returncode is not None :
380+ process .terminate ()
381+ await process .wait ()
378382
379383
380384@Stream .register_api (staticmethod )
0 commit comments