Skip to content
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

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

Open
AzureIP opened this issue Aug 28, 2024 · 0 comments
Open

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

AzureIP opened this issue Aug 28, 2024 · 0 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@AzureIP and others