473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

See when process exits in Windows XP

I've tested this function out and it works well... it'll loop until
ntbackup.exe has exited and then the script goes on to rename the
backup.bkf file and copy it to a file server. Having _never_ done this
before I thought it'd be wise to run this by comp.lang.python. I know
it's a simple and stupid way in which to monitor a process, but it works
for me... is it safe to do this? I don't want to get too complex.
Thanks, Brad

def wait_for_ntbackup_to_exit(procname):
while True:
try:
pids = win32pdhutil.FindPerformanceAttributesByName(procn ame)
if len(pids) > 0:
print pids
print len(pids)
print "ntbackup is running... waiting for it to exit."
continue
except:
return
Jul 18 '05 #1
3 1288
I posted the wrong function... here's the one that works:

def wait_for_ntbackup_to_exit(procname):
while True:
try:
pids = win32pdhutil.FindPerformanceAttributesByName(procn ame)
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
Jul 18 '05 #2
Hi!

On 17 Okt 2004, Brad Tilley wrote:
def wait_for_ntbackup_to_exit(procname):
while True:
try:
pids = \
win32pdhutil.FindPerformanceAttributesByName(procn ame)
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? 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.

Bye
Tobias

PS. Why not use a simple:

while win32pdhutil.FindPerformanceAttributesByName(procn ame):
print "still running"
--
please send any mail to botedesschattens(at)web(dot)de
Jul 18 '05 #3
Tobias Pfeiffer wrote:
Hi!

On 17 Okt 2004, Brad Tilley wrote:

def wait_for_ntbackup_to_exit(procname):
while True:
try:
pids = \
win32pdhutil.FindPerformanceAttributesByName(procn ame)
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.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
Using Windows XP SP-1 with all security udpates installed MS Access version 10.2627.3501 SP-1 (all service packs to be installed over the weekend) MDAC 2.8 Jet 4.0 SP 8 When the database and...
29
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this...
3
by: Timothy Shih | last post by:
Hi, I am trying to start a process from inside a .NET service. The process is a simple GUI app, the service will start up the GUI and then stop itself. The service starts the app, but no GUI...
3
by: Marcel van den Hof | last post by:
Dear all, Is there any way to prevent the ASP.NET worker process from recycling the worker process when a thread is being executed on the foreground (IsBackground=false). I'd also like to...
7
by: Devron Blatchford | last post by:
Hi there, I am trying to develop a small menu application to run on an RF network, we are using a wavelink server to communicate with our rf scanners and run VB.NET applications on our server...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
8
by: Lonifasiko | last post by:
Hi, Using Process class I asynchronously launch an executable (black box executable) file from my Windows application. I mean asynchronously because I've got an EventHandler for "Exited" event....
5
by: Saya | last post by:
Hi Folks, I have now spend app. 3 days to get the below scenario to work, but can not get there! ..Net version = 2.0.50727 Windows version = Microsoft Windows = Windows Server 2003 Now I...
7
by: geoffbache | last post by:
Am currently being very confused over the following code on Windows import subprocess, os file = open("filename", "w") try: proc = subprocess.Popen("nosuchprogram", stdout=file) except...
0
by: John Halet | last post by:
I have a application that crunches a bunch of data, creating log files, excel files etc... I use Process.Start to open any number of these file for viewing. My goal is to have the application...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.