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

[16.0][FIX] fastapi: prevent the creation of multiple event loops/threads #485

Conversation

sebalix
Copy link

@sebalix sebalix commented Jan 8, 2025

Attempt to address issue #484

@OCA-git-bot
Copy link
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

@sebalix sebalix force-pushed the 16-fastapi-fix-multiple_event_loop_threads branch from 4f9e664 to 94677cd Compare January 8, 2025 08:41
@@ -18,6 +20,8 @@

_logger = logging.getLogger(__name__)

event_loop = asyncio.new_event_loop()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question here: do we want one event loop to handle multiple databases / endpoints? Or create one dynamically based on the DB(+endpoint)? Is there any benefit to do that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebalix What problem are you trying to solve here? I don't think we can share the same event loop between requests. This is to ensure that the processing of requests made in parallel is isolated. The only problem I can imagine if Odoo runs in multi-thread mode and not multi-process mode is that you end up with zombie threads for event loops that were created for deleted odoo threads.... In this case, we don't currently have a mechanism for managing the lifecycle of event loop threads (this isn't a problem in multi workers mode).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have the whole context of this fastapi module, so from what I see in #486 means we can share the same event loop/thread for different root_path, that was my main question (regarding performance).

Closing this one in favor of #486, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants