Passing an Event from a Thread to its Caller
Matt Rapoport
matthew.rapoport at accenture.com
Mon Jun 2 15:20:17 EDT 2003
Hi all, I'm a newbie to python and threading in general.
I'm trying to write a service using the win32 extensions. My service
runs a thread and the thread is just a simple class that I created.
I'd like that simple class of mine to be able to generate an event
within the service. How do I do that? Thank you very much for the
help.
- Matt
Here's a snippet of the code (my simple class iss called Client)...
import Client
class ClientThread(threading.Thread):
def run(self):
client = Client.Client()
client.run()
class ClientService(win32serviceutil.ServiceFramework):
_svc_name_ = "HBTClient"
_svc_display_name_ = "HBTClient"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
client = ClientThread()
client.setDaemon(1)
client.start()
win32event.WaitForSingleObject(self.hWaitStop,
win32event.INFINITE)
More information about the Python-list
mailing list