import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class MyEventHandler(FileSystemEventHandler): def on_modified(self, event): print("File modified:", event.src_path) observer = Observer() observer.schedule(MyEventHandler(), path='.') observer.start() if observer.isAlive(): print("Observer thread is running!") # Wait for 10 seconds and stop the observer time.sleep(10) observer.stop() observer.join() if not observer.isAlive(): print("Observer thread has stopped.")In this code example, we create a new Observer and start it. Then, we call the isAlive method to check if the observer thread is running. We wait for 10 seconds and then stop and join the observer thread. Afterwards, we check the status of the observer thread with the isAlive method again. The package library used for this code is Watchdog.