Skip to content

capttwinky/twisted_dirwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twisted_dirwatch

Twisted's inotify watches for changes in a directory, reactor handles response in a different thread or process.

Contents

README.md: this file .gitignore: guess /src cmdline.py: a simple test script that simulates random processing latency dir_watch.py: the main file for this module tw_simple_proc.py: simple implementation of twisted's process protocol & interface to threadding

To Use

  1. import the module

    import dir_watch

  2. create a watcher for a directory

    my_notify = Dir_Watcher("/tmp/filewatch")

  3. register one or more callback functions

    declare a function that takes a twisted FilePath

    set a refrence to that function in the watcher's callbacks dictionary

    where the key == string representation of the event needing response

    use tw_simple_proc for parallel processing of events

    can also use Queue.Queue, etc.

    def callbackfn(event, filepath): print filepath

    my_notify.callbacks['create'] = callbackfn

  4. turn on the listeners for the scripted events

    my_notify.events = ['create']

  5. run your reactor

    reactor.run()

  6. enjoy with family and friends.

About

Twisted's inotify watches for changes in a directory, reactor handles response in a different thread or process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages