Set Process Title

1.3.7 · active · verified Sat Mar 28

The `setproctitle` module is a C extension for Python that allows a process to change its title, which is displayed by system tools like `ps`, `top`, or `MacOS Activity Monitor`. This is particularly useful in multi-process systems (e.g., master/forked children) to identify the specific task each process is handling. The current version is 1.3.7, and it has a stable release cadence, with the last update in September 2025.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to change the current process's title using `setproctitle.setproctitle()` and retrieve it with `setproctitle.getproctitle()`. It also shows how to restore the original title.

import setproctitle
import time
import os

original_title = setproctitle.getproctitle()
print(f"Original process title: {original_title}")

new_title = f"my_worker_process_id_{os.getpid()}"
setproctitle.setproctitle(new_title)
print(f"New process title: {setproctitle.getproctitle()}")

# Simulate some work
time.sleep(5)

setproctitle.setproctitle(original_title)
print(f"Restored original process title: {setproctitle.getproctitle()}")

view raw JSON →