By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,771 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,771 IT Pros & Developers. It's quick & easy.

_ssl.pyd is buggy?

P: n/a

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_Application.py and win32_Service.py. 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.exe. The
event log shows this:
Information: The AmazonOfferDownloaderService 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,threading,time

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

stopped = threading.Event()
stopped.clear()
processor = Processor(stopped)
thread.start_new_thread(processor.Process,())
logger = getLogger('win32_Application')
logger.info("Staring as application. Please press CTRL+C to stop service.")
while 1:
try:
time.sleep(1)
except:
break
logger.info("Stopping application " + SERVICE_NAME)
stopped.set()
while not processor.stopped.isSet():
logger.debug("Waiting for the processor to finish...")
time.sleep(1)

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

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

import traceback
import thread,threading

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.stopped = threading.Event()
self.stopped.clear()
self.logger = getLogger(SERVICE_NAME)

def SvcStop(self):
self.logger.info("Got SvcStop, trying to stop service...")
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)
self.stopped.set()

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_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
self.logger.info("Started.")
self.logger.debug("Creating processor instance")
processor = Processor(self.stopped)
self.logger.debug("Starting processor thread")
thread.start_new_thread(processor.Process,())
self.logger.debug("Waiting for the processor thread to finish")
self.stopped.wait()
self.logger.debug("Stopping")
time.sleep(1)
while not processor.stopped.isSet():

self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING, 5000)
time.sleep(5)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, "")
)
self.logger.info("Stopped")
except:
self.logger.error('',exc_info = sys.exc_info())
if __name__=='__main__':
win32serviceutil.HandleCommandLine(Service)
Feb 13 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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_Application.py and win32_Service.py. 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.exe. The
event log shows this:
Information: The AmazonOfferDownloaderService 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,threading,time

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

stopped = threading.Event()
stopped.clear()
processor = Processor(stopped)
thread.start_new_thread(processor.Process,())
logger = getLogger('win32_Application')
logger.info("Staring as application. Please press CTRL+C to stop service.")
while 1:
try:
time.sleep(1)
except:
break
logger.info("Stopping application " + SERVICE_NAME)
stopped.set()
while not processor.stopped.isSet():
logger.debug("Waiting for the processor to finish...")
time.sleep(1)

logger.info("Application stopped.")
>>>Here is the code for the service:

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

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

import traceback
import thread,threading

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.stopped = threading.Event()
self.stopped.clear()
self.logger = getLogger(SERVICE_NAME)

def SvcStop(self):
self.logger.info("Got SvcStop, trying to stop service...")
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)
self.stopped.set()

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_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
self.logger.info("Started.")
self.logger.debug("Creating processor instance")
processor = Processor(self.stopped)
self.logger.debug("Starting processor thread")
thread.start_new_thread(processor.Process,())
self.logger.debug("Waiting for the processor thread to finish")
self.stopped.wait()
self.logger.debug("Stopping")
time.sleep(1)
while not processor.stopped.isSet():

self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING, 5000)
time.sleep(5)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, "")
)
self.logger.info("Stopped")
except:
self.logger.error('',exc_info = sys.exc_info())
if __name__=='__main__':
win32serviceutil.HandleCommandLine(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
Feb 13 '07 #2

P: n/a
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 RotatingFileHandler, 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
Feb 13 '07 #3

P: n/a
En Tue, 13 Feb 2007 14:40:20 -0300, Laszlo Nagy
<ga*****@designaproduct.bizescribió:
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 RotatingFileHandler, 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

Feb 13 '07 #4

P: n/a
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
Feb 13 '07 #5

P: n/a
En Tue, 13 Feb 2007 16:49:10 -0300, Laszlo Nagy
<ga*****@designaproduct.bizescribió:
>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

Feb 13 '07 #6

P: n/a
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_Application.py and win32_Service.py. 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.exe. The
event log shows this:
Information: The AmazonOfferDownloaderService 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,threading,time

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

stopped = threading.Event()
stopped.clear()
processor = Processor(stopped)
thread.start_new_thread(processor.Process,())
logger = getLogger('win32_Application')
logger.info("Staring as application. Please press CTRL+C to stop service.")
while 1:
try:
time.sleep(1)
except:
break
logger.info("Stopping application " + SERVICE_NAME)
stopped.set()
while not processor.stopped.isSet():
logger.debug("Waiting for the processor to finish...")
time.sleep(1)

logger.info("Application stopped.")
>>>Here is the code for the service:

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

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

import traceback
import thread,threading

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.stopped = threading.Event()
self.stopped.clear()
self.logger = getLogger(SERVICE_NAME)

def SvcStop(self):
self.logger.info("Got SvcStop, trying to stop service...")
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)
self.stopped.set()

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_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
self.logger.info("Started.")
self.logger.debug("Creating processor instance")
processor = Processor(self.stopped)
self.logger.debug("Starting processor thread")
thread.start_new_thread(processor.Process,())
self.logger.debug("Waiting for the processor thread to finish")
self.stopped.wait()
self.logger.debug("Stopping")
time.sleep(1)
while not processor.stopped.isSet():

self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING, 5000)
time.sleep(5)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, "")
)
self.logger.info("Stopped")
except:
self.logger.error('',exc_info = sys.exc_info())
if __name__=='__main__':
win32serviceutil.HandleCommandLine(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(win32serviceutil.ServiceFramework):
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.timeout=5000 # 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.CreateEvent(None, 0, 0, None)
return

def SvcStop(self):
#---------------------------------------------------------------------
# Before we do anything, tell SCM we are beginning the stop process.
#---------------------------------------------------------------------
self.ReportServiceStatus(win32service.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.SetEvent(self.hWaitStop)
return

def SvcDoRun(self):
import servicemanager
#---------------------------------------------------------------------
# Make entry in the event log that this service started
#---------------------------------------------------------------------
servicemanager.LogMsg(servicemanager.EVENTLOG_INFO RMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))

while 1:
#-------------------------------------------------------------------
# Wait for service stop signal, if I timeout, loop again
#-------------------------------------------------------------------
rc=win32event.WaitForSingleObject(self.hWaitStop, 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(servicemanager.EVENTLOG_INFO RMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(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
Feb 13 '07 #7

P: n/a
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

Feb 14 '07 #8

P: n/a
On 14 Feb, 00:17, "Giles Brown" <giles_br...@hotmail.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!

Feb 14 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.