<br><font size=2 face="sans-serif">David,</font>
<br>
<br><font size=2 face="sans-serif">Maybe I'm missing something, but doesn't
XP take awhile to launch and kill Notepad?</font>
<br>
<br><font size=2 face="sans-serif">Does it work a bit better if you launch
a process every 10 seconds?</font>
<br>
<br><font size=2 face="sans-serif">Thanks,<br>
Tom</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td><font size=1 face="sans-serif"><b>"David S." <david128@receptec.net></b>
</font>
<br>
<br><font size=1 face="sans-serif">Sent by: python-win32-bounces@python.org</font>
<p><font size=1 face="sans-serif">03/20/2006 09:42 AM</font>
<td>
<table width=100%>
<tr valign=top>
<td>
<td>
<p>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">python-win32@python.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">[python-win32] win32process open-terminate
loop cripples OS</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>Hello,<br>
<br>
I decided to attempt to use python's win32 extensions as a method to<br>
monitor and control process for my python application. It's working<br>
well in the short term, but, as this app is intended to be very<br>
low-maintenance, and probably high-uptimes without restarting, I want to<br>
put it to the test. I set a loop similar to below to run every second<br>
for the weekend. It wasn't very pretty. I didn't get any process<br>
information (couldn't - system was /almost/ unresponsive) - the most i<br>
could do was alt-tab around, though it wouldn't paint the window, move<br>
the mouse pointer and turn the num lock light on and off. Can anyone<br>
provide some guidance or perhaps point out a problem in my code?<br>
<br>
For what it's worth, I think I can poll process /ad infinitum/ without<br>
any lockups.<br>
<br>
Thank you,<br>
<br>
-David S.<br>
<br>
---------------------------------------------------------------------------<br>
<br>
def weekendprocesstest():<br>
print 1<br>
Processes.StartProcess("notepad")<br>
print 2<br>
Processes.KillName("notepad")<br>
print 3<br>
<br>
<br>
---and the functions....<br>
<br>
<br>
def StartProcess(self, RunCmd):<br>
#not going to bother with win32 for this<br>
#output=os.System(RunCmd).read()<br>
StartupInfo = win32process.STARTUPINFO()<br>
win32process.CreateProcess(<br>
None, #
program<br>
RunCmd, # command
line<br>
None, #
process security attributes<br>
None, #
thread attributes<br>
1,
# inherit handles, or USESTDHANDLES won't work.<br>
# creation flags. Don't access the console.<br>
0,
# Don't need anything here.<br>
# If you're in a GUI app, you should use<br>
# CREATE_NEW_CONSOLE here, or any subprocesses<br>
# might fall victim to the problem described in:<br>
# KB article: Q156755, cmd.exe requires<br>
# an NT console in order to perform redirection..<br>
None, #
new environment<br>
None,
# new directory<br>
StartupInfo)<br>
self.ProcessTableRefresh()<br>
<br>
<br>
def KillName(self, matchstring):<br>
#get PIDS that have the supplied substring<br>
self.ProcessTableRefresh()<br>
ProcessList=self.GetProcessList()<br>
for process in ProcessList:<br>
if process[2].lower().find(matchstring.lower())!=-1:<br>
win32process.TerminateProcess(process[0],0)<br>
self.ProcessTableRefresh()<br>
<br>
def ProcessTableRefresh(self):<br>
processes = win32process.EnumProcesses()<br>
pnamepidlist=list()<br>
for pid in processes:<br>
try:<br>
handle =<br>
win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid)<br>
exe = win32process.GetModuleFileNameEx(handle,
0)<br>
pnamepidlist.append((handle,
pid, exe))<br>
except:<br>
pass<br>
<br>
self.lProcessTable.acquire()<br>
self.ProcessList=pnamepidlist<br>
self.ProcessTableAge=0<br>
self.lProcessTable.release()<br>
<br>
<br>
_______________________________________________<br>
Python-win32 mailing list<br>
Python-win32@python.org<br>
http://mail.python.org/mailman/listinfo/python-win32<br>
</tt></font>
<br>
<br>
<br>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender</span><br>