Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid QueueFull exception in file_watch source plugin #342

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions extensions/eda/plugins/event_source/file_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,47 +41,55 @@ def __init__(self: "Handler", **kwargs: Any) -> None:
RegexMatchingEventHandler.__init__(self, **kwargs)

def on_created(self: "Handler", event: FileSystemEvent) -> None:
loop.call_soon_threadsafe(
queue.put_nowait,
{
"change": "created",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
asyncio.run_coroutine_threadsafe(
mkanoor marked this conversation as resolved.
Show resolved Hide resolved
queue.put(
{
"change": "created",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
),
loop,
)

def on_deleted(self: "Handler", event: FileSystemEvent) -> None:
loop.call_soon_threadsafe(
queue.put_nowait,
{
"change": "deleted",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
asyncio.run_coroutine_threadsafe(
queue.put(
{
"change": "deleted",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
),
loop,
)

def on_modified(self: "Handler", event: FileSystemEvent) -> None:
loop.call_soon_threadsafe(
queue.put_nowait,
{
"change": "modified",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
asyncio.run_coroutine_threadsafe(
queue.put(
{
"change": "modified",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
),
loop,
)

def on_moved(self: "Handler", event: FileSystemEvent) -> None:
loop.call_soon_threadsafe(
queue.put_nowait,
{
"change": "moved",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
asyncio.run_coroutine_threadsafe(
queue.put(
{
"change": "moved",
"src_path": event.src_path,
"type": event.__class__.__name__,
"root_path": root_path,
},
),
loop,
)

observer = Observer()
Expand Down