I am trying to create a python process and give it an explicit name so that I can find it by its name within the psutil iter object. Somehow, the pid of the created python process is correct, but the name displayed by psutil is "python", while I expect to see the name I gave it. Since my goal is to create a bunch of deterministic processes, and monitoring their states (running or not), I do not know how to distinguish them, apart from their name. (I will actually have one process whose only purpose is to monitor the state of the other processes). Any idea on how to solve this ?
Below a sample of my code (very basic)
process = multiprocessing.Process(
name=service_config["service_type"],
target=service.start_service
)
process.start()
print(process.pid)
print(process.name)
The prints: 9387 silly_service_name
Attached a screenshot of psutil.
Appreciate any help.
I first thought it was a windows issue, so I moved my entire project to ubuntu (which I should definitely have started from the beginning). But the process name is still wrong. I must be missing something.
Another way to solve it, is by looking at process.cmdline(), where explicitly I'll find the name of what I am looking for, but I am simply curious as to what I do not understand regarding previous approach.