AW: [python-win32] Geting values from a thread
python at kareta.de
python at kareta.de
Tue Jan 11 11:09:05 CET 2005
Hi,
> That's the whole advantage of threads: they run independently.
Yes, of course thats the reason. But I struggled into that problem, when I tried
to send LogInfoMsg to the eventlog. (W2K,p2.3.3.pywin202)
def SvcDoRun(self):
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))
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 :-(
regards,
Jürgen
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
More information about the Python-win32
mailing list