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

Ctrl-C not working #4

Open
urso opened this issue Apr 10, 2011 · 4 comments
Open

Ctrl-C not working #4

urso opened this issue Apr 10, 2011 · 4 comments

Comments

@urso
Copy link

urso commented Apr 10, 2011

when running an Observer either with run() or start(), the program can't be stopped e.g. by pressing Ctrl-C and Signal-handlers installed (for e.g. SIGINT or SIGTERM) are ignored.

@jibleo
Copy link

jibleo commented Jun 3, 2011

I can confirm this pretty annoying issue.
I am using macfsevents (great binding!) in a launchd agent and the SIGTERM signal sent by 'launchctl unload' is ignored. This causes launchctl to send a SIGKILL signal after its timeout in order to stop the agent.
The problem is that 'launchctl unload' is fired from a UI and the about-10-sec timeout makes things look very unresponsive.

@jachin
Copy link

jachin commented Feb 17, 2012

The way I've found around this issue right now is Ctrl-\

I'm trying to figure out a way to wrap it so I can control it the way I want to.

@thomasst
Copy link
Collaborator

To solve this problem in your app, catch KeyboardInterrupt in your main thread. Do something like this:

except KeyboardInterrupt, e:
    observer.unschedule(stream)
    observer.stop()
    observer.join()

@renard
Copy link

renard commented Sep 8, 2013

Any new about that issue?

I got something like:

if __name__ == "__main__":
    try:
        obs = Observer()
        obs.start()
        str = Stream(callback, live, file_events=True)
        obs.schedule(str)
    except KeyboardInterrupt:
        print "Going to quit"
        obs.unschedule(str)
        obs.stop()
        obs.join()
        sys.exit(0)

And I still cannot terminate the program but but hitting Ctrl-\

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

5 participants