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

  • Home
  • SEARCH
  • 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 6987385
In Process

The Archive Base Latest Questions

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

I have some basic questions about pyinotify that I can’t seem to find the

  • 0

I have some basic questions about pyinotify that I can’t seem to find the answers to elsewhere.

1) For a continuous directory monitor (and event processor) is it necessary to have a while( True ) loop or is the continuous event ‘loop’ handled by the notify watch and ended when I remove the watch?

2) What happens if files are pre-existing when the inotify instance is ‘turned-on’? Initially I just want to monitor for IN_CREATE but this won’t handle pre-existing files.

3) Similar to #2, what happens if a file gets created while I’m in my event processor function? Will pyinotify cache it in its queue and process it when the ‘loop’ starts again, or will I lose this event?

  • 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-27T18:55:48+00:00Added an answer on May 27, 2026 at 6:55 pm
    • is it necessary to have a while( True ) loop

    You’ll need a while-loop, but it can be set up implicitly by calling the notifier.loop method:

        wm = pyinotify.WatchManager()
        mask = pyinotify.IN_CREATE
        notifier = pyinotify.Notifier(wm, MyProcessEvent(path))
        wdd = wm.add_watch(path, mask, rec=True, auto_add=True)
        notifier.loop()
    

    If you wish to set up the while-loop yourself, you might start with this source code from notifier.loop:

        while 1:
            try:
                notifier.process_events()
                # check_events is blocking
                if notifier.check_events():
                    notifier.read_events()
            except KeyboardInterrupt:
                # Stop monitoring if sigint is caught (Control-C).
                break
        notifier.stop()
    

    To remove a watch of a particular file or directory, call wm.rm_watch.

    • What happens if files are pre-existing when the inotify instance is ‘turned-on’?

      No event is generated before wm.add_watch is called.

    • what happens if a file gets created while I’m in my event processor function?

      The events are queued in a buffer of size
      /proc/sys/fs/inotify/max_queued_events. For example, on my system
      that number is

      % cat /proc/sys/fs/inotify/max_queued_events
      16384
      

      If the filesystem generates enough events to fill up the buffer while
      you are processing a prior event, then you get a IN_Q_OVERFLOW
      event.

      See the comment in blucz’s answer.

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

Sidebar

Related Questions

I have some questions about basic CSS that I was unable to understand or
It seems interesting, that nobody asked this before. I have some basic-questions about the
I have some basic questions around understanding fundamentals of Performance testing. I know that
I have some basic questions about abstract classes/methods. I know the basic use of
I am quite new on mvc3 and have some basic and ridiculous questions that
I just have some basic questions about the way shared preferences work with Android:
I have some basic questions about core data (which I am new to) and
I'm working through the Stanford iPhone podcasts and have some basic questions. The first:
Dup of Some Basic PHP Questions Hello, I have a heap of tinyint fields
Hi have some forms that I want to use some basic php validation (regular

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.