file_manager: cleanup coroutines on close
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
36de982692
commit
0a811b9e44
|
@ -1493,8 +1493,8 @@ class INotifyHandler:
|
||||||
int, Tuple[InotifyNode, str, asyncio.Handle]] = {}
|
int, Tuple[InotifyNode, str, asyncio.Handle]] = {}
|
||||||
self.create_gcode_notifications: Dict[str, Any] = {}
|
self.create_gcode_notifications: Dict[str, Any] = {}
|
||||||
self.initialized: bool = False
|
self.initialized: bool = False
|
||||||
self.pending_gcode_notificatons: List[Coroutine] = []
|
self.pending_gcode_notifications: List[Coroutine] = []
|
||||||
self._gcode_queue_busy: bool = False
|
self._gc_notify_task: Optional[asyncio.Task] = None
|
||||||
|
|
||||||
def add_root_watch(self, root: str, root_path: str) -> None:
|
def add_root_watch(self, root: str, root_path: str) -> None:
|
||||||
# remove all exisiting watches on root
|
# remove all exisiting watches on root
|
||||||
|
@ -1834,16 +1834,17 @@ class INotifyHandler:
|
||||||
pending_node.queue_move_notification(args)
|
pending_node.queue_move_notification(args)
|
||||||
|
|
||||||
def queue_gcode_notificaton(self, coro: Coroutine) -> None:
|
def queue_gcode_notificaton(self, coro: Coroutine) -> None:
|
||||||
self.pending_gcode_notificatons.append(coro)
|
self.pending_gcode_notifications.append(coro)
|
||||||
if not self._gcode_queue_busy:
|
if self._gc_notify_task is None:
|
||||||
self._gcode_queue_busy = True
|
self._gc_notify_task = self.event_loop.create_task(
|
||||||
self.event_loop.create_task(self._process_gcode_notifications())
|
self._process_gcode_notifications()
|
||||||
|
)
|
||||||
|
|
||||||
async def _process_gcode_notifications(self) -> None:
|
async def _process_gcode_notifications(self) -> None:
|
||||||
while self.pending_gcode_notificatons:
|
while self.pending_gcode_notifications:
|
||||||
coro = self.pending_gcode_notificatons.pop(0)
|
coro = self.pending_gcode_notifications.pop(0)
|
||||||
await coro
|
await coro
|
||||||
self._gcode_queue_busy = False
|
self._gc_notify_task = None
|
||||||
|
|
||||||
def notify_filelist_changed(self,
|
def notify_filelist_changed(self,
|
||||||
action: str,
|
action: str,
|
||||||
|
@ -1908,6 +1909,11 @@ class INotifyHandler:
|
||||||
self.server.send_event("file_manager:filelist_changed", result)
|
self.server.send_event("file_manager:filelist_changed", result)
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
|
while self.pending_gcode_notifications:
|
||||||
|
coro = self.pending_gcode_notifications.pop(0)
|
||||||
|
coro.close()
|
||||||
|
if self._gc_notify_task is not None:
|
||||||
|
self._gc_notify_task.cancel()
|
||||||
self.event_loop.remove_reader(self.inotify.fileno())
|
self.event_loop.remove_reader(self.inotify.fileno())
|
||||||
for watch in self.watched_nodes.keys():
|
for watch in self.watched_nodes.keys():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue