Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
type annotations
  • Loading branch information
blarson-b10 committed Sep 9, 2025
commit 3d52defa42008c4acd525678b8ea6eda7dd93804
2 changes: 1 addition & 1 deletion lib/bindings/python/rust/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ where
Resp: Data + for<'de> Deserialize<'de>,
{
async fn generate(&self, request: SingleIn<Req>) -> Result<ManyOut<Annotated<Resp>>, Error> {
match self.0 .0.generate_in_parts(request).await {
match self.0.0.generate_in_parts(request).await {
Ok((mut stream, context)) => {
let first_item = match futures::StreamExt::next(&mut stream).await {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should extract the error message check / check if HTTPError (identical to if let Some(py_err) = e.downcast_ref:)

Some(item) => item,
Expand Down
6 changes: 6 additions & 0 deletions lib/bindings/python/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ impl DistributedRuntime {
self.inner.runtime().shutdown();
}

fn child_token(&self) -> CancellationToken {
CancellationToken {
inner: self.inner.runtime().child_token(),
}
}

fn event_loop(&self) -> PyObject {
self.event_loop.clone()
}
Expand Down
24 changes: 24 additions & 0 deletions lib/bindings/python/src/dynamo/_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ class DistributedRuntime:
Shutdown the runtime by triggering the cancellation token
"""
...

def child_token(self) -> CancellationToken:
"""
Get a child cancellation token from the runtime
"""
...

class CancellationToken:
"""
A cancellation token for coordinating shutdown across components
"""

def cancel(self) -> None:
"""
Cancel the token
"""
...

async def cancelled(self) -> None:
"""
Wait for the token to be cancelled
"""
...

class EtcdClient:
"""
Etcd is used for discovery in the DistributedRuntime
Expand Down