_ssl.pyd is buggy?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laszlo Nagy

    _ssl.pyd is buggy?


    Hello,

    I wrote a small program that uses xmlrpc over https. It should work as a
    win32 application and as a win32 service too. There is a file called
    Processor.py that contains the main thread of the program. It is called
    from two files: win32_Applicati on.py and win32_Service.p y. The
    application works perfectly. The service does not. I can start it from
    the services mmc console, but it does not created logfiles, and does
    nothing. It cannot be stopped and I have to kill pythonservice.e xe. The
    event log shows this:


    Information: The AmazonOfferDown loaderService service has started.
    Application error: Faulty application: python.exe, version: 0.0.0.0,
    faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87.

    Is it possible that my _ssl.pyd is faulty? Please help me.

    Python version: 2.4.3 (#69, Mar 29 2006)
    Windows version: Windows XP Professional, service pack 2, Hungarian (I
    translated the above messages from the event log....)

    Thanks,

    Laszlo

    >>Here is the code for the application:
    import thread,threadin g,time

    from Processor import *
    from servicelog import *
    from win32_Config import *

    stopped = threading.Event ()
    stopped.clear()
    processor = Processor(stopp ed)
    thread.start_ne w_thread(proces sor.Process,())
    logger = getLogger('win3 2_Application')
    logger.info("St aring as application. Please press CTRL+C to stop service.")
    while 1:
    try:
    time.sleep(1)
    except:
    break
    logger.info("St opping application " + SERVICE_NAME)
    stopped.set()
    while not processor.stopp ed.isSet():
    logger.debug("W aiting for the processor to finish...")
    time.sleep(1)

    logger.info("Ap plication stopped.")
    >>Here is the code for the service:
    from win32_Config import *
    from Processor import *
    from servicelog import *

    import win32serviceuti l, win32service
    import pywintypes, win32con, winerror
    from win32event import *
    from win32file import *
    from win32pipe import *
    from win32api import *
    from ntsecuritycon import *

    import traceback
    import thread,threadin g

    class Service(win32se rviceutil.Servi ceFramework):
    _svc_name_ = SERVICE_NAME
    _svc_display_na me_ = SERVICE_DISPLAY
    def __init__(self, args):
    win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
    self.stopped = threading.Event ()
    self.stopped.cl ear()
    self.logger = getLogger(SERVI CE_NAME)

    def SvcStop(self):
    self.logger.inf o("Got SvcStop, trying to stop service...")
    self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
    self.stopped.se t()

    def SvcDoRun(self):
    """Write an event log record - in debug mode we will also see
    this message printed."""
    try:
    import servicemanager
    servicemanager. LogMsg(
    servicemanager. EVENTLOG_INFORM ATION_TYPE,
    servicemanager. PYS_SERVICE_STA RTED,
    (self._svc_name _, '')
    )
    self.logger.inf o("Started.")
    self.logger.deb ug("Creating processor instance")
    processor = Processor(self. stopped)
    self.logger.deb ug("Starting processor thread")
    thread.start_ne w_thread(proces sor.Process,())
    self.logger.deb ug("Waiting for the processor thread to finish")
    self.stopped.wa it()
    self.logger.deb ug("Stopping")
    time.sleep(1)
    while not processor.stopp ed.isSet():

    self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING, 5000)
    time.sleep(5)
    servicemanager. LogMsg(
    servicemanager. EVENTLOG_INFORM ATION_TYPE,
    servicemanager. PYS_SERVICE_STO PPED,
    (self._svc_name _, "")
    )
    self.logger.inf o("Stopped")
    except:
    self.logger.err or('',exc_info = sys.exc_info())


    if __name__=='__ma in__':
    win32serviceuti l.HandleCommand Line(Service)


  • Larry Bates

    #2
    Re: _ssl.pyd is buggy?

    Laszlo Nagy wrote:
    >
    Hello,
    >
    I wrote a small program that uses xmlrpc over https. It should work as a
    win32 application and as a win32 service too. There is a file called
    Processor.py that contains the main thread of the program. It is called
    from two files: win32_Applicati on.py and win32_Service.p y. The
    application works perfectly. The service does not. I can start it from
    the services mmc console, but it does not created logfiles, and does
    nothing. It cannot be stopped and I have to kill pythonservice.e xe. The
    event log shows this:
    >
    >
    Information: The AmazonOfferDown loaderService service has started.
    Application error: Faulty application: python.exe, version: 0.0.0.0,
    faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87.
    >
    Is it possible that my _ssl.pyd is faulty? Please help me.
    >
    Python version: 2.4.3 (#69, Mar 29 2006)
    Windows version: Windows XP Professional, service pack 2, Hungarian (I
    translated the above messages from the event log....)
    >
    Thanks,
    >
    Laszlo
    >
    >
    >>>Here is the code for the application:
    >
    import thread,threadin g,time
    >
    from Processor import *
    from servicelog import *
    from win32_Config import *
    >
    stopped = threading.Event ()
    stopped.clear()
    processor = Processor(stopp ed)
    thread.start_ne w_thread(proces sor.Process,())
    logger = getLogger('win3 2_Application')
    logger.info("St aring as application. Please press CTRL+C to stop service.")
    while 1:
    try:
    time.sleep(1)
    except:
    break
    logger.info("St opping application " + SERVICE_NAME)
    stopped.set()
    while not processor.stopp ed.isSet():
    logger.debug("W aiting for the processor to finish...")
    time.sleep(1)
    >
    logger.info("Ap plication stopped.")
    >
    >>>Here is the code for the service:
    >
    from win32_Config import *
    from Processor import *
    from servicelog import *
    >
    import win32serviceuti l, win32service
    import pywintypes, win32con, winerror
    from win32event import *
    from win32file import *
    from win32pipe import *
    from win32api import *
    from ntsecuritycon import *
    >
    import traceback
    import thread,threadin g
    >
    class Service(win32se rviceutil.Servi ceFramework):
    _svc_name_ = SERVICE_NAME
    _svc_display_na me_ = SERVICE_DISPLAY
    def __init__(self, args):
    win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
    self.stopped = threading.Event ()
    self.stopped.cl ear()
    self.logger = getLogger(SERVI CE_NAME)
    >
    def SvcStop(self):
    self.logger.inf o("Got SvcStop, trying to stop service...")
    self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
    self.stopped.se t()
    >
    def SvcDoRun(self):
    """Write an event log record - in debug mode we will also see
    this message printed."""
    try:
    import servicemanager
    servicemanager. LogMsg(
    servicemanager. EVENTLOG_INFORM ATION_TYPE,
    servicemanager. PYS_SERVICE_STA RTED,
    (self._svc_name _, '')
    )
    self.logger.inf o("Started.")
    self.logger.deb ug("Creating processor instance")
    processor = Processor(self. stopped)
    self.logger.deb ug("Starting processor thread")
    thread.start_ne w_thread(proces sor.Process,())
    self.logger.deb ug("Waiting for the processor thread to finish")
    self.stopped.wa it()
    self.logger.deb ug("Stopping")
    time.sleep(1)
    while not processor.stopp ed.isSet():
    >
    self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING, 5000)
    time.sleep(5)
    servicemanager. LogMsg(
    servicemanager. EVENTLOG_INFORM ATION_TYPE,
    servicemanager. PYS_SERVICE_STO PPED,
    (self._svc_name _, "")
    )
    self.logger.inf o("Stopped")
    except:
    self.logger.err or('',exc_info = sys.exc_info())
    >
    >
    if __name__=='__ma in__':
    win32serviceuti l.HandleCommand Line(Service)
    >
    >
    I was using _ssl.pyd to upload files to DAV server over ssl and
    found it to be a problem. I upgraded to Python 2.5 and the problem
    was fixed. I don't know if it is the same problem that is affecting
    you, but I couldn't get it to work on 2.4.

    FYI, Larry

    Comment

    • Laszlo Nagy

      #3
      Re: _ssl.pyd is buggy?

      I was using _ssl.pyd to upload files to DAV server over ssl and
      found it to be a problem. I upgraded to Python 2.5 and the problem
      was fixed. I don't know if it is the same problem that is affecting
      you, but I couldn't get it to work on 2.4.
      >
      FYI, Larry
      >
      I just installed Python 2.5 and now I do not get the error message in
      the event log. But the service still cannot be stopped and does not log
      anything. I'm using the logging module and RotatingFileHan dler, so the
      service should start logging into a new file immediately after startup.
      According to the event log, the service is started, but it does nothing.
      If I start the same program as an application, it works fine. The
      program only uses the standard lib. Any ideas, what can be the problem?

      Thanks,

      Laszlo

      Comment

      • Gabriel Genellina

        #4
        Re: _ssl.pyd is buggy?

        En Tue, 13 Feb 2007 14:40:20 -0300, Laszlo Nagy
        <gandalf@design aproduct.bizesc ribió:
        I just installed Python 2.5 and now I do not get the error message in
        the event log. But the service still cannot be stopped and does not log
        anything. I'm using the logging module and RotatingFileHan dler, so the
        service should start logging into a new file immediately after startup.
        According to the event log, the service is started, but it does nothing.
        If I start the same program as an application, it works fine. The
        program only uses the standard lib. Any ideas, what can be the problem?
        Services usually run under the LOCAL_SERVICE account, which is rather
        limited on what it is allowed to do (It has no access to network shares,
        by example). Perhaps this is afecting your program.

        --
        Gabriel Genellina

        Comment

        • Laszlo Nagy

          #5
          Re: _ssl.pyd is buggy?

          Services usually run under the LOCAL_SERVICE account, which is rather
          limited on what it is allowed to do (It has no access to network shares,
          by example). Perhaps this is afecting your program.
          >
          I'm sorry, it is not. My service only uses the standard output, writes
          into different files and uses the http and https protocol. It does not
          use microsoft networking, only TCP/IP. It is actually a spider that
          downloads information from some web sites. The most strange thing is
          that the main thread is enclosed in a try - except statement, and it
          should log all exceptions into a file. The file is even not created, and
          I see no way to debug it. Can a python win32 service program be debugged?

          Thanks,

          Laszlo


          Comment

          • Gabriel Genellina

            #6
            Re: _ssl.pyd is buggy?

            En Tue, 13 Feb 2007 16:49:10 -0300, Laszlo Nagy
            <gandalf@design aproduct.bizesc ribió:
            >Services usually run under the LOCAL_SERVICE account, which is rather
            >limited on what it is allowed to do (It has no access to network shares,
            >by example). Perhaps this is afecting your program.
            >>
            I'm sorry, it is not. My service only uses the standard output, writes
            into different files and uses the http and https protocol. It does not
            use microsoft networking, only TCP/IP. It is actually a spider that
            downloads information from some web sites. The most strange thing is
            that the main thread is enclosed in a try - except statement, and it
            should log all exceptions into a file. The file is even not created, and
            I see no way to debug it. Can a python win32 service program be debugged?
            Do you catch all exceptions on your working thread too? You didn't post
            that code.

            --
            Gabriel Genellina

            Comment

            • Larry Bates

              #7
              Re: _ssl.pyd is buggy?

              Laszlo Nagy wrote:
              >
              Hello,
              >
              I wrote a small program that uses xmlrpc over https. It should work as a
              win32 application and as a win32 service too. There is a file called
              Processor.py that contains the main thread of the program. It is called
              from two files: win32_Applicati on.py and win32_Service.p y. The
              application works perfectly. The service does not. I can start it from
              the services mmc console, but it does not created logfiles, and does
              nothing. It cannot be stopped and I have to kill pythonservice.e xe. The
              event log shows this:
              >
              >
              Information: The AmazonOfferDown loaderService service has started.
              Application error: Faulty application: python.exe, version: 0.0.0.0,
              faulty modul: _ssl.pyd, version: 0.0.0.0, memory address: 0x00019b87.
              >
              Is it possible that my _ssl.pyd is faulty? Please help me.
              >
              Python version: 2.4.3 (#69, Mar 29 2006)
              Windows version: Windows XP Professional, service pack 2, Hungarian (I
              translated the above messages from the event log....)
              >
              Thanks,
              >
              Laszlo
              >
              >
              >>>Here is the code for the application:
              >
              import thread,threadin g,time
              >
              from Processor import *
              from servicelog import *
              from win32_Config import *
              >
              stopped = threading.Event ()
              stopped.clear()
              processor = Processor(stopp ed)
              thread.start_ne w_thread(proces sor.Process,())
              logger = getLogger('win3 2_Application')
              logger.info("St aring as application. Please press CTRL+C to stop service.")
              while 1:
              try:
              time.sleep(1)
              except:
              break
              logger.info("St opping application " + SERVICE_NAME)
              stopped.set()
              while not processor.stopp ed.isSet():
              logger.debug("W aiting for the processor to finish...")
              time.sleep(1)
              >
              logger.info("Ap plication stopped.")
              >
              >>>Here is the code for the service:
              >
              from win32_Config import *
              from Processor import *
              from servicelog import *
              >
              import win32serviceuti l, win32service
              import pywintypes, win32con, winerror
              from win32event import *
              from win32file import *
              from win32pipe import *
              from win32api import *
              from ntsecuritycon import *
              >
              import traceback
              import thread,threadin g
              >
              class Service(win32se rviceutil.Servi ceFramework):
              _svc_name_ = SERVICE_NAME
              _svc_display_na me_ = SERVICE_DISPLAY
              def __init__(self, args):
              win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
              self.stopped = threading.Event ()
              self.stopped.cl ear()
              self.logger = getLogger(SERVI CE_NAME)
              >
              def SvcStop(self):
              self.logger.inf o("Got SvcStop, trying to stop service...")
              self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
              self.stopped.se t()
              >
              def SvcDoRun(self):
              """Write an event log record - in debug mode we will also see
              this message printed."""
              try:
              import servicemanager
              servicemanager. LogMsg(
              servicemanager. EVENTLOG_INFORM ATION_TYPE,
              servicemanager. PYS_SERVICE_STA RTED,
              (self._svc_name _, '')
              )
              self.logger.inf o("Started.")
              self.logger.deb ug("Creating processor instance")
              processor = Processor(self. stopped)
              self.logger.deb ug("Starting processor thread")
              thread.start_ne w_thread(proces sor.Process,())
              self.logger.deb ug("Waiting for the processor thread to finish")
              self.stopped.wa it()
              self.logger.deb ug("Stopping")
              time.sleep(1)
              while not processor.stopp ed.isSet():
              >
              self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING, 5000)
              time.sleep(5)
              servicemanager. LogMsg(
              servicemanager. EVENTLOG_INFORM ATION_TYPE,
              servicemanager. PYS_SERVICE_STO PPED,
              (self._svc_name _, "")
              )
              self.logger.inf o("Stopped")
              except:
              self.logger.err or('',exc_info = sys.exc_info())
              >
              >
              if __name__=='__ma in__':
              win32serviceuti l.HandleCommand Line(Service)
              >
              >
              I see some problems. You don't use time sleep in services. You wait for a
              stop signal and if you don't get it by the time you reach your timeout,
              you loop. I'm not sure what you are trying to accomplish with the threading
              module, but you should start with a simple service first. I don't think you
              will need the threading at all. Here is a skeleton that might help:

              class Service(win32se rviceutil.Servi ceFramework):
              def __init__(self, args):
              win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
              self.timeout=50 00 # 5000 milliseconds or 5 seconds
              #---------------------------------------------------------------------
              # Create an event which we will use to wait on.
              # The "service stop" request will set this event.
              #---------------------------------------------------------------------
              self.hWaitStop= win32event.Crea teEvent(None, 0, 0, None)
              return

              def SvcStop(self):
              #---------------------------------------------------------------------
              # Before we do anything, tell SCM we are beginning the stop process.
              #---------------------------------------------------------------------
              self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
              #---------------------------------------------------------------------
              # And set my event, note you don't stop here, you just set the flag
              # so that you will exit from your while loop in SvcDoRun
              #---------------------------------------------------------------------
              win32event.SetE vent(self.hWait Stop)
              return

              def SvcDoRun(self):
              import servicemanager
              #---------------------------------------------------------------------
              # Make entry in the event log that this service started
              #---------------------------------------------------------------------
              servicemanager. LogMsg(servicem anager.EVENTLOG _INFORMATION_TY PE,
              servicemanager. PYS_SERVICE_STA RTED,
              (self._svc_name _, ''))

              while 1:
              #-------------------------------------------------------------------
              # Wait for service stop signal, if I timeout, loop again
              #-------------------------------------------------------------------
              rc=win32event.W aitForSingleObj ect(self.hWaitS top, self.timeout)
              #
              # Check to see if self.hWaitStop happened
              #
              if rc == win32event.WAIT _OBJECT_0:
              #
              # Stop signal encountered
              #
              break

              else:
              #
              # Do your work here
              #
              pass

              #--End while--
              #---------------------------------------------------------------------
              # Log stopped message to EventLog
              #---------------------------------------------------------------------
              servicemanager. LogMsg(servicem anager.EVENTLOG _INFORMATION_TY PE,
              servicemanager. PYS_SERVICE_STO PPED,
              (self._svc_name _, ''))

              return



              Note: I pieced this together from a working service, it has NOT been
              tested. It should be VERY close.

              If you don't have it already you might want to pick up a copy of
              Python Programming on Win32 by Mark Hammond and Andy Robinson. It helped
              me a LOT.

              -Larry

              Comment

              • Giles Brown

                #8
                Re: _ssl.pyd is buggy?

                Something I always found useful is to use the win32traceutil to set up
                the trace debugging tool.
                You can then see the output in the pythonwin trace collector tool.
                This is very useful for
                Python services and COM servers.

                Best of luck,
                Giles

                Comment

                • Giles Brown

                  #9
                  Re: _ssl.pyd is buggy?

                  On 14 Feb, 00:17, "Giles Brown" <giles_br...@ho tmail.comwrote:
                  Something I always found useful is to use the win32traceutil to set up
                  the trace debugging tool.
                  You can then see the output in the pythonwin trace collector tool.
                  This is very useful for
                  Python services and COM servers.
                  >
                  Best of luck,
                  Giles
                  Eh? Wrong thread. Damn the new google groups interface!

                  Comment

                  Working...