[python-win32] python win-32, 64-bits, and services

Chris Curvey chris at chriscurvey.com
Wed May 13 17:08:28 CEST 2009


On Tue, May 12, 2009 at 4:08 PM, Chris Curvey <chris at chriscurvey.com> wrote:

> I'm attempting to wrap up a Python program and turn it into a service,
> using the method listed in Mark Hammond's book (*not* using py2exe).   The
> program spawns a bunch of threads using the "subprocess" module.  If I run
> the program from the command line, everything works fine.  If I run it as a
> service, any kind of exception seems to stop the affected thread
> immediately.  Exceptions are not bubbling up to the relevant try/except
> block.
>
> The only thing I can think of right now is that I'm running on a 64-bit
> version of Windows, and that the win32 packages won't fully work in that
> environment.   (Although the startup string for Python says that it's the 32
> bit Python [MSC  v.1310 32 bit (Intel) ], so I think that's a wild goose
> chase.)
>
> Anyone have any ideas?  I'll try to put together a succinct test case that
> I can share.
>
> -Chris
>

I found the problem, but before I wrote a sharable test case.

The core of my problem was that I had misconfigured the logging module.  (By
calling logging.config.fileConfig in two places.).  Then what happened was I
would try to log something, which would cause an exception to be raised by
the logging module.  And the default behavior for the logging module is to
print errors to stdout, which does not exist because we're running in a
thread.

So there were several solutions to this problem.

1) Don't misconfigure the loggin module (duh!), or
2) set logging.raiseExceptions = 0, so that internal exceptions in the
logging module are not raised, or
3) Write my own custom logging handler and override the handleError() method
so that it does not try to write to stdout.

Thanks for the help!

-Chris

-- 
Corruptissima republica plurimae leges
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20090513/92aea8a9/attachment.htm>


More information about the python-win32 mailing list