diff --git a/config/settings.yml b/config/settings.yml index 1a903ff..fe8e75a 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -8,4 +8,4 @@ webdriver: mongo: uri : 'mongodb://localhost:27017/' dbname: 'tiktok' - enabled: 0 + enabled: 'on' diff --git a/scripts/__pycache__/watcher.cpython-39.pyc b/scripts/__pycache__/watcher.cpython-39.pyc index 76ee429..309aac4 100644 Binary files a/scripts/__pycache__/watcher.cpython-39.pyc and b/scripts/__pycache__/watcher.cpython-39.pyc differ diff --git a/scripts/__pycache__/webdriver.cpython-39.pyc b/scripts/__pycache__/webdriver.cpython-39.pyc index 9710a7b..94d2a3f 100644 Binary files a/scripts/__pycache__/webdriver.cpython-39.pyc and b/scripts/__pycache__/webdriver.cpython-39.pyc differ diff --git a/scripts/watcher.py b/scripts/watcher.py index f2b4977..5623741 100644 --- a/scripts/watcher.py +++ b/scripts/watcher.py @@ -1,9 +1,14 @@ import time +import concurrent.futures +import queue + from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler from messages.utils import unpackMsgBin +q = queue.Queue() + class Watcher: DIRECTORY_TO_WATCH = "" @@ -18,7 +23,8 @@ class Watcher: try: while True: - time.sleep(5) + with concurrent.futures.ThreadPoolExecutor() as executor: + executor.submit(unpackMsgBin, q.get()) except: self.observer.stop() @@ -33,5 +39,5 @@ class Handler(FileSystemEventHandler): return None elif event.event_type == 'created': - unpackMsgBin(event.src_path) + q.put(event.src_path)