Skip to content

Running multiple managed_workers separated from main litestar instance is skipping the last one #43

@PanagiotisS

Description

@PanagiotisS

Hi,

I updated today to the latest version of litestar-saq and SAQ and I noticed an issue in the code here https://github.com/cofin/litestar-saq/blame/main/litestar_saq/cli.py#L85-L100.
Currently, when running SAQ as a separate instance form main Litestar (i.e. litestar workers run), when looping over managed_workers skips the last Queue/worker.

If I understand correctly, the loop is triggering one less worker since the first worker is manually triggered after the loop. Therefore, the loop should be written as follows:

if len(managed_workers) > 1:
    for j in range(len(managed_workers) - 1):
        p = multiprocessing.Process(target=run_saq_worker, args=(managed_workers[j + 1], app.logging_config))
        p.start()
        _processes.append(p)

Since managed_workers[0] is manually triggered later:

run_saq_worker(
    worker=managed_workers[0],
    logging_config=cast("BaseLoggingConfig", app.logging_config),
)

Best wishes,
Panagiotis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions