From 11b229af964abc1f6b8fcedd85ccfa93304f23a7 Mon Sep 17 00:00:00 2001 From: robnagler <5495179+robnagler@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:47:25 +0000 Subject: [PATCH] Fix #525 add coros argument to http.server_start --- pykern/http.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pykern/http.py b/pykern/http.py index 31b640ce..2ff1f980 100644 --- a/pykern/http.py +++ b/pykern/http.py @@ -41,9 +41,19 @@ _API_NAME_RE = re.compile(rf"^{pykern.quest.API.METHOD_PREFIX}(\w+)") -def server_start(api_classes, attr_classes, http_config): +def server_start(api_classes, attr_classes, http_config, coros=()): + """Start the `_HTTPServer` in asyncio + + Args: + api_classes (Iterable): `pykern.quest.API` subclasses to be dispatched + attr_classes (Iterable): `pykern.quest.Attr` subclasses to create API instance + http_config (PKDict): auth_secret and `pkasyncio.Loop.http_server` arg + coros (Iterable): list of coroutines to be passed to `pkasyncio.Loop.run` + """ l = pykern.pkasyncio.Loop() _HTTPServer(l, api_classes, attr_classes, http_config) + if coros: + l.run(*coros) l.start()