multiprocessing and process run time
Piet van Oostrum
piet at cs.uu.nl
Fri Jun 19 16:03:16 EDT 2009
>>>>> Thomas Robitaille <thomas.robitaille at gmail.com> (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 p.pid 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: http://code.google.com/p/psutil/
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list