Priority is a pure-Python implementation of the HTTP/2 priority logic, as described in RFC 7540 Section 5.3 (Stream Priority). It allows clients to express preferences for how servers allocate resources across concurrent HTTP/2 requests by managing a priority tree. The library uses a variant of the implementation from the H2O project. The current version, 2.0.0, was released in June 2021, indicating a stable project in maintenance mode, part of the broader python-hyper ecosystem for HTTP/2 related libraries.
pip install priorityVerified import paths — ran on the pinned version, not inferred.
Initialize a `PriorityTree`, insert streams with various dependencies and weights, then iterate using `next_stream_to_send()` to determine the optimal sending order. Demonstrates how to block and unblock streams to change their active status within the tree.
Be aware of server-side HTTP/2 implementations and network configurations. Do not assume strict adherence to client-side priority signals. Verify actual behavior through testing with tools like HTTP/2 prioritization test pages.
Ensure `block()`, `unblock()`, and `reprioritize()` methods are called correctly to reflect the actual state and desired priority of HTTP/2 streams in response to application logic and network conditions.
The `PriorityTree` class is typically accessed after importing the `priority` package. The correct way to use it is by instantiating it after `import priority` or by using `from priority.tree import PriorityTree` if specifically importing the class.
Ensure that each stream inserted into the `PriorityTree` has a unique `stream_id`. If a stream's priority needs to be updated, use the `reprioritize()` method instead of `insert_stream()`.
Verify that the `stream_id` passed to the method corresponds to an existing stream in the `PriorityTree`. Ensure the stream has been previously inserted and not yet removed.
This often points to an issue with managing stream lifecycle. Ensure streams are correctly removed using `remove_stream()` when they are no longer needed. If a higher limit is genuinely required, the `maximum_streams` parameter can be set during `PriorityTree` initialization, e.g., `p = priority.PriorityTree(maximum_streams=2000)` (though this should be done cautiously).
Consult the `priority` library's documentation for the correct method names and their usage. For example, if intending to block a stream, use `p.block(stream_id)` instead of a misspelled or non-existent method.
No dependency data recorded yet.