From 8cc9289129ee91bb96b2059edc68d253281d23f8 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 26 Mar 2024 13:24:48 +1000 Subject: [PATCH 1/2] Move batch helper to base class, so it can be used with remote endpoints --- src/dispatch/fastapi.py | 5 ----- src/dispatch/function.py | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dispatch/fastapi.py b/src/dispatch/fastapi.py index 0cb98384..239c3b36 100644 --- a/src/dispatch/fastapi.py +++ b/src/dispatch/fastapi.py @@ -120,11 +120,6 @@ def __init__( function_service = _new_app(self, verification_key) app.mount("/dispatch.sdk.v1.FunctionService", function_service) - def batch(self) -> Batch: - """Returns a Batch instance that can be used to build - a set of calls to dispatch.""" - return self.client.batch() - def parse_verification_key( verification_key: Ed25519PublicKey | str | bytes | None, diff --git a/src/dispatch/function.py b/src/dispatch/function.py index db14868a..97f18176 100644 --- a/src/dispatch/function.py +++ b/src/dispatch/function.py @@ -250,6 +250,11 @@ def set_client(self, client: Client): for fn in self.functions.values(): fn._client = client + def batch(self) -> Batch: + """Returns a Batch instance that can be used to build + a set of calls to dispatch.""" + return self.client.batch() + class Client: """Client for the Dispatch API.""" From d183f512263686f5782f84d93f22c05bf27c2cdb Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 26 Mar 2024 13:26:50 +1000 Subject: [PATCH 2/2] Don't print stack trace on KeyboardInterrupt --- src/dispatch/test/__main__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dispatch/test/__main__.py b/src/dispatch/test/__main__.py index c0e45439..30eb1b75 100644 --- a/src/dispatch/test/__main__.py +++ b/src/dispatch/test/__main__.py @@ -85,7 +85,11 @@ def main(): print(f' export DISPATCH_VERIFICATION_KEY="{verification_key}"') print() - server.wait() + try: + server.wait() + except KeyboardInterrupt: + print("closing down server after interrupt") + pass if __name__ == "__main__":