2828 Sized ,
2929 TextIO ,
3030 Tuple ,
31+ TypeVar ,
3132 Union ,
3233 cast ,
3334)
@@ -114,9 +115,11 @@ def _terminate_processes() -> None:
114115 # we're executing, so it's not safe to use a for loop here.
115116 while processes_to_kill :
116117 process = processes_to_kill .popleft ()
117- cidfile = [
118- str (arg ).split ("=" )[1 ] for arg in process .args if "--cidfile" in str (arg )
119- ]
118+ if isinstance (process .args , MutableSequence ):
119+ args = process .args
120+ else :
121+ args = [process .args ]
122+ cidfile = [str (arg ).split ("=" )[1 ] for arg in args if "--cidfile" in str (arg )]
120123 if cidfile :
121124 try :
122125 with open (cidfile [0 ]) as inp_stream :
@@ -680,11 +683,14 @@ def formatTime(
680683 return with_msecs
681684
682685
686+ ProvOut = Union [io .TextIOWrapper , WritableBagFile ]
687+
688+
683689def setup_provenance (
684690 args : argparse .Namespace ,
685691 argsl : List [str ],
686692 runtimeContext : RuntimeContext ,
687- ) -> Union [ io . TextIOWrapper , WritableBagFile ]:
693+ ) -> Tuple [ ProvOut , "logging.StreamHandler[ProvOut]" ]:
688694 if not args .compute_checksum :
689695 _logger .error ("--provenance incompatible with --no-compute-checksum" )
690696 raise ArgumentException ()
@@ -705,7 +711,7 @@ def setup_provenance(
705711 # Log cwltool command line options to provenance file
706712 _logger .info ("[cwltool] %s %s" , sys .argv [0 ], " " .join (argsl ))
707713 _logger .debug ("[cwltool] Arguments: %s" , args )
708- return log_file_io
714+ return log_file_io , prov_log_handler
709715
710716
711717def setup_loadingContext (
@@ -983,7 +989,7 @@ def main(
983989 coloredlogs .install (logger = _logger , stream = stderr )
984990 stderr_handler = _logger .handlers [- 1 ]
985991 workflowobj = None
986- prov_log_handler = None # type : Optional[logging.StreamHandler]
992+ prov_log_handler : Optional [logging .StreamHandler [ Any ]] = None
987993 try :
988994 if args is None :
989995 if argsl is None :
@@ -1051,7 +1057,9 @@ def main(
10511057 if argsl is None :
10521058 raise Exception ("argsl cannot be None" )
10531059 try :
1054- prov_log_stream = setup_provenance (args , argsl , runtimeContext )
1060+ prov_log_stream , prov_log_handler = setup_provenance (
1061+ args , argsl , runtimeContext
1062+ )
10551063 except ArgumentException :
10561064 return 1
10571065
0 commit comments