Python Watchdog Measure Time Events
<p>I'm trying to implement a module called <a href="https://github.com/gorakhargosh/watchdog" rel="nofollow">Watchdog</a> into a project. I'm looking for a way I can measure time between event calls within Watchdog.</p>

<pre><code>if timebetweenevents == 5 seconds:
    dothething()
</code></pre>

<p>Thank you,</p>

<p>Charles</p>

<hr>

<p>Edit:</p>

<p>I'm using Python 3.5.0</p>

<p>Here's what the code I was working on <a href="http://pastebin.com/GvSWxymb" rel="nofollow">LINK</a>.</p>

<p>I can print out the current time of the event, but what is the best way to hold on to the time from the last event and then measure the time between since the last event?</p>

<p>You can modify your Handler class to have a record of the time of the last call.</p>

<p><strong>init</strong> method just initialises the value to the current time.
You will also need to make the method on_any_event a non static method</p>

<pre><code>class Handler(FileSystemEventHandler):
    event_time=0

    def __init__(self):
        self.event_time=time.time()

    def on_any_event(self, event):
        now=time.time()
        timedelta=now-self.event_time
        self.event_time=now

        print(timedelta)
</code></pre>

python watchdog