Skip to content

Commit

Permalink
fix web access of ioloop
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 13, 2023
1 parent 1ee5bcd commit d1bbf5f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions klongpy/web/sys_fn_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __str__(self):

def eval_sys_fn_create_web_server(klong, x, y, z):
"""
.web(x, y, z) [Start Web server]
Start a web server and return its handle.
Expand Down Expand Up @@ -113,23 +113,23 @@ async def start_server():
site = web.TCPSite(runner, bind, port)
await site.start()

server_task = klong['.ioloop'].create_task(start_server())
server_task = klong['.system']['ioloop'].create_task(start_server())
return WebServerHandle(bind, port, runner, server_task)


def eval_sys_fn_shutdown_web_server(klong, x):
"""
.webc(x) [Stop Web server]
Stop and close the web server referenced by "x".
"""
if isinstance(x, KGCall) and issubclass(type(x.a), KGLambda):
x = x.a.fn
if isinstance(x, WebServerHandle) and x.runner is not None:
print("shutting down web server")
klong['.ioloop'].run_until_complete(x.shutdown())
klong['.system']['ioloop'].run_until_complete(x.shutdown())
return 1
return 0

Expand Down

0 comments on commit d1bbf5f

Please sign in to comment.