Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Why does an idle python service needs 1% to 1,6% of my CPU? #2364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AzureIP opened this issue Aug 28, 2024 · 3 comments
Closed

Why does an idle python service needs 1% to 1,6% of my CPU? #2364

AzureIP opened this issue Aug 28, 2024 · 3 comments

Comments

@AzureIP
Copy link

AzureIP commented Aug 28, 2024

import win32serviceutil
import win32service
import cherrypy


class HelloWorld(object):

    @cherrypy.expose
    def index(self):
        return "Hello world!"


class MyService(win32serviceutil.ServiceFramework):
    _svc_name_ = "myName"
    _svc_display_name_ = "myName"

    def SvcDoRun(self):
        cherrypy.quickstart(HelloWorld())

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

        self.ReportServiceStatus(win32service.SERVICE_STOPPED)
        # very important for use with py2exe
        # otherwise the Service Controller never knows that it is stopped !


if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(MyService)

Hi,

I created this simple service that contains a cherrypy webserver that provides a Hello World page. If I run this web server without a service it takes 0% CPU load. If I run this script above that runs the server as a service, it takes 1% to 1,6% of my CPU. A bit too mouch for doing nothing in my opinion. Why is that happening?

@ACrazyPencil
Copy link

What cpu do u have?

@ACrazyPencil
Copy link

ACrazyPencil commented May 13, 2025

and it’s reporting to windows

@ACrazyPencil
Copy link

Repository owner locked and limited conversation to collaborators May 13, 2025
@Avasam Avasam converted this issue into discussion #2606 May 13, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@AzureIP @ACrazyPencil and others