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

make graceful shutdown thread-safe #1033

Merged
merged 1 commit into from May 23, 2015
Merged

Conversation

ccl0326
Copy link

@ccl0326 ccl0326 commented May 19, 2015

No description provided.

@benoitc
Copy link
Owner

benoitc commented May 19, 2015

+1 can anyone else review it? So far looks good for a merge

@benoitc
Copy link
Owner

benoitc commented May 20, 2015

how can I reproduce the issue?

@benoitc
Copy link
Owner

benoitc commented May 20, 2015

Sorry I didn't see the related issue #1032 . looking at it.

@@ -50,10 +49,27 @@ def watchdog(self):
self.log.info("Parent changed, shutting down: %s", self)
self.stop()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop method is not defined. You have remove the method stop.

@ccl0326
Copy link
Author

ccl0326 commented May 21, 2015

@fatelei Thanks.I'm so sorry for missed it out.Parent changed and Auto-restart has been tested.

def heartbeat(self):
if not self.alive:
if self.server_alive:
if hasattr(self, 'server'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we write this like the following snippet? (untested)

if hasattr(self, 'server'):
    try:
        self.server.stop()
    except Exception:
        pass

self.server_alive = False

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, if the server doesn't exist we need to stop the worker anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception is ignored,but in fact we don't know how to deal with it.LGTM.

@berkerpeksag
Copy link
Collaborator

LGTM, thanks!

Two minor comments:

  • Could you please squash the commits?

  • Please delete the empty lines in gunicorn/workers/gtornado.py:

    -# -*- coding: utf-8 -
    +
    +

@ccl0326
Copy link
Author

ccl0326 commented May 23, 2015

done.

berkerpeksag added a commit that referenced this pull request May 23, 2015
make graceful shutdown thread-safe
@berkerpeksag berkerpeksag merged commit e1aa806 into benoitc:master May 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants