@@ -52,6 +52,42 @@ def make_default_params(verbose):
52
52
"identifier" : ""
53
53
}
54
54
55
+ def tail_line_result (wait , line , params ):
56
+ """
57
+ Keep the line, filter it for leading #,
58
+ if verbose print the line. else print progress.
59
+ """
60
+ # pylint: disable=pointless-statement
61
+ if params ['skip_done' ]:
62
+ if isinstance (line , tuple ):
63
+ print (params ['prefix' ] + str (line [0 ], 'utf-8' ).rstrip ())
64
+ params ['output' ].write (line [0 ])
65
+ return True
66
+ now = datetime .now ()
67
+ if now - params ['last_read' ] > timedelta (seconds = 1 ):
68
+ params ['skip_done' ] = True
69
+ print (params ['prefix' ] + 'initial tail done, starting to output' )
70
+ return True
71
+ def make_tail_params (verbose , prefix , logfile ):
72
+ """ create the structure to work with arrays to output the strings to """
73
+ return {
74
+ "trace_io" : False ,
75
+ "error" : "" ,
76
+ "verbose" : verbose ,
77
+ "output" : logfile .open ("wb" ),
78
+ "lfn" : str (logfile ),
79
+ "identifier" : "" ,
80
+ "skip_done" : False ,
81
+ "prefix" : prefix ,
82
+ "last_read" : datetime .now ()
83
+ }
84
+ def delete_tail_params (params ):
85
+ """ teardown the structure to work with logfiles """
86
+ print (f"{ params ['identifier' ]} closing { params ['lfn' ]} " )
87
+ params ['output' ].flush ()
88
+ params ['output' ].close ()
89
+ print (f"{ params ['identifier' ]} { params ['lfn' ]} closed" )
90
+
55
91
def make_logfile_params (verbose , logfile , trace ):
56
92
""" create the structure to work with logfiles """
57
93
return {
@@ -214,6 +250,7 @@ def __init__(self, config, connect_instance, deadline_signal=-1):
214
250
self .connect_instance = connect_instance
215
251
self .cfg = config
216
252
self .deadline_signal = deadline_signal
253
+ self .pid = None
217
254
if self .deadline_signal == - 1 :
218
255
# pylint: disable=no-member
219
256
# yes, one is only there on the wintendo, the other one elsewhere.
@@ -315,6 +352,8 @@ def run_monitored(self,
315
352
close_fds = ON_POSIX ,
316
353
cwd = self .cfg .test_data_dir .resolve (),
317
354
) as process :
355
+ # pylint: disable=consider-using-f-string
356
+ self .pid = process .pid
318
357
queue = Queue ()
319
358
thread1 = Thread (
320
359
name = f"readIO { identifier } " ,
@@ -381,6 +420,7 @@ def run_monitored(self,
381
420
if datetime .now () > deadline :
382
421
have_deadline += 1
383
422
if have_deadline == 1 :
423
+ # pylint: disable=line-too-long
384
424
add_message_to_report (
385
425
params ,
386
426
f"{ identifier } Execution Deadline reached - will trigger signal { self .deadline_signal } !" )
@@ -406,6 +446,7 @@ def run_monitored(self,
406
446
process .stdout .close ()
407
447
break
408
448
except psutil .TimeoutExpired :
449
+ # pylint: disable=line-too-long
409
450
deadline_grace_count += 1
410
451
print_log (f"{ identifier } timeout waiting for exit { str (deadline_grace_count )} " , params )
411
452
# if its not willing, use force:
0 commit comments