Hi to everyone,

I have a Service, that runs on a WinXP machine. The service read a file
on a Win98 machine and write the content in a file on the WinXP machine.
After tree times I get the error message exceptions.IOError: (13,
'Permission denied'). 

The following things I have already tested:

- The file on Win98 machine could be deleted, so the file is closed
correctly.
- Stop an restart the service on WinXP, will have no effect
- Reboot the Win98 machine solve the problem for three times. So I have
the same issue explained above.
- I have changed the intervall from 5 sec to 1 minute. After ther first
time I get the error message.
- Using a Win2000 or WINXP machine instead of the Win98 machine. That
works. But unfortunatly the PC to access is a Win98 and I have no
influence to decide for upgrade.

I can't figure out, what's the problem.

This is the code to simulate my actual problem:

# -*- coding: iso-8859-1 -*-

import win32serviceutil
import win32service
import win32event
import pywintypes
import win32file
import win32pipe
import win32api
import win32con
import thread
import ntsecuritycon 
import os
import sys

class MyService(win32serviceutil.ServiceFramework):
    """NT Service."""
    
    _svc_name_ = "TCTest"
    _svc_display_name_ = "TCTest"

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.stop_event = win32event.CreateEvent(None, 0, 0, None)
        self.overlapped = pywintypes.OVERLAPPED()
        self.overlapped.hEvent = win32event.CreateEvent(None,0,0,None)
        self.thread_handles = []

    def SvcDoRun(self):               
        import servicemanager
                      
        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STARTED,
                (self._svc_name_, '')
                )        
       
        while 1:
            datei = open(r'\\ipcwin98\test\test.txt', 'r')
            log = open(r'c:\log.txt', 'a')
            log.write(datei.read())
            datei.close()
            log.close()
            
            if win32event.WaitForSingleObject(self.stop_event, 5000) ==
win32event.WAIT_OBJECT_0:
                break 
            
        servicemanager.LogMsg(
        servicemanager.EVENTLOG_INFORMATION_TYPE,
        servicemanager.PYS_SERVICE_STOPPED,
        (self._svc_name_, '')
        )
   
    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.stop_event)

if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(MyService)


Thanks in advanced for your help.
bye
Robert
-- 
http://www.dollinger.it

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

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

Reply via email to