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:
uri : 'mongodb://localhost:27017/'
dbname: 'tiktok'
enabled: 0
enabled: 'on'

View File

@ -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)