Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows Services

6 views
Skip to first unread message

Mondal

unread,
Dec 14, 2005, 3:02:14 AM12/14/05
to
Hi,

Can anybody tell me how to develop Windows Services (which are actually
daemons) using Python. Also what protocol is most suitable for
developing a server-client application with the server running as a
Windows Service.

Thanks in advance

Bye

Peter Hansen

unread,
Dec 14, 2005, 9:44:06 AM12/14/05
to pytho...@python.org
Mondal wrote:
> Can anybody tell me how to develop Windows Services (which are actually
> daemons) using Python.

Yes, anyone can tell you. Anyone who can use Google that is. Can you?

http://www.google.com/search?q=python+windows+service

(There are directly relevant answers on the first page of results.)

> Also what protocol is most suitable for
> developing a server-client application with the server running as a
> Windows Service.

I'd suggest whatever protocol is most suitable for developing
client-server applications with the server *not* running as a Windows
Service. In other words, I don't think the manner in which the service
is invoked has much impact on the protocol you would use.

Generally the best protocol is determined more by what your server will
actually do, and performance requirements, than anything else.

-Peter

alf

unread,
Dec 14, 2005, 11:24:13 AM12/14/05
to
Also think through which Windows account will run the service, and what
permissions it will need. A little up front work here will be
appreciated by the people who have to install your service.

Mondal

unread,
Dec 15, 2005, 5:31:25 AM12/15/05
to
Hi,

Thanks to Peter, now I know how to control an *existing* Windows
service and how to run a *python script* as a Windows service. Although
these were really useful, my point was different.

I have developed a script that monitors a specified folder for changes
in the files or folders within it. I converted that script to a stand
alone exe using py2exe. ***Now I would like to run that exe as a
Windows service***.

I also intend to create an exe that will retrieve any information
stored by the file monitor mentioned above.

Please tell me how do I go about it.

Although I am a beginner in Python and Windows Services (Daemon), I am
a moderately experienced programmer.

-Regards

Frank Millman

unread,
Dec 15, 2005, 6:06:48 AM12/15/05
to

Here is an alternative solution.

I have a simple socket server program, which I wanted to run as a
service on Linux and Windows.

On Linux it was easy - start it from rc.local with a trailing &.

On Windows, I was given advice on how to use pywin32 to set up the
program as a Windows service, but it felt like overkill. Then someone
suggested 'srvany', a utility that allows you to run any program as a
service. It is part of the NT Resource Kit. I downloaded it and it
works fine for me. Google has plenty of references.

Frank Millman

Steve Holden

unread,
Dec 15, 2005, 6:15:47 AM12/15/05
to pytho...@python.org
I'm afraid that you can't just run any old executable as a Windows service.

If something is going to be run as a service then it has to use the
Windows service API so it responds correctly to being started and
stopped, for example, and "pumps" the event queue from time to time.

regards
Steve

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

bon...@gmail.com

unread,
Dec 15, 2005, 6:33:06 AM12/15/05
to

Steve Holden wrote:
> Mondal wrote:
> > Hi,
> >
> > Thanks to Peter, now I know how to control an *existing* Windows
> > service and how to run a *python script* as a Windows service. Although
> > these were really useful, my point was different.
> >
> > I have developed a script that monitors a specified folder for changes
> > in the files or folders within it. I converted that script to a stand
> > alone exe using py2exe. ***Now I would like to run that exe as a
> > Windows service***.
> >
> > I also intend to create an exe that will retrieve any information
> > stored by the file monitor mentioned above.
> >
> > Please tell me how do I go about it.
> >
> > Although I am a beginner in Python and Windows Services (Daemon), I am
> > a moderately experienced programmer.
> >
> I'm afraid that you can't just run any old executable as a Windows service.
>
> If something is going to be run as a service then it has to use the
> Windows service API so it responds correctly to being started and
> stopped, for example, and "pumps" the event queue from time to time.
>
I think there is some wrapper programs that can wrap around any console
window programs as service, either from cygwin or may be stand alone
too. Of course, the wrapped program would be stopped through some
"kill" signal rather than proper start/stop API calls.

Mondal

unread,
Dec 19, 2005, 4:59:15 AM12/19/05
to
Hi,

Every one please accept my thanks.

I have stopped using Python IDLE. Know I am using Pythonwin IDE from
Active State. They have the same core modules. But the Pywin32
extensions are a plus from Active State.

The problem is that the Pywin32 Documentation is incomplete/incorrect.
The modules by Mark Hammond are in .pyd and not in .py. The
documentayion on Active's web site is also incorrect. Here is a code
snippet from the IDE

import win32service
>>> ws=win32service
>>> ws.CreateDesktop()
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: CreateDesktop() takes exactly 4 arguments (0 given)
>>>

And here is the prototype from the documentation

win32service.CreateDesktop
PyHDESK = CreateDesktop()

Creates a new desktop in calling process's current window station

The documentation does not mention any arguments, yet there is a
TypeError.

The source code in C at Pywin32 extensions homepage are of not much
help.

So, how do i use win32 extensions?

Regards

Roger Upole

unread,
Dec 19, 2005, 10:17:24 AM12/19/05
to
Active State's help file is missing parameters from some modules built using Swig.
The .chm included with the SourceForge releases has complete parameter info.

hth
Roger

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Mondal

unread,
Dec 21, 2005, 1:04:48 AM12/21/05
to
Hi,

Thanks Upole!!!!!!! I dowloaded it. From exe files at sourceforge.net.

Regards

0 new messages