Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Watchdog: Why is my subprocess called continuously?
    primarykey
    data
    text
    <p>I'm a novice with Python &amp; I'm trying to automate synchronization with my home server with unison. I discovered watchdog &amp; I'm trying to use it, but whenever I run "touch test.txt", the script continuously launches new unison processes. Since the observer is using classes inherited from Queue, I assumed that it should just block after it pops the first event off the top of the queue. Have I overlooked something here?</p> <p>Code:</p> <pre><code>#!/usr/bin/python import sys import subprocess import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class ChangeHandler(FileSystemEventHandler): def on_any_event(self, event): subprocess.call(["/usr/bin/unison", "-batch", "-silent", "-ui", "text", "default"]) if __name__ == "__main__": observer = Observer() observer.schedule(ChangeHandler(), '/home/philip', True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() </code></pre> <p>Output:</p> <pre><code>props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads props &lt;-?-&gt; props / props &lt;-?-&gt; props Documents props &lt;-?-&gt; props Downloads </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload