This commit is contained in:
耿伦伦 2021-11-30 22:46:09 +08:00
parent d7511f35f5
commit 467791ee09
4 changed files with 9 additions and 3 deletions

View File

@ -8,4 +8,4 @@ webdriver:
mongo: mongo:
uri : 'mongodb://localhost:27017/' uri : 'mongodb://localhost:27017/'
dbname: 'tiktok' dbname: 'tiktok'
enabled: 0 enabled: 'on'

View File

@ -1,9 +1,14 @@
import time import time
import concurrent.futures
import queue
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
from messages.utils import unpackMsgBin from messages.utils import unpackMsgBin
q = queue.Queue()
class Watcher: class Watcher:
DIRECTORY_TO_WATCH = "" DIRECTORY_TO_WATCH = ""
@ -18,7 +23,8 @@ class Watcher:
try: try:
while True: while True:
time.sleep(5) with concurrent.futures.ThreadPoolExecutor() as executor:
executor.submit(unpackMsgBin, q.get())
except: except:
self.observer.stop() self.observer.stop()
@ -33,5 +39,5 @@ class Handler(FileSystemEventHandler):
return None return None
elif event.event_type == 'created': elif event.event_type == 'created':
unpackMsgBin(event.src_path) q.put(event.src_path)