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

Support gracefully shutdown when SIGINT/Ctrl+C #31

Merged
merged 1 commit into from
Feb 14, 2018

Conversation

pjw91
Copy link
Contributor

@pjw91 pjw91 commented Feb 14, 2018

Detach subprocess from interpreter's process group, avoids receiving SIGINT from it.

When hitting Ctrl+C, the subprocess Xvfb (and webdriver/selenium), receives SIGINT and shutdown, probably before the custom clean-up code. (race condition)

If I use a class Page to wrap around selenium, and have a clean-up code in exit to close the opened window:

class Page:
  def __init__(self, wd):
    self.wd=wd
  def __enter__(self):
    // open window by js, and calculate the opened window handle
    self.window = // set(new_window_handles) - set(new_window_handles)
  def __exit__(self, *a):
    //xvfb and webdriver stop here, and...
    self.switch_to(self.window)  // cause this line fails
    self.close()

Detach subprocess from interpreter's process group, avoids receiving SIGINT from it
@cgoldberg cgoldberg merged commit 5d481b1 into cgoldberg:master Feb 14, 2018
@cgoldberg
Copy link
Owner

thanks!

@pjw91
Copy link
Contributor Author

pjw91 commented Feb 23, 2018

Actually, this patch forces the user to properly shutdown the Xfvb; otherwise, it would be an orphan process.

Shall this become an optional feature?

@cgoldberg
Copy link
Owner

I just reverted this in master for now. Will investigate when I have time.

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

Successfully merging this pull request may close these issues.

2 participants