Parallel python + ??

Gerhard Häring gh at ghaering.de
Wed Jun 11 07:50:48 EDT 2008


Thor wrote:
> Hi,
> 
> I am running a program using Parallel Python and I wonder if there is a
> way/module to know in which CPU/core the process is running in. Is that
> possible?

This is of course OS-specific. On Linux, you can parse the proc filesystem:

 >>> open("/proc/%i/stat" % os.getpid()).read().split()[39]

You can use the "taskset" utility to query or set CPU affinity on Linux.

-- Gerhard




More information about the Python-list mailing list