gorakhargosh / watchdog

Python library and shell utilities to monitor filesystem events.

Home Page:http://packages.python.org/watchdog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does the watchdog have a method for detecting function timeout?

b-niu opened this issue · comments

commented

Dear contributors,

Can I use some method to achieve this function:

from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer

class MyEventHandler(FileSystemEventHandler):
    def __init__(self):
        FileSystemEventHandler.__init__(self)
        ...

    def on_modified(self, event):
        set_a_timeout_of_3_seconds()
        do_something()
        if the_function_ends_in_3_seconds:
           pass
        else:
           break_it()

I have tried the eventlet and signal module, but all of them cannot be used with watchdog together.

Thanks a lot!