Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3275704
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:10:27+00:00 2026-05-17T19:10:27+00:00

I managed to install a Python script as a service using this recipe at

  • 0

I managed to install a Python script as a service using this recipe at ActiveState: win-services-helper.

In order to get much use out of it, I included the business end of my program by replacing lines 99 – 100:

 95   class Test(Service):
 96       def start(self):
 97           self.runflag=True
 98           while self.runflag:
 99               # My logging script
100               # goes here
101        def stop(self):
102            self.runflag=False
103            self.log("I'm done")
105
106    instart(Test, 'aTest', 'Python Service Test')

My problem is, the service logs only one entry and then stops by itself. Then I go to services.msc, attempt to start the service again, then Windows displays this message:

The Python Service Test service on Local Computer started and then stopped. Some services stop automatically when they have no work to do, for example, the Performance Logs and Alerts service.

How come my service thinks it has nothing to do when I placed it in an infinite loop? It should stop only when I shut down the computer and start working again the next time the computer is turned on, even without anyone logging in.

NOTE: My logging script uses simple file read/write to csv. It doesn’t use any fancy logging modules.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:10:27+00:00Added an answer on May 17, 2026 at 7:10 pm

    It works now. Thanks everyone for the insights!

    The recipe consisted of two scripts:

    • winservice.py
    • winservice_test.py

    In my previous attempt, I picked out some lines which I thought were useful. I might have missed some of them, hence it didn’t work.

    I left winservice.py as it is. For the business end of my script, I placed it in a loop structure in winservice_test.py.

    After writing the code, I went to the command line, browsed to where the two scripts were stored, then installed the service with

    python winservice_test.py
    

    My service can now be accessed through services.msc. By default, it runs as Local system account, which presents problems upon logging out. The service will still continue, but it will grind to a halt because the account doesn’t have write access to the log folder.

    I modified its Properties so that it runs with my user account (which has write access to the log folder). My service now survives logouts, stops working only upon shutdown, and also starts itself as soon as Windows boots up even without anyone logging in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a managed API to retrieve an application's install date using the Product
Have you managed to get Aptana Studio debugging to work? I tried following this,
I managed to create a class using CodeDom and add a single method to
If I have managed to locate and verify the existence of a file using
I'm using managed c++ to implement a method that returns a string. I declare
Has anyone managed to use ItemizedOverlays in Android Beta 0.9? I can't get it
I've somehow managed to get an SVN repository into a bad state. I've moved
I've managed to mostly ignore all this multi-byte character stuff, but now I need
Do you know managed tools for manipulating PowerPoint files? The tool should be 100%
What problems does MEF (Managed Extensibility Framework) solves that cannot be solved by existing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.