multiprocessing and process run time

Piet van Oostrum piet at
Fri Jun 19 16:03:16 EDT 2009

>>>>> Thomas Robitaille <thomas.robitaille at> (TR) wrote:

>TR> Hi,

>TR> I'm making use of the multiprocessing module, and I was wondering if there
>TR> is an easy way to find out how long a given process has been running for.
>TR> For example, if I do

>TR> import multiprocessing as mp
>TR> import time

>TR> def time_waster():
>TR>     time.sleep(1000)

>TR> p = mp.Process(target=time_waster)

>TR> p.start()

>TR> Is there a way that I can then find how long p has been running for? I
>TR> figured I can use to get the PID of the process, but I'm not sure
>TR> where to go from there. Is there an easy way to do this?

You could look at the psutil module:
Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list