Correct locking in thread poll watcher
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import asyncio
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from os import stat_result
|
||||
@@ -190,10 +189,10 @@ def watcher_thread_poll(loop):
|
||||
|
||||
while not quit:
|
||||
rootpath = config.config.path
|
||||
old = state.root
|
||||
new = walk()
|
||||
if old != new:
|
||||
with state.lock:
|
||||
with state.lock:
|
||||
old = state.root
|
||||
if old != new:
|
||||
state.root = new
|
||||
broadcast(format_update(old, new), loop)
|
||||
|
||||
@@ -333,8 +332,9 @@ async def abroadcast(msg):
|
||||
|
||||
async def start(app, loop):
|
||||
config.load_config()
|
||||
use_inotify = False # sys.platform == "linux"
|
||||
app.ctx.watcher = threading.Thread(
|
||||
target=watcher_thread if sys.platform == "linux" else watcher_thread_poll,
|
||||
target=watcher_thread if use_inotify else watcher_thread_poll,
|
||||
args=[loop],
|
||||
)
|
||||
app.ctx.watcher.start()
|
||||
|
||||
Reference in New Issue
Block a user