New to threads. How do they work?
gel
geli at tasmail.com
Wed Jul 19 22:08:12 EDT 2006
Hi all
I am attempting to understand threads to use in a network app which I
am writing. The part that I am going to use threads on is run on the
clients/workstations. I will monitor all starting and ending
processes. Below is what I have been doing. It looks like only the
first thread is starting. Can someone explain a basic example of how
threads work and are implemented, what is better to use threading or
thread module, and what am I doing wrong in the example below. I know
I have asked a lot of questions, any help/direction would be
appreciated.
Thanks
import wmi
import pythoncom
import thread
def create():
pythoncom.CoInitialize()
c = wmi.WMI()
while 1 :
print "watching creation"
watcher = c.watch_for(notification_type="Creation",
wmi_class="Win32_Process", delay_secs=1)
print watcher()
def delete():
pythoncom.CoInitialize()
d = wmi.WMI()
while 1 :
print "watching deletion"
watcher = d.watch_for(notification_type="Deletion",
wmi_class="Win32_Process", delay_secs=1)
print watcher()
thread.start_new_thread(create(),())
thread.start_new_thread(delete(),())
More information about the Python-list
mailing list