mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 07:02:37 +08:00
* ⚡️ Speed up method `JobQueueService.create_queue` by 630% in PR #5940 (`refactor-build-flow`) Certainly! To optimize the provided `JobQueueService` class to run faster, we should ensure the code efficiency in creating event managers and handling queues. We can speed up the process by making the following changes. 1. Remove redundant logger calls if they don't provide essential debugging or monitoring information. 2. Inline `create_default_event_manager` function to avoid redundant function calls while ensuring that the `EventManager` setup remains efficient. 3. Ensure faster dictionary access and error message handling. Here is the rewritten and optimized code. In this optimization. 1. The `create_queue` method was streamlined to reduce redundancy checks and fewer logger messages. 2. The `create_default_event_manager` function is integrated directly as `_create_default_event_manager` private method within the class. 3. Utilized list iteration instead of multiple function calls to register events efficiently in the `EventManager`. These changes aim to maintain functionality while improving performance where possible, particularly in the setup process. * fix: improve error messages in JobQueueService for better clarity * [autofix.ci] apply automated fixes * refactor: Relax event type constraint in EventManager Change event type from a strict literal to a more flexible string type, allowing for greater extensibility in event registration * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes * fix: update send_event method to use str for event_type * fix: change event_type parameter to str and handle invalid types in create_event_by_type * fix: Add noqa comment to suppress linting warning for access_host assignment --------- Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>