@@ -127,21 +127,26 @@ def perform_task(task_pk, task_working_dir_rel_path):
127127 set_domain (task .pulp_domain )
128128 os .chdir (task_working_dir_rel_path )
129129
130- if settings .TASK_DIAGNOSTICS :
131- _execute_task_and_profile (task )
130+ if task .profile_options :
131+ profilers = set (task .profile_options ) & set (settings .TASK_DIAGNOSTICS )
132+ if unavailable_profilers := set (task .profile_options ) - set (settings .TASK_DIAGNOSTICS ):
133+ _logger .warning (
134+ "Requested task diagnostic profilers are not available: %s" , unavailable_profilers
135+ )
136+ _execute_task_and_profile (task , profilers )
132137 else :
133138 execute_task (task )
134139
135140
136- def _execute_task_and_profile (task ):
141+ def _execute_task_and_profile (task , profile_options ):
137142 with tempfile .TemporaryDirectory (dir = settings .WORKING_DIRECTORY ) as temp_dir :
138143 _execute_task = execute_task
139144
140- if settings . TASK_DIAGNOSTICS is True or "memory" in settings . TASK_DIAGNOSTICS :
145+ if "memory" in profile_options :
141146 _execute_task = _memory_diagnostic_decorator (temp_dir , _execute_task )
142- if settings . TASK_DIAGNOSTICS is True or "pyinstrument" in settings . TASK_DIAGNOSTICS :
147+ if "pyinstrument" in profile_options :
143148 _execute_task = _pyinstrument_diagnostic_decorator (temp_dir , _execute_task )
144- if settings . TASK_DIAGNOSTICS is True or "memray" in settings . TASK_DIAGNOSTICS :
149+ if "memray" in profile_options :
145150 _execute_task = _memray_diagnostic_decorator (temp_dir , _execute_task )
146151
147152 _execute_task (task )
0 commit comments