From 2db5d92fb258d1360d6b9b394fb1dc9711698715 Mon Sep 17 00:00:00 2001 From: Robert Betts Date: Thu, 28 Sep 2023 10:43:18 +0100 Subject: [PATCH] Bump version to 0.1.7 * improved asyncio shutdown for examples --- examples/client.py | 2 +- examples/server.py | 14 ++++++++++---- examples/server_basic.py | 13 ++++++++++--- pyproject.toml | 2 +- src/nuropb/interface.py | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/examples/client.py b/examples/client.py index 610b7b7..d08ba24 100644 --- a/examples/client.py +++ b/examples/client.py @@ -98,7 +98,7 @@ async def main(): total_sample_count = 0 total_request_time = 0 - batch_size = 500 + batch_size = 5000 number_of_batches = 5 ioloop = asyncio.get_event_loop() diff --git a/examples/server.py b/examples/server.py index 8e63c28..b6c4400 100644 --- a/examples/server.py +++ b/examples/server.py @@ -84,10 +84,13 @@ async def main(): try: logging.info("Service %s ready", service_example._service_name) await asyncio.Event().wait() - except KeyboardInterrupt: logging.info("Shutting down signal received") - - logging.info("Service %s done", service_example._service_name) + await container.stop() + except BaseException as err: + logging.info("Shutting down. %s: %s", type(err).__name__, err) + await container.stop() + finally: + logging.info("Service %s done", service_example._service_name) if __name__ == "__main__": @@ -99,4 +102,7 @@ async def main(): logging.getLogger("pika").setLevel(logging.CRITICAL) logging.getLogger("etcd3").setLevel(logging.WARNING) logging.getLogger("urllib3").setLevel(logging.WARNING) - asyncio.run(main()) + try: + asyncio.run(main()) + except KeyboardInterrupt: + pass diff --git a/examples/server_basic.py b/examples/server_basic.py index f1dc680..ce3a684 100644 --- a/examples/server_basic.py +++ b/examples/server_basic.py @@ -42,12 +42,16 @@ async def main(): transport_settings=transport_settings, ) await mesh_api.connect() - try: logging.info("Service %s ready", service_instance._service_name) await asyncio.Event().wait() - except KeyboardInterrupt: logging.info("Shutting down signal received") + await mesh_api.disconnect() + except BaseException as err: + logging.info("Shutting down. %s: %s", type(err).__name__, err) + await mesh_api.disconnect() + finally: + logging.info("Service %s done", service_instance._service_name) logging.info("Service %s done", service_instance._service_name) @@ -61,4 +65,7 @@ async def main(): logging.getLogger("pika").setLevel(logging.WARNING) logging.getLogger("etcd3").setLevel(logging.WARNING) logging.getLogger("urllib3").setLevel(logging.WARNING) - asyncio.run(main()) + try: + asyncio.run(main()) + except KeyboardInterrupt: + pass diff --git a/pyproject.toml b/pyproject.toml index ae03a8b..d92488a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nuropb" -version = "0.1.6" +version = "0.1.7" description = "NuroPb - A Distributed Event Driven Service Mesh" authors = ["Robert Betts "] readme = "README.md" diff --git a/src/nuropb/interface.py b/src/nuropb/interface.py index 52fef65..ea263f9 100644 --- a/src/nuropb/interface.py +++ b/src/nuropb/interface.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) -NUROPB_VERSION = "0.1.6" +NUROPB_VERSION = "0.1.7" NUROPB_PROTOCOL_VERSION = "0.1.1" NUROPB_PROTOCOL_VERSIONS_SUPPORTED = ("0.1.1",) NUROPB_MESSAGE_TYPES = (