At 11/1/2005 08:01, you wrote:


        while True:
            retval=win32event.WaitForMultipleObjects
(self.close_evt,self.accept_evt),False,win32event.INFINITE)
            if retval == win32event.WAIT_OBJECT_0:
                win32file.CloseHandle(self.accept_evt)
                self.socket.close()
                servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STOPPED,
                (self._svc_name_, ''))
                return

            elif retval == win32event.WAIT_OBJECT_0 + 1:

                thread.start_new_thread(self.FetchData,(self.socket,))


def FetchData(self,socket):
##code
import servicemanager
message= 'Processed %d bytes for client connection and printed out on port
%s' % (value1,value2) ##value 1,2 set inside the FetchData code
servicemanager.LogInfoMsg(message)



If the service runs in debug mode, the message is written to the console. If the
service runs normal (with 'start' parameter) no message send to the eventlog (no
error message, no exit code, nothing happens). If I put the message line and the
LogInfoMsg line under thread.start_new_thread the message is send to the
eventlog, but I cannot pass the two values of the FetchData function.
That's the whole problem. Don't know how to solve :-(

If you really need another thread to process FetchData, you could use a Queue to pass data between threads.
But, for a server accepting multiple simultaneous connections the asyncore module may be a better solution than multiple threads.



_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32

Reply via email to