Running a Windows Python service without pythonservice.exe?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Running a Windows Python service without pythonservice.exe?

jalopyuser
A few weeks ago, Mark mentioned that there's now a way to run a Windows
service without pythonservice.exe.

I'd like to hear more about that.  Right now, I'm stuck with my UpLib
system on Windows.  I'd like to be able to install everything in the
UpLib directory, including a private copy of Python and PyWin32.  But
then there's no way to tell pythonservice.exe where the modules are, and
so Python services don't start.

I'm thinking the problem is this code in PythonService.cpp:

// Our EXE entry point.
 1540
 1541 int _tmain(int argc, TCHAR **argv)
 1542 {
 1543 PyObject *module, *f;
 1544 PyThreadState *threadState;
 1545 HMODULE hmod;
 1546 FARPROC proc;
 1547 Py_Initialize();
 1548 PyEval_InitThreads();
 1549 module = PyImport_ImportModule("servicemanager");
 1550 if (!module) goto failed;

I've got the PyWin32 extensions installed in a private site-packages
directory under my stuff, which isn't the same as the Python
site-packages site.  I need a way to set PYTHONPATH, or in some other
way initialize the DLL load path and Python sys.path, before running the
pythonservice.exe, don't I?  Otherwise, this load of "servicemanager"
will fail (and Py_Initialize() will fail if I don't copy
pythonservice.exe to the same location as python.exe and python26.dll).

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
On 10/05/2010 7:08 AM, Bill Janssen wrote:

> A few weeks ago, Mark mentioned that there's now a way to run a Windows
> service without pythonservice.exe.
>
> I'd like to hear more about that.  Right now, I'm stuck with my UpLib
> system on Windows.  I'd like to be able to install everything in the
> UpLib directory, including a private copy of Python and PyWin32.  But
> then there's no way to tell pythonservice.exe where the modules are, and
> so Python services don't start.
>
> I'm thinking the problem is this code in PythonService.cpp:
>
> // Our EXE entry point.
>   1540
>   1541 int _tmain(int argc, TCHAR **argv)
>   1542 {
>   1543 PyObject *module, *f;
>   1544 PyThreadState *threadState;
>   1545 HMODULE hmod;
>   1546 FARPROC proc;
>   1547 Py_Initialize();
>   1548 PyEval_InitThreads();
>   1549 module = PyImport_ImportModule("servicemanager");
>   1550 if (!module) goto failed;
>
> I've got the PyWin32 extensions installed in a private site-packages
> directory under my stuff, which isn't the same as the Python
> site-packages site.  I need a way to set PYTHONPATH, or in some other
> way initialize the DLL load path and Python sys.path, before running the
> pythonservice.exe, don't I?  Otherwise, this load of "servicemanager"
> will fail (and Py_Initialize() will fail if I don't copy
> pythonservice.exe to the same location as python.exe and python26.dll).

That's correct.  Using python.exe as the host will involve having a .py
script which imports the servicemanager module then call
PrepareToHostSingle and instantiate the service class - or something
like that :)

Another alternative is to ship a slightly modified pythonxx.dll - it has
a feature where a certain string resource contains the basename of the
registry key used at runtime to load the pythonpath - eg, you will find
the resource has "2.6" for Python 2.6 builds.  Using a resource editor
(or even a script using pywin32) to change this to some custom value
will mean the pythonpath can be loaded from a private key in the
registry, meaning you still get isolation from other installed Python
versions.

HTH,

Mark
>
> Bill
> _______________________________________________
> python-win32 mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
Mark Hammond <[hidden email]> wrote:

> That's correct.  Using python.exe as the host will involve having a
> .py script which imports the servicemanager module then call
> PrepareToHostSingle and instantiate the service class - or something
> like that :)

How definitive :-).  I'm already generating a python script for each
service, so this could easily be incorporated, if I knew exactly what it
was I have to do.

1.  Set up the sys.path and os.environ["Path"] properly.

2.  import servicemanager

3.  define my class

4.  call servicemanager.PrepareToHostSingle(my class name)

Seem right?

> Another alternative is to ship a slightly modified pythonxx.dll - it
> has a feature where a certain string resource contains the basename of
> the registry key used at runtime to load the pythonpath - eg, you will
> find the resource has "2.6" for Python 2.6 builds.  Using a resource
> editor (or even a script using pywin32) to change this to some custom
> value will mean the pythonpath can be loaded from a private key in the
> registry, meaning you still get isolation from other installed Python
> versions.

