diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index fff045f31c3a07ec2a50d5947d7f1a67c2469521..910aaaac31278715d2f64109bbf631078521b21d 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -35,6 +35,7 @@ import datetime import argparse import importlib.util import multiprocessing +import setproctitle from typing import Union, Any from pathos.helpers import mp as pathos_multiprocess @@ -142,6 +143,10 @@ class Population: # Create location where ensemble results are written to self.grid_ensemble_results = {} + # Set process name + setproctitle.setproctitle('binarycpython parent process') + setproctitle.setthreadtitle("binarycpyhon parent thread") + ################################################### # Argument functions ################################################### @@ -1051,12 +1056,14 @@ class Population: def _process_run_population_grid(self, job_queue, result_queue, ID): """ - Function that loops over the whole generator, but only runs - systems that fit to: if (localcounter+ID) % self.grid_options["amt_cores"] == 0 + Worker process that gets items from the job_queue and runs those systems. + It keeps track of several things like failed systems, total time spent on systems etc. - That way with e.g. 4 processes, process 1 runs sytem 0, 4, 8... process 2 runs system 1, 5, 9..., etc + Input: + job_queue: Queue object containing system dicts + result_queue: Queue where the resulting analytic dictionaries will be put in + ID: id of the worker process - This function is called by _evolve_population_grid """ # set start timer @@ -1070,6 +1077,12 @@ class Population: stream_logger = self.get_stream_logger() stream_logger.debug(f"Setting up processor: process-{self.process_ID}") + # Set the process names + name = 'binarycpython population thread {}'.format(ID) + name_proc = 'binarycpython population process {}'.format(ID) + setproctitle.setproctitle(name_proc) + setproctitle.setthreadtitle(name) + # Set to starting up with open( os.path.join( diff --git a/setup.py b/setup.py index 0903d8c4d1513e14e3f761d0e23d00d50751b007..3c86dc24e56be09981ad50312b50f7d38a0713f3 100644 --- a/setup.py +++ b/setup.py @@ -260,6 +260,7 @@ setup( "astropy", "matplotlib", "py_rinterpolate", + "setproctitle", ], include_package_data=True, ext_modules=[BINARY_C_PYTHON_API_MODULE], # binary_c must be loaded