Skip to content

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

Closed
@AzureIP

Description

@AzureIP
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions