[python-win32] (no subject)
python at kareta.de
python at kareta.de
Tue Jan 11 14:59:04 CET 2005
Hello,
after more than a day I found a solution by myself :-))
The Solution: In the old code the LogInfoMsg is the last statement before the
return statement (in the FetchData function). If I put an other statement
between LogInfoMsg and return statement it works in debug and in start modus -
don't know if this only appears on my machines ?(tested with w2k pywin202/nt04
sp6 pywin203, both p2.3.3). Is that a feature or a bug?
regards,
Jürgen
>> 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.
>
>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) ##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