Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #525 add coros argument to http.server_start #526

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
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
12 changes: 11 additions & 1 deletion pykern/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down