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

bus deadlock joining main thread #1164

Closed
ghost opened this issue Aug 27, 2012 · 2 comments
Closed

bus deadlock joining main thread #1164

ghost opened this issue Aug 27, 2012 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 27, 2012

Originally reported by: Alexey Luchko (Bitbucket: soulne4ny, GitHub: soulne4ny)


Hi!

I had to make custom win32 service running cherrypy.
While debugging it found that at cherrypy.engine.exit() it hands waiting something (for multiple objects). Log contained "Waiting for thread MainThread." I found Bus.block() waiting for all non-daemon threads at exit.

A workaround could be either tweaking threading.enumerate() before calling engine.exit() or making main thread daemon.

A possible patch attached.

Regards,
Alex


@ghost
Copy link
Author

ghost commented Aug 31, 2013

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


I have just experience exactly the same issue and you are right, the thread that execute SvcStop is not the main thread as a work around tried to communicate trough an event and it worked:

#!python
    def SvcDoRun(self):
        import servicemanager
        servicemanager.LogMsg(
               servicemanager.EVENTLOG_INFORMATION_TYPE,
               servicemanager.PYS_SERVICE_STARTED,
               (self._svc_name_, ''))
        SITE.web.start(block=False)
        win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE)
        SITE.web.stop()

    def SvcStop(self):
        import servicemanager
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STOPPED,
                              (self._svc_name_, ''))
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.stop_event)

Anyway I think that your patch will be an improvement for this case and at the same time fix the issue #1101.

@ghost
Copy link
Author

ghost commented Aug 31, 2013

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Bugfix of a potential deadlock if the main bus is stopped from a different
thread than the main thread, this is the case when is implemented as a
windows service.

Closing issue #1164
Closing issue #1101

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

No branches or pull requests

0 participants