Home > Software design >  What to use instead of threads with quart
What to use instead of threads with quart

Time:02-12

I want to make a discord bot dashboard with replit and I want to use quart, there is my keep_alive function:

def run():
  app.run(host="0.0.0.0", port=8080)

def keep_alive():
  server = Thread(target=run)
  server.start()

There is just one little problem, I don't know what to use instead of thread because Quart is an asynchronous library.

CodePudding user response:

Quart run takes the following arguments. if you want to reload on file changes then it does the job by default.

def run(
    self,
    host: Optional[str] = None,
    port: Optional[int] = None,
    debug: Optional[bool] = None,
    use_reloader: bool = True,
    loop: Optional[asyncio.AbstractEventLoop] = None,
    ca_certs: Optional[str] = None,
    certfile: Optional[str] = None,
    keyfile: Optional[str] = None,
    **kwargs: Any,
) -> None:

CodePudding user response:

With hypercorn.asyncio.serve, you can turn an ASGI server (i.e., Quart here) to an asnycio.Future object, which allows you to push the Future to event loop (by asyncio.create_task or something else) and run it at background.

  • Related