See when process exits in Windows XP
Brad Tilley
rtilley at vt.edu
Sun Oct 17 10:23:09 EDT 2004
Tobias Pfeiffer wrote:
> Hi!
>
> On 17 Okt 2004, Brad Tilley wrote:
>
>
>>def wait_for_ntbackup_to_exit(procname):
>> while True:
>> try:
>> pids = \
>> win32pdhutil.FindPerformanceAttributesByName(procname)
>> if len(pids) > 0:
>> ## If ntbackup is running, loop until it closes.
>> print pids
>> print len(pids)
>> print "ntbackup is running... waiting for it to
>> exit." continue
>> else:
>> ## ntbackup is not running.
>> break
>> except:
>> return
>
>
> I have no clue about that win32pdhutil thingy but if it returns a list
> with pids, then why do you need the except statement?
From trial and error, I found that if this function runs when ntbackup
isn't running that it would produce an error... that's the reason for
the except. I can reproduce it if you want the exact error message.
And it seems to me
> that this loops as fast as the CPU is able to, so it actually steals away
> other processe's CPU time. If you insert a time.sleep(0.5) statement (or
> something similar), you can decrease the CPU usage to a minimum.
You're right, I did this and it helps.
More information about the Python-list
mailing list