On Fri, 19 Jun 2009 07:40:11 -0700 (PDT) Thomas Robitaille <thomas.robitai...@gmail.com> wrote:
> I'm making use of the multiprocessing module, and I was wondering if there > is an easy way to find out how long a given process has been running for. > For example, if I do > > import multiprocessing as mp > import time > > def time_waster(): > time.sleep(1000) > > p = mp.Process(target=time_waster) > > p.start() > > Is there a way that I can then find how long p has been running for? I > figured I can use p.pid to get the PID of the process, but I'm not sure > where to go from there. Is there an easy way to do this? If you use unix-like platform (e.g. linux) you can just use 'ps -e -o pid,start_time | grep <pid>'. I'd used procpy to do ps-like stuff in python since it's a wrapper around the same procps library, prehaps it can get the same results as well, w/o having to invoke shell commands: http://code.google.com/p/procpy/ -- Mike Kazantsev // fraggod.net -- http://mail.python.org/mailman/listinfo/python-list