Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:53:55+00:00 2026-05-27T22:53:55+00:00

I know pyinotify.Notifier.check_events(self, timeout=None) can take a timeout – but I’d prefer it poll

  • 0

I know pyinotify.Notifier.check_events(self, timeout=None) can take a timeout – but I’d prefer it poll indefinitely. Is it possible to interrupt it?

I am calling Notifier.stop(self), but it does not seem to be escaping from check_events.

In the below example, another thread calls stopIt(), and self.notifier.stop() is called – but neither “check_events is True” nor “check_events is False” is printed:

def run(self):
    self.notifier = pyinotify.Notifier(self.monitor, MyProcessing(self))
    while True:
        self.notifier.process_events()
        print "Waiting at check_events"
        if self.notifier.check_events():
            print "check_events is True"
            self.notifier.read_events()
        else:
            print "check_events is False"
    print "Out of while"
    return True

def stopIt(self):
    self.notifier.stop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:53:56+00:00Added an answer on May 27, 2026 at 10:53 pm

    Even though threads run concurrently, each thread has its own independent flow of execution. One thread can not inject commands into another thread’s flow of execution by calling its methods (such as by calling stopIt).

    So what else can we do? Well, besides the obvious option of using the timeout, you could use the other thread to create a dummy file, say, which triggers an IN_CREATE event which MyProcessing could then process.

    I see MyProcessing(self) knows self, so it could set self.done = True, (where self is the threading.Thread instance, not the MyProcessing instance.) MyProcessing could then delete the dummy file.

    Then you could use

        if (not self.done) and self.notifier.check_events():
            print "check_events is True"
            self.notifier.read_events()
    

    to break out of the check without setting a timeout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are similar questions already on SO but none of them seem
I know regex and substrings is a common question on here but i can
I know I can do this by str.c_str() , but I do not want
I know we can trigger an Intent.ACTION_SEND intent to send email. But according to
I know I have done this before but I can't seem to remember where
I know you can minify/condense Javascript or CSS code, but can you do this
I know regular expressions can be used, but am not able to find the
I know there are a few similar questions to this but I just can't
Know this might be rather basic, but I been trying to figure out how
I know that I can do something like $int = (int)99; //(int) has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.