From time to time, you may want to change the process name of the program you are running. In Python, it seems better to use a package called setproctitle.
Debian, Ubuntu and Mint can be installed in one shot with the following command.
# aptitude install setproctitle
Or it is uploaded to pypi, so install it with pip. Since it is partly written in C and you need to refer to the Python header file to compile, install python-dev for Debian or Ubuntu.
# aptitude install python-dev python-pip
# pip install setproctitle
You can set the process name with setproctitle and get the current process name with getproctitle as shown below. Let's check if the process name is actually changed by doing something like "pgrep hoge".
>>> from setproctitle import setproctitle, getproctitle
>>> getproctitle()
'python'
>>> setproctitle("hoge")
>>> getproctitle()
'hoge'
>>>
Recommended Posts