Skip to content

[feature request]Support priorities #455

@kshpytsya

Description

@kshpytsya

Over time, my use case for aiojobs got extended to require support for job priorities, i.e. it should be possible to pass a priority value to Scheduler.spawn method, and if not executed immediately, job should be placed into the pending queue at a position according to the specified priority.

If possible performance impact of replacing deque (which is the structure behind asyncio.Queue used by aiojobs) with heapq+list (used by asyncio.PriorityQueue) could be neglected, then I would suppose that implementing this feature request would be as simple as adding an optional priority parameter to spawn method and switching to PriorityQueue. Otherwise, a slightly more involved implementation would involve creating a Scheduler subclass tentatively named PriorityScheduler.

My use case doesn't require support for priorities in aiojobs.aiohttp but I suspect that it may be desirable to implement that as well for the sake of completeness.

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