File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ def _check_kamel_output(self,
165165 # Start thread analyzing logs:
166166 reading_thread .start ()
167167
168+ # Initiate the first read:
169+ reading_thread .read_flag .set ()
170+
168171 success = False
169172 while True :
170173 # Log progress of kamel subprocess:
@@ -194,12 +197,14 @@ def _check_kamel_output(self,
194197 countdown -= 1
195198 if countdown == 0 :
196199 break
200+ reading_thread .read_flag .set ()
197201 time .sleep (0.01 )
198202
199203 # Terminate log thread:
200204 if with_timeout :
201205 reading_thread .stop_flag .set ()
202- reading_thread .join ()
206+ if success :
207+ reading_thread .join ()
203208
204209 return success
205210
Original file line number Diff line number Diff line change 1616
1717import os
1818import random
19- import time
2019import threading
2120from queue import Queue , Empty
2221
@@ -86,14 +85,16 @@ class LogThread(threading.Thread):
8685 def __init__ (self , stdout ):
8786 threading .Thread .__init__ (self )
8887 self .stop_flag = threading .Event ()
88+ self .read_flag = threading .Event ()
8989 self .stdout = stdout
9090 self .queue = Queue ()
9191
9292 def run (self ):
9393 while not self .stop_flag .is_set ():
94- line = self .stdout .readline ().decode ("utf-8" )
95- self .queue .put (line .strip ())
96- time .sleep (0.1 )
94+ if self .read_flag .is_set ():
95+ line = self .stdout .readline ().decode ("utf-8" )
96+ self .queue .put (line .strip ())
97+ self .read_flag .clear ()
9798
9899 print ("[Logging thread] Kamel command logging terminated." )
99100
You can’t perform that action at this time.
0 commit comments