Watchdog getting events thrice in Python 3 -
i'm creating program in python using watchdog watches set of files , takes actions based on changes. put the exact example site in file:
import sys import time import logging watchdog.observers import observer watchdog.events import loggingeventhandler if __name__ == "__main__": logging.basicconfig(level=logging.info, format='%(asctime)s - %(message)s', datefmt='%y-%m-%d %h:%m:%s') path = sys.argv[1] if len(sys.argv) > 1 else '.' event_handler = loggingeventhandler() observer = observer() observer.schedule(event_handler, path, recursive=true) observer.start() try: while true: time.sleep(1) except keyboardinterrupt: observer.stop() observer.join()
then, noticed odd. have installed watchdog both python 2 , python 3, in same way (using pip2 install watchdog
, pip3 install watchdog
), , @ same time. however, when run program in python 2 , 3 , same modification once each, happens:
$ python2 watch_test.py 2015-09-30 11:18:32 - modified file: ./watch_test.py $ python3 watch_test.py 2015-09-30 11:18:39 - modified file: ./watch_test.py 2015-09-30 11:18:39 - modified file: ./watch_test.py 2015-09-30 11:18:39 - modified file: ./watch_test.py
what i'm wondering cause behavior , how fix it.
this question is not duplicate of:
- python watchdog runs more once; events same
- python watchdog duplicate events; error happens on python 3, not on python 2.
Comments
Post a Comment