I could do that, I guess.  I'd like to be able to script all the
preparations, so if it's a GUI step that would be a Bad Thing.  But a
script using pywin32 would be great.  So, I need to know a couple of
things:

1.  What's the name of this "certain string resource"?

2.  How would one write such a pywin32 script :-)?

I wrote this script to answer question #1:

-----------------------------------------------------------------
import sys, os

import win32api, win32con

handle = win32api.LoadLibrary(sys.argv[1])
for rname in win32api.EnumResourceNames(handle, win32con.RT_STRING):
    rvalue = win32api.LoadResource(handle, win32con.RT_STRING, rname)
    print rname, rvalue
-----------------------------------------------------------------

$ python resource.py python26.dll
63 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^C^@2^@.^@6^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
$

So, the "name" is 63, and it's a 38-byte value with a lot of nul
characters in it.  I'm unsure of just how to hack it with UpdateResource
-- do I just center the replacement text and pad with nul characters?
And what's the registry key this works against, anyway?  I'd have to
update that as part of my installer, too.

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-3
On 11/05/2010 12:50 PM, Bill Janssen wrote:

> Mark Hammond<[hidden email]>  wrote:
>
>> That's correct.  Using python.exe as the host will involve having a
>> .py script which imports the servicemanager module then call
>> PrepareToHostSingle and instantiate the service class - or something
>> like that :)
>
> How definitive :-).  I'm already generating a python script for each
> service, so this could easily be incorporated, if I knew exactly what it
> was I have to do.
>
> 1.  Set up the sys.path and os.environ["Path"] properly.
>
> 2.  import servicemanager
>
> 3.  define my class
>
> 4.  call servicemanager.PrepareToHostSingle(my class name)
>
> Seem right?

Sounds about right - but reading pythonservice.cpp is really the
definitive source to what needs to be done.  Sadly I can't find anything
more specific, such as a sample.

>> Another alternative is to ship a slightly modified pythonxx.dll - it
>> has a feature where a certain string resource contains the basename of
>> the registry key used at runtime to load the pythonpath - eg, you will
>> find the resource has "2.6" for Python 2.6 builds.  Using a resource
>> editor (or even a script using pywin32) to change this to some custom
>> value will mean the pythonpath can be loaded from a private key in the
>> registry, meaning you still get isolation from other installed Python
>> versions.
>
> I could do that, I guess.  I'd like to be able to script all the
> preparations, so if it's a GUI step that would be a Bad Thing.  But a
> script using pywin32 would be great.  So, I need to know a couple of
> things:
>
> 1.  What's the name of this "certain string resource"?
>
> 2.  How would one write such a pywin32 script :-)?
>
> I wrote this script to answer question #1:
>
> -----------------------------------------------------------------
> import sys, os
>
> import win32api, win32con
>
> handle = win32api.LoadLibrary(sys.argv[1])
> for rname in win32api.EnumResourceNames(handle, win32con.RT_STRING):
>      rvalue = win32api.LoadResource(handle, win32con.RT_STRING, rname)
>      print rname, rvalue
> -----------------------------------------------------------------
>
> $ python resource.py python26.dll
> 63 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^C^@2^@.^@6^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
> $
>
> So, the "name" is 63, and it's a 38-byte value with a lot of nul
> characters in it.  I'm unsure of just how to hack it with UpdateResource
> -- do I just center the replacement text and pad with nul characters?
> And what's the registry key this works against, anyway?  I'd have to
> update that as part of my installer, too.

I think the above loaded a string *table*.  The resource ID is 1000, and
py2exe has some code to deal with updating this for a file.  It does:

         from py2exe.resources.StringTables import StringTable, RT_STRING
         from py2exe_util import add_resource, load_resource
         from py2exe.resources.VersionInfo import RT_VERSION

...
         # OK - do the strings.
         s = StringTable()
         # 1000 is the resource ID Python loads for its winver.
         s.add_string(1000, new_winver)
         for id, data in s.binary():
             add_resource(ensure_unicode(dll_name), data, RT_STRING, id,
False)

While this could be done with pywin32 and the win32api.UpdateResource
function, that would probably require some struct magic - the
StringTable object in py2exe hides some of this from you.

HTH,

Mark
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
Thanks, Mark.

I suppose I could run regsetup.py, but that would make my private Python
globally known, not really what I want to do.

