[PR #16734] UPD: Enable ExceptionGroup catching in tasks.py & handler in main.py #11018

Open
opened 2025-11-11 19:19:48 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/16734
Author: @rgaricano
Created: 8/19/2025
Status: 🔄 Open

Base: devHead: dev-Catch_ExceptionGroup


📝 Commits (6)

  • 631d444 UPD: ExceptionGroup catch in tasks.py
  • aa5f533 UPD: ExceptionGroup catch - update main.py
  • 8a423c0 Fix Format Code Warmings
  • 5fdb68b Fix Code Format Warmings
  • bd883c8 Fix Code Format Warming
  • beb7b0b re-add "from the global tasks dictionary" comment that was removed

📊 Changes

2 files changed (+69 additions, -12 deletions)

View changed files

📝 backend/open_webui/main.py (+14 -1)
📝 backend/open_webui/tasks.py (+55 -11)

📄 Description

Implementation of ExceptionGroup catching as commented in https://github.com/open-webui/open-webui/discussions/16732#discussioncomment-14155085

In some scenarios with concurrent tasks, for example when uploading files (e.g. issue https://github.com/open-webui/open-webui/discussions/16964), multiple tasks may fail simultaneously, resulting in "ExceptionGroup: Unhandled errors in a TaskGroup." errors.

To solve this it's necessary manage this faults as ExceptionGroup, and that is what this implementation does.

As also arised errors ERROR | open_webui.tasks:redis_task_command_listener:55 - Error handling distributed task command: Expecting value: line 1 column 1 (char 0) due to a Redis pub/sub message contains empty or invalid JSON data, a check for this situation is implemented.

This errors are "dificult" to reproduce/verify, for this reason I also tested with a python script that generate failed concurrent tasks: test_exceptiongroup.py (place&execute in backend dir)

I tested in diferent ways, uploading multiples files, running the script some times between other tasks,...
Now only appear a | WARNING | open_webui.tasks:redis_task_command_listener:46 - Invalid JSON in Redis message: invalid_json... Error: Expecting value: line 1 column 1 (char 0)

Changes:

in tasks.py
Added caching for multiple concurrent exceptions.
Modified:

  • async def redis_task_command_listener
  • async def cleanup_task

in main.py
Added caching for concurrent exceptions handler.
Modified:

  • redis_task_command_listener

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Regards
Ricardo


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/16734 **Author:** [@rgaricano](https://github.com/rgaricano) **Created:** 8/19/2025 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `dev-Catch_ExceptionGroup` --- ### 📝 Commits (6) - [`631d444`](https://github.com/open-webui/open-webui/commit/631d4441aa620473aa72e589b1ebe9eeeca757a3) UPD: ExceptionGroup catch in tasks.py - [`aa5f533`](https://github.com/open-webui/open-webui/commit/aa5f5330d3abd1a3780cd7e883e75c80cf3273ef) UPD: ExceptionGroup catch - update main.py - [`8a423c0`](https://github.com/open-webui/open-webui/commit/8a423c0a98842997d1917e8f3c5ee52a494885ba) Fix Format Code Warmings - [`5fdb68b`](https://github.com/open-webui/open-webui/commit/5fdb68bd2730e71a9c8c8273db37a1fd7096ad61) Fix Code Format Warmings - [`bd883c8`](https://github.com/open-webui/open-webui/commit/bd883c802601a6ded04742772a1be54de92eee78) Fix Code Format Warming - [`beb7b0b`](https://github.com/open-webui/open-webui/commit/beb7b0bf3d7a80a609a39973509c7663bcb61964) re-add "from the global `tasks` dictionary" comment that was removed ### 📊 Changes **2 files changed** (+69 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+14 -1) 📝 `backend/open_webui/tasks.py` (+55 -11) </details> ### 📄 Description Implementation of ExceptionGroup catching as commented in https://github.com/open-webui/open-webui/discussions/16732#discussioncomment-14155085 In some scenarios with concurrent tasks, for example when uploading files (e.g. issue https://github.com/open-webui/open-webui/discussions/16964), multiple tasks may fail simultaneously, resulting in "ExceptionGroup: Unhandled errors in a TaskGroup." errors. To solve this it's necessary manage this faults as ExceptionGroup, and that is what this implementation does. As also arised errors `ERROR | open_webui.tasks:redis_task_command_listener:55 - Error handling distributed task command: Expecting value: line 1 column 1 (char 0)` due to a Redis pub/sub message contains empty or invalid JSON data, a check for this situation is implemented. This errors are "dificult" to reproduce/verify, for this reason I also tested with a python script that generate failed concurrent tasks: [test_exceptiongroup.py](https://github.com/user-attachments/files/21860833/test_exceptiongroup.py) (place&execute in backend dir) I tested in diferent ways, uploading multiples files, running the script some times between other tasks,... Now only appear a ` | WARNING | open_webui.tasks:redis_task_command_listener:46 - Invalid JSON in Redis message: invalid_json... Error: Expecting value: line 1 column 1 (char 0)` Changes: in tasks.py Added caching for multiple concurrent exceptions. Modified: - async def redis_task_command_listener - async def cleanup_task in main.py Added caching for concurrent exceptions handler. Modified: - redis_task_command_listener ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. Regards Ricardo --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 19:19:48 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#11018