Register a function to run as process terminates While class Process has a register_finalize_method, when a process is looked up by pid using psutil.Process, there is no method available to register a cleanup process. Hence, this function can be used to register a function to allo
(function, *args, **kwargs)
| 1266 | |
| 1267 | |
| 1268 | def register_cleanup_finalize_function(function, *args, **kwargs): |
| 1269 | """ |
| 1270 | Register a function to run as process terminates |
| 1271 | |
| 1272 | While class Process has a register_finalize_method, when a process is looked up by pid |
| 1273 | using psutil.Process, there is no method available to register a cleanup process. |
| 1274 | |
| 1275 | Hence, this function can be used to register a function to allow cleanup processes |
| 1276 | which cannot be added by class Process register_finalize_method. |
| 1277 | |
| 1278 | Note: there is no deletion, since it is assummed that if something is registered, it will continue to be used |
| 1279 | """ |
| 1280 | log.debug( |
| 1281 | "register_cleanup_finalize_function entry, function=%r, args=%r, kwargs=%r", |
| 1282 | function, |
| 1283 | args, |
| 1284 | kwargs, |
| 1285 | ) |
| 1286 | finalize_function_tuple = (function, args, kwargs) |
| 1287 | if finalize_function_tuple not in _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST: |
| 1288 | _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST.append(finalize_function_tuple) |
no test coverage detected