I'll soldier on with option (a), using python.exe to run the service,
and see if I can get that to work on a simple example.

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
In reply to this post by Mark Hammond-3
Mark Hammond <[hidden email]> wrote:

> Sounds about right - but reading pythonservice.cpp is really the
> definitive source to what needs to be done.  Sadly I can't find
> anything more specific, such as a sample.

OK.  pythonservice.exe has a lot of stuff in it -- for instance, there
seems to be a standalone implementation of servicemanager.

And don't I have to hack InstallService somewhere, too?  Otherwise the
Service Manager will try to use PythonService.exe instead of python.exe,
won't it?

A simple example would sure be a help :-).

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
In reply to this post by Mark Hammond-3
OK, so I wrote my own InstallService:

--------------------------------------------------------------------------------
import sys, os, win32service

def InstallService(pythonClassFile, serviceName, displayName,
                   startType = None, errorControl = None, bRunInteractive = 0,
                   serviceDeps = None, userName = None, password = None,
                   exeArgs = None, description = None):

    # Handle the default arguments.
    if startType is None:
        startType = win32service.SERVICE_DEMAND_START
    serviceType = win32service.SERVICE_WIN32_OWN_PROCESS
    if bRunInteractive:
        serviceType = serviceType | win32service.SERVICE_INTERACTIVE_PROCESS
    if errorControl is None:
        errorControl = win32service.SERVICE_ERROR_NORMAL

    pythonClassFile = os.path.abspath(pythonClassFile)
    commandLine = '"%s" "%s"' % (sys.executable, pythonClassFile)
    if exeArgs:
        commandLine = commandLine + " " + exeArgs
    hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS)
    try:
        hs = win32service.CreateService(
            hscm,
            serviceName,
            displayName,
            win32service.SERVICE_ALL_ACCESS,         # desired access
            serviceType,        # service type
            startType,
            errorControl,       # error control type
            commandLine,
            None,
            0,
            serviceDeps,
            userName,
            password)
        if description is not None:
            try:
                win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description)
            except NotImplementedError:
                pass    ## ChangeServiceConfig2 and description do not exist on NT
        win32service.CloseServiceHandle(hs)
    finally:
        win32service.CloseServiceHandle(hscm)

if __name__ == "__main__":
    if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
        InstallService(sys.argv[1], os.path.basename(sys.argv[1]), os.path.basename(sys.argv[1]))
--------------------------------------------------------------------------------

Note that it doesn't try to register the class string.  Seems to work:

$ python myinstallservice.py test2.py
$ sc query test2.py

SERVICE_NAME: test2.py
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0 (0x0)
        SERVICE_EXIT_CODE  : 0 (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
$ sc qc test2.py
[SC] GetServiceConfig SUCCESS

SERVICE_NAME: test2.py
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 3   DEMAND_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "c:\UpLib\1.7.9\python\python.exe" "c:\testrepo2\overhead\test2.py"  
        LOAD_ORDER_GROUP   :  
        TAG                : 0  
        DISPLAY_NAME       : test2.py  
        DEPENDENCIES       :  
        SERVICE_START_NAME : LocalSystem  
$

Although I think I should be crunching those paths to the "short" form.

However, it doesn't start:

$ sc start test2.py
[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.
$

Here's what's in test2.py:

--------------------------------------------------------------------------------
import win32serviceutil
import win32service
import win32event
import win32evtlogutil
import servicemanager

class MyService(win32serviceutil.ServiceFramework):

   _svc_name_ = "test2.py"
   _svc_display_name_ = "test2.py"

   def __init__(self, args):
       win32serviceutil.ServiceFramework.__init__(self, args)
       self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

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

   def SvcDoRun(self):
       servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                             servicemanager.PYS_SERVICE_STARTING,
                             (self._svc_name_, ""))
       while True:
           win32event.WaitForSingleObject(self.hWaitStop, 500)

servicemanager.Initialize()
servicemanager.PrepareToHostSingle(MyService)
win32serviceutil.HandleCommandLine(MyService)
--------------------------------------------------------------------------------

What am I missing here?

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-3
On 12/05/2010 4:28 AM, Bill Janssen wrote:
> OK, so I wrote my own InstallService:

That actually isn't necessary - the class can provide _exe_name_ and
_exe_args_ attributes to override the defaults.

See attached sample which works for me - be sure to place it in the same
directory as the pipeTestService.py sample (win32/Demos/service).  I'm
afraid I did mislead you a little in the steps necessary to get things
going, but I'm checking this sample into pywin32 so it doesn't get lost
again :)

