@@ -1026,64 +1026,6 @@ def install_pip_requirements(repositories):
10261026 run_required_command (b"pip-install" , cmd )
10271027
10281028
1029- def maybe_run_resource_monitoring ():
1030- """Run the resource monitor if available.
1031-
1032- Discussion in https://github.com/taskcluster/taskcluster-rfcs/pull/160
1033- and https://bugzil.la/1648051
1034-
1035- """
1036- if "MOZ_FETCHES" not in os .environ :
1037- return
1038- if "RESOURCE_MONITOR_OUTPUT" not in os .environ :
1039- return
1040-
1041- prefix = b"resource_monitor"
1042-
1043- executable = "{}/resource-monitor/resource-monitor{}" .format (
1044- os .environ .get ("MOZ_FETCHES_DIR" ), ".exe" if IS_WINDOWS else ""
1045- )
1046-
1047- if not os .path .exists (executable ) or not os .access (executable , os .X_OK ):
1048- print_line (prefix , b"%s not executable\n " % executable .encode ("utf-8" ))
1049- return
1050- args = [
1051- executable ,
1052- "-process" ,
1053- str (os .getpid ()),
1054- "-output" ,
1055- os .environ ["RESOURCE_MONITOR_OUTPUT" ],
1056- ]
1057- print_line (prefix , b"Resource monitor starting: %s\n " % str (args ).encode ("utf-8" ))
1058- # Avoid environment variables the payload doesn't need.
1059- del os .environ ["RESOURCE_MONITOR_OUTPUT" ]
1060-
1061- # Without CREATE_NEW_PROCESS_GROUP Windows signals will attempt to kill run-task, too.
1062- process = subprocess .Popen (
1063- args ,
1064- # Disable buffering because we want to receive output
1065- # as it is generated so timestamps in logs are
1066- # accurate.
1067- bufsize = 0 ,
1068- stdout = subprocess .PIPE ,
1069- stderr = subprocess .STDOUT ,
1070- creationflags = subprocess .CREATE_NEW_PROCESS_GROUP if IS_WINDOWS else 0 ,
1071- cwd = os .getcwd (),
1072- )
1073-
1074- def capture_output ():
1075- fh = io .TextIOWrapper (process .stdout , encoding = "latin1" )
1076- while True :
1077- data = fh .readline ().encode ("latin1" )
1078- if data == b"" :
1079- break
1080- print_line (prefix , data )
1081-
1082- monitor_process = Thread (target = capture_output )
1083- monitor_process .start ()
1084- return process
1085-
1086-
10871029def _display_python_version ():
10881030 print_line (
10891031 b"setup" , b"Python version: %s\n " % platform .python_version ().encode ("utf-8" )
@@ -1332,7 +1274,6 @@ def main(args):
13321274 b"%s is %s\n " % (k .encode ("utf-8" ), os .environ [k ].encode ("utf-8" )),
13331275 )
13341276
1335- resource_process = None
13361277 try :
13371278 if "MOZ_FETCHES" in os .environ :
13381279 fetch_artifacts ()
@@ -1341,21 +1282,8 @@ def main(args):
13411282 # fetches to grab dependencies.
13421283 install_pip_requirements (repositories )
13431284
1344- resource_process = maybe_run_resource_monitoring ()
1345-
13461285 return run_command (b"task" , task_args , cwd = args .task_cwd )
13471286 finally :
1348- if resource_process :
1349- print_line (b"resource_monitor" , b"terminating\n " )
1350- if IS_WINDOWS :
1351- # .terminate() on Windows is not a graceful shutdown, due to
1352- # differences in signals. CTRL_BREAK_EVENT will work provided
1353- # the subprocess is in a different process group, so this script
1354- # isn't also killed.
1355- os .kill (resource_process .pid , signal .CTRL_BREAK_EVENT )
1356- else :
1357- resource_process .terminate ()
1358- resource_process .wait ()
13591287 fetches_dir = os .environ .get ("MOZ_FETCHES_DIR" )
13601288 if fetches_dir and os .path .isdir (fetches_dir ):
13611289 print_line (b"fetches" , b"removing %s\n " % fetches_dir .encode ("utf-8" ))
0 commit comments