469,898 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Windows Services

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

Dec 14 '05 #1
9 4454
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

Dec 14 '05 #2
alf
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.

Dec 14 '05 #3
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

Dec 15 '05 #4

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.

-Regards


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

Dec 15 '05 #5
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.

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/

Dec 15 '05 #6

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.

Dec 15 '05 #7
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

Dec 19 '05 #8
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
"Mondal" <ms******@gmail.com> wrote:
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


----== 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 =----
Dec 19 '05 #9
Hi,

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

Regards

Dec 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Bill Sonia | last post: by
5 posts views Thread by =?Utf-8?B?dmlzaHJ1dGg=?= | last post: by
2 posts views Thread by =?Utf-8?B?dmlzaHJ1dGg=?= | last post: by
1 post views Thread by =?Utf-8?B?dmlzaHJ1dGg=?= | last post: by
5 posts views Thread by dm3281 | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.