durusmail: quixote-users: Need help in running quixote.demo as medusas' ortwisteds' win32 service
Need help in running quixote.demo as medusas' or twisteds' win32 service
2004-03-29
Need help in running quixote.demo as medusas' ortwisteds' win32 service
2004-03-29
Need help in running quixote.demo as medusas' ortwisteds' win32 service
2004-03-29
Re: Need help in running quixote.demo as medusas' or twisteds' win32 service
2004-03-29
Re: Need help in running quixote.demo as medusas' or twisteds' win32 service
2004-03-29
Re: Need help in running quixote.demo as medusas' or twisteds' win32 service
2004-03-29
2004-03-29
Need help in running quixote.demo as medusas' ortwisteds' win32 service
Jason E. Sibre
2004-03-29
Samir,

This may also be useful to you, if you decide to continue in the direction
of services:

http://mail.python.org/pipermail/python-win32/2002-March/000274.html

I never woulda guessed that Python had to be installed by 'Administrator' in
order to allow the service to run after you logged out...

Jason

  -----Original Message-----
  From: quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org
[mailto:quixote-users-bounces+jsibre=chironsys.com@mems-exchange.org]On
Behalf Of Samir Patel
  Sent: Sunday, March 28, 2004 9:37 PM
  To: quixote-users@mems-exchange.org
  Subject: [Quixote-users] Need help in running quixote.demo as medusas'
ortwisteds' win32 service


  I have created a quixote program which I like to run as service on windows
machine using either medusa or twisted matrix as web server.
  I am having trouble with both of them. Am I missing something or I have to
run it with IIS or Apache?



  When I run quixote.demo (quixote 0.7a3) with medusa server as a win32
service as follows:

  import win32serviceutil
  import win32service
  import win32event

  class motorService(win32serviceutil.ServiceFramework):
      _svc_name_ = "motorService"
      _svc_display_name_ = "The Motor Service"
      def __init__(self, args):
          win32serviceutil.ServiceFramework.__init__(self, args)
          #self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

      def SvcStop(self):
          pass
         # self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
         # win32event.SetEvent(self.hWaitStop)

      def SvcDoRun(self):
          import asyncore
          from quixote.server.medusa_http import http_server, QuixoteHandler
          from quixote import enable_ptl
          from quixote.publish import Publisher
          enable_ptl()
          server = http_server.http_server('', 80)

          publisher = Publisher('quixote.demo')
          publisher.setup_logs()
          dh = QuixoteHandler(publisher, 'Quixote/demo', server)
          server.install_handler(dh)
          asyncore.loop()

          #win32event.WaitForSingleObject(self.hWaitStop,
win32event.INFINITE)

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

  **********************************************
  It runs for some time and then stop running with following error in
eventlog:

  Event Type: Error
  Event Source: Python Service
  Event Category: None
  Event ID: 3
  Date:  3/28/2004
  Time:  10:20:51 PM
  User:  N/A
  Computer: RCPORTABLE
  Description:
  The instance's SvcRun() method failed
    File "C:\Python23\lib\site-packages\win32\lib\win32serviceutil.py", line
670, in SvcRun
      self.SvcDoRun()
    File "C:\Python23\service\motorServiceMedusa.py", line 29, in SvcDoRun
      asyncore.loop()
    File "C:\Python23\lib\asyncore.py", line 193, in loop
      poll_fun(timeout, map)
    File "C:\Python23\lib\asyncore.py", line 125, in poll
      write(obj)
    File "C:\Python23\lib\asyncore.py", line 81, in write
      obj.handle_error()
    File "c:\python23\Lib\site-packages\medusa\http_server.py", line 429, in
handle_error
      asynchat.async_chat.handle_error (self)
    File "C:\Python23\lib\asyncore.py", line 418, in handle_error
      'error'
    File "C:\Python23\lib\asyncore.py", line 376, in log_info
      print '%s: %s' % (type, message)
  exceptions.IOError: (9, 'Bad file descriptor')



****************************************************************************
**********************

  When I run with twisted as follows:

  import win32serviceutil
  import win32service
  import win32event

  class motorService(win32serviceutil.ServiceFramework):
      _svc_name_ = "motorService"
      _svc_display_name_ = "The Motor Service"
      def __init__(self, args):
          win32serviceutil.ServiceFramework.__init__(self, args)
          #self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

      def SvcStop(self):
          pass
         # self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
         # win32event.SetEvent(self.hWaitStop)

      def SvcDoRun(self):
          from twisted.internet.app import Application
          from quixote.server.twisted_http import QuixoteFactory
          import quixote
          quixote.enable_ptl()
          from quixote.publish import Publisher
          from twisted.python.log import startLogging
          startLogging(open('c:/twistedexample.log','a'))

          import quixote.demo
          http_port = 80
          namespace = quixote.demo

          app = Application('Quixote')
          publisher = Publisher(namespace)
          qf = QuixoteFactory(publisher)
          app.listenTCP(http_port, qf)
          app.run(save=0)


  I got following error in twisted log file. I can not run demo at all using
twisted.

  2004/03/28 22:19 Eastern Standard Time [-] Log opened.
  2004/03/28 22:19 Eastern Standard Time [-]
C:\Python23\service\motorService.py:30: exceptions.DeprecationWarning:
twisted.internet.app is deprecated, use twisted.application or the reactor
instead.
  2004/03/28 22:19 Eastern Standard Time [*Quixote*]
quixote.server.twisted_http.QuixoteFactory starting on 80
  2004/03/28 22:19 Eastern Standard Time [*Quixote*] Starting factory

  2004/03/28 22:19 Eastern Standard Time [*Quixote*] Traceback (most recent
call last):
     File "C:\Python23\lib\site-packages\win32\lib\win32serviceutil.py",
line 670, in SvcRun
       self.SvcDoRun()
     File "C:\Python23\service\motorService.py", line 34, in SvcDoRun
       app.run(save=0)
     File "C:\Python23\Lib\site-packages\twisted\internet\app.py", line 873,
in run
       log.callWithLogger(self, reactor.run,
installSignalHandlers=installSignalHandlers)
   ---  ---
     File "C:\Python23\Lib\site-packages\twisted\python\log.py", line 65, in
callWithLogger
       callWithContext({"system": lp}, func, *args, **kw)
     File "C:\Python23\Lib\site-packages\twisted\python\log.py", line 52, in
callWithContext
       return context.call({ILogContext: newCtx}, func, *args, **kw)
     File "C:\Python23\Lib\site-packages\twisted\python\context.py", line
32, in callWithContext
       return func(*args,**kw)
     File "C:\Python23\Lib\site-packages\twisted\internet\default.py", line
124, in run
       self.startRunning(installSignalHandlers=installSignalHandlers)
     File "C:\Python23\Lib\site-packages\twisted\internet\default.py", line
120, in startRunning
       self._handleSignals()
     File "C:\Python23\Lib\site-packages\twisted\internet\default.py", line
92, in _handleSignals
       signal.signal(signal.SIGINT, self.sigInt)
   exceptions.ValueError: signal only works in main thread




reply