Cheers,

Mark

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32

nativePipeTestService.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
In reply to this post by Mark Hammond-4
test
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
In reply to this post by Mark Hammond-4
test
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
In reply to this post by Mark Hammond-4
test
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
In reply to this post by Mark Hammond-4
On 12/05/2010 4:51 PM, Mark Hammond wrote:
> test

Oops - sorry about the noise :(

One-of-the-risks-when-working-on-email-clients ly,

Mark
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
In reply to this post by Mark Hammond-3
Mark Hammond <[hidden email]> wrote:

> See attached sample which works for me - be sure to place it in the
> same directory as the pipeTestService.py sample (win32/Demos/service).

All right, I put it in a file called nativePipeTestService.py, in that
directory, and tried it.  Here's what I get:

$ pwd -W
c:/UpLib/1.7.9/python/Lib/site-packages/win32/Demos/service
$ python nativePipeTestService.py install
Installing service PyNativePipeTestService
Service installed
$ sc query PyNativePipeTestService

SERVICE_NAME: PyNativePipeTestService
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 1077 (0x435)
        SERVICE_EXIT_CODE  : 0 (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
$ sc qc PyNativePipeTestService
[SC] GetServiceConfig SUCCESS

SERVICE_NAME: PyNativePipeTestService
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 3   DEMAND_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "c:\UpLib\1.7.9\python\python.exe" "c:\UpLib\1.7.9\python\Lib\site-packages\win32\Demos\service\nativePipeTestService.py"  
        LOAD_ORDER_GROUP   :  
        TAG                : 0  
        DISPLAY_NAME       : Python Native Pipe Test Service  
        DEPENDENCIES       :  
        SERVICE_START_NAME : LocalSystem  
$ python nativePipeTestService.py start
Starting service PyNativePipeTestService []
Error starting service: The service did not respond to the start or control request in a timely fashion.
$

What should I try next?

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
Bill Janssen <[hidden email]> wrote:

> $ python nativePipeTestService.py start
> Starting service PyNativePipeTestService []
> Error starting service: The service did not respond to the start or control request in a timely fashion.
> $

I rebooted and tried again, same result.

Then I tried setting up a win32trace window first, and ran

$ python nativePipeTestService.py
Redirecting output to win32trace remote collector
$

What shows up in the trace window is this:

> C:\UpLib\1.7.9\python\Lib\site-packages\win32\lib>python win32traceutil.py
Collecting Python Trace Output...
service is starting...
(execute this script with '--help' if that isn't what you want)
Something went bad!
Traceback (most recent call last):
  File "nativePipeTestService.py", line 51, in <module>
    main()
  File "nativePipeTestService.py", line 44, in main
    servicemanager.StartServiceCtrlDispatcher()
error: (1063, 'StartServiceCtrlDispatcher', 'The service process could not connect to the service controller.')

This smacks of a registry problem, but I'm unsure where to go from here...

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
On 13/05/2010 2:08 AM, Bill Janssen wrote:

> Bill Janssen<[hidden email]>  wrote:
>
>> $ python nativePipeTestService.py start
>> Starting service PyNativePipeTestService []
>> Error starting service: The service did not respond to the start or control request in a timely fashion.
>> $
>
> I rebooted and tried again, same result.
>
> Then I tried setting up a win32trace window first, and ran
>
> $ python nativePipeTestService.py
> Redirecting output to win32trace remote collector
> $
>
> What shows up in the trace window is this:
>
>> C:\UpLib\1.7.9\python\Lib\site-packages\win32\lib>python win32traceutil.py
> Collecting Python Trace Output...
> service is starting...
> (execute this script with '--help' if that isn't what you want)
> Something went bad!
> Traceback (most recent call last):
>    File "nativePipeTestService.py", line 51, in<module>
>      main()
>    File "nativePipeTestService.py", line 44, in main
>      servicemanager.StartServiceCtrlDispatcher()
> error: (1063, 'StartServiceCtrlDispatcher', 'The service process could not connect to the service controller.')
>
> This smacks of a registry problem, but I'm unsure where to go from here...

When run with no args, the program assumes it is being started as the
service - see the first 3 output lines.

Execute 'python nativePipeTestService.py install' to install it, then
start it as normal (ie, don't run it manually with no args).  If you
want different cmdline behaviour, the script can be re-worked to catch
the error calling StartServiceCtrlDispatcher(), assume the user is
running it interactively and take some different action.

Mark
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
Mark Hammond <[hidden email]> wrote:

> Execute 'python nativePipeTestService.py install' to install it, then
> start it as normal (ie, don't run it manually with no args).

Yes, that's what I tried first.  See my message
<[hidden email]>, just previous to the one you replied to.

$ sc start PyNativePipeTestService
[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

$

Same thing if I try to start it from the System Management GUI tool.

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-4
On 13/05/2010 9:25 AM, Bill Janssen wrote:
> Mark Hammond<[hidden email]>  wrote:
>
>> Execute 'python nativePipeTestService.py install' to install it, then
>> start it as normal (ie, don't run it manually with no args).
>
> Yes, that's what I tried first.  See my message
> <[hidden email]>, just previous to the one you replied to.

Sorry - I missed that 'install' command in that message.

> $ sc start PyNativePipeTestService
> [SC] StartService FAILED 1053:
>
> The service did not respond to the start or control request in a timely fashion.
>
> $
>
> Same thing if I try to start it from the System Management GUI tool.

I'm not sure what the problem could be.  It appears Python is finding
all the modules OK and I can't think of why the service request would be
failing.  Does the standard old pipeTestService.py still work for you?

Mark
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

jalopyuser
Mark Hammond <[hidden email]> wrote:

> On 13/05/2010 9:25 AM, Bill Janssen wrote:
> > Mark Hammond<[hidden email]>  wrote:
> >
> >> Execute 'python nativePipeTestService.py install' to install it, then
> >> start it as normal (ie, don't run it manually with no args).
> >
> > Yes, that's what I tried first.  See my message
> > <[hidden email]>, just previous to the one you replied to.
>
> Sorry - I missed that 'install' command in that message.
>
> > $ sc start PyNativePipeTestService
> > [SC] StartService FAILED 1053:
> >
> > The service did not respond to the start or control request in a timely fashion.
> >
> > $
> >
> > Same thing if I try to start it from the System Management GUI tool.
>
> I'm not sure what the problem could be.  It appears Python is finding
> all the modules OK and I can't think of why the service request would
> be failing.  Does the standard old pipeTestService.py still work for
> you?

No, it fails the same way.  Is there a test suite for PyWin32 that I
could run to verify my installation is good?

Bill
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Mark Hammond-3
On 15/05/2010 5:06 AM, Bill Janssen wrote:

> Mark Hammond<[hidden email]>  wrote:
>
>> On 13/05/2010 9:25 AM, Bill Janssen wrote:
>>> Mark Hammond<[hidden email]>   wrote:
>>>
>>>> Execute 'python nativePipeTestService.py install' to install it, then
>>>> start it as normal (ie, don't run it manually with no args).
>>>
>>> Yes, that's what I tried first.  See my message
>>> <[hidden email]>, just previous to the one you replied to.
>>
>> Sorry - I missed that 'install' command in that message.
>>
>>> $ sc start PyNativePipeTestService
>>> [SC] StartService FAILED 1053:
>>>
>>> The service did not respond to the start or control request in a timely fashion.
>>>
>>> $
>>>
>>> Same thing if I try to start it from the System Management GUI tool.
>>
>> I'm not sure what the problem could be.  It appears Python is finding
>> all the modules OK and I can't think of why the service request would
>> be failing.  Does the standard old pipeTestService.py still work for
>> you?
>
> No, it fails the same way.  Is there a test suite for PyWin32 that I
> could run to verify my installation is good?

win32\test\testall.py is probably the closest, but it only checks the
pywin32 implementation and doesn't do much in the way of 'environment'
checking - indeed, nothing related to services is automatically tested
at all.

It might be worth checking your windows event log - pythonservice may
have written something there...

Mark
_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: Running a Windows Python service without pythonservice.exe?

Kyle
Bill, did you ever find a resolution to your pythonservice.exe issue?

>I've got the PyWin32 extensions installed in a private site-packages
>directory under my stuff, which isn't the same as the Python
>site-packages site.  I need a way to set PYTHONPATH, or in some other
>way initialize the DLL load path and Python sys.path, before running the
>pythonservice.exe, don't I?  Otherwise, this load of "servicemanager"
>will fail (and Py_Initialize() will fail if I don't copy
>pythonservice.exe to the same location as python.exe and python26.dll).

I have the same requirement.  I need to be able to package up a private copy of python and pywin32 under my own  directory.

I'm trying Mark's PyNativePipeTestService script, but I receive the same error (WinXP):

[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.

12