Skip to content

Commit 3d52def

Browse files
committed
type annotations
1 parent 1d85aec commit 3d52def

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/bindings/python/rust/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ where
177177
Resp: Data + for<'de> Deserialize<'de>,
178178
{
179179
async fn generate(&self, request: SingleIn<Req>) -> Result<ManyOut<Annotated<Resp>>, Error> {
180-
match self.0 .0.generate_in_parts(request).await {
180+
match self.0.0.generate_in_parts(request).await {
181181
Ok((mut stream, context)) => {
182182
let first_item = match futures::StreamExt::next(&mut stream).await {
183183
Some(item) => item,

lib/bindings/python/rust/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ impl DistributedRuntime {
377377
self.inner.runtime().shutdown();
378378
}
379379

380+
fn child_token(&self) -> CancellationToken {
381+
CancellationToken {
382+
inner: self.inner.runtime().child_token(),
383+
}
384+
}
385+
380386
fn event_loop(&self) -> PyObject {
381387
self.event_loop.clone()
382388
}

lib/bindings/python/src/dynamo/_core.pyi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,30 @@ class DistributedRuntime:
5252
Shutdown the runtime by triggering the cancellation token
5353
"""
5454
...
55+
56+
def child_token(self) -> CancellationToken:
57+
"""
58+
Get a child cancellation token from the runtime
59+
"""
60+
...
61+
62+
class CancellationToken:
63+
"""
64+
A cancellation token for coordinating shutdown across components
65+
"""
66+
67+
def cancel(self) -> None:
68+
"""
69+
Cancel the token
70+
"""
71+
...
72+
73+
async def cancelled(self) -> None:
74+
"""
75+
Wait for the token to be cancelled
76+
"""
77+
...
78+
5579
class EtcdClient:
5680
"""
5781
Etcd is used for discovery in the DistributedRuntime

0 commit comments

Comments
 (0)