Classes
StreamPriority
2
▼
Parsed priority for a single HTTP/2 stream.
StreamPriority
2
▼
Parsed priority for a single HTTP/2 stream.
Attributes
| Name | Type | Description |
|---|---|---|
urgency |
int
|
0 (highest) to 7 (lowest). Default: 3. |
incremental |
bool
|
If True, response can be interleaved with others. |
PriorityScheduler
8
▼
Priority-based scheduler for HTTP/2 stream writes.
Maintains a per-stream priority and provides or…
PriorityScheduler
8
▼
Priority-based scheduler for HTTP/2 stream writes.
Maintains a per-stream priority and provides ordering for which stream should get bandwidth next. Higher urgency (lower number) streams are served first. Among same-urgency streams, incremental streams can interleave while non-incremental streams are sequential.
All operations are O(log n) via a min-heap. Thread-safe: a lock protects all mutable state for correctness under free-threading.
Methods
has_pending
0
bool
▼
True if any streams are waiting to send.
property
has_pending
0
bool
▼
def has_pending(self) -> bool
Returns
bool
stream_count
0
int
▼
Number of tracked streams.
property
stream_count
0
int
▼
def stream_count(self) -> int
Returns
int
set_priority
2
▼
Set or update the priority for a stream.
set_priority
2
▼
def set_priority(self, stream_id: int, priority: StreamPriority) -> None
Parameters
| Name | Type | Description |
|---|---|---|
stream_id |
— |
The HTTP/2 stream identifier. |
priority |
— |
The parsed priority for this stream. |
get_priority
1
StreamPriority
▼
Get the priority for a stream (default: urgency=3, not incremental).
get_priority
1
StreamPriority
▼
def get_priority(self, stream_id: int) -> StreamPriority
Parameters
| Name | Type | Description |
|---|---|---|
stream_id |
— |
Returns
StreamPriority
schedule
1
▼
Mark a stream as ready to send data.
schedule
1
▼
def schedule(self, stream_id: int) -> None
Parameters
| Name | Type | Description |
|---|---|---|
stream_id |
— |
The stream that has data to write. |
next_stream
0
int | None
▼
Get the next stream that should write data.
next_stream
0
int | None
▼
def next_stream(self) -> int | None
Returns
int | None
Stream ID with highest priority (lowest urgency), or None
if no streams are pending.
remove_stream
1
▼
Remove a stream from the scheduler.
remove_stream
1
▼
def remove_stream(self, stream_id: int) -> None
Parameters
| Name | Type | Description |
|---|---|---|
stream_id |
— |
The stream to remove. |
Internal Methods 1 ▼
__init__
0
▼
__init__
0
▼
def __init__(self) -> None
Functions
parse_priority
1
StreamPriority
▼
Parse an RFC 9218 Priority header value.
parse_priority
1
StreamPriority
▼
def parse_priority(value: bytes | str) -> StreamPriority
Parameters
| Name | Type | Description |
|---|---|---|
value |
bytes | str |
The Priority header value (e.g., |
Returns
StreamPriority