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.
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from priority import PriorityTree
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.
import priority
p = priority.PriorityTree()
p.insert_stream(stream_id=1)
p.insert_stream(stream_id=3)
p.insert_stream(stream_id=5, depends_on=1)
p.insert_stream(stream_id=7, weight=32)
p.insert_stream(stream_id=9, depends_on=7, weight=8)
p.insert_stream(stream_id=11, depends_on=7, exclusive=True)
# Simulate sending data by iterating the tree
print("Initial serving order:")
for _ in range(10):
next_stream_id = p.next_stream_to_send()
if next_stream_id is None:
print(" No more active streams.")
break
print(f" Sending data for stream: {next_stream_id}")
# Simulate blocking a stream after it's been served once
if next_stream_id == 7:
p.block(7)
print(" Stream 7 blocked for demonstration.")
# Unblock a stream to see it re-enter the queue
p.unblock(7)
print("\nStream 7 unblocked. Continuing serving order:")
for _ in range(5):
next_stream_id = p.next_stream_to_send()
if next_stream_id is None:
print(" No more active streams.")
break
print(f" Sending data for stream: {next_stream_id}")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.
Agent activity
0 hits · last 30 days
No traffic data recorded yet.