diff --git a/tfw/components/pipe_io/pipe_connector/pipe_connector.py b/tfw/components/pipe_io/pipe_connector/pipe_connector.py index 04157ff..0c33a59 100644 --- a/tfw/components/pipe_io/pipe_connector/pipe_connector.py +++ b/tfw/components/pipe_io/pipe_connector/pipe_connector.py @@ -28,13 +28,12 @@ class PipeConnector: def _on_any_event(self, event): path = event.src_path - if self._is_pipe(path): - if isinstance(event, InotifyFileCreatedEvent): - self._on_create_pipe(path) - LOG.debug('Connected to new pipe "%s"', path) - elif isinstance(event, InotifyFileDeletedEvent): - self._on_delete_pipe(path) - LOG.debug('Disconnected from deleted pipe "%s"', path) + if self._is_pipe(path) and isinstance(event, InotifyFileCreatedEvent): + self._on_create_pipe(path) + LOG.debug('Connected to new pipe "%s"', path) + elif isinstance(event, InotifyFileDeletedEvent): + self._on_delete_pipe(path) + LOG.debug('Disconnected from deleted pipe "%s"', path) @staticmethod def _is_pipe(path): diff --git a/tfw/components/pipe_io/pipe_connector/test_proxy_pipe_connector.py b/tfw/components/pipe_io/pipe_connector/test_proxy_pipe_connector.py index 0764d0c..65175f7 100644 --- a/tfw/components/pipe_io/pipe_connector/test_proxy_pipe_connector.py +++ b/tfw/components/pipe_io/pipe_connector/test_proxy_pipe_connector.py @@ -3,7 +3,7 @@ from enum import Enum from dataclasses import dataclass from json import dumps from secrets import token_urlsafe -from os import urandom, mkfifo, mkdir +from os import urandom, mkfifo, mkdir, remove from os.path import join from pathlib import Path from tempfile import TemporaryDirectory @@ -117,6 +117,7 @@ def test_pipe_creation_deletion(mock_context): path = mock_context.emit_pipe_creation_event(action, mkfifo) assert events[-1] == path assert path in pipes.keys() + remove(path) mock_context.pipes.observer.on_any_event(InotifyFileDeletedEvent(path)) assert path not in pipes.keys()