Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Phil Jones
    @pgjones
    It is the usage of the shutdown_trigger that I think is the issue for you. This is set by default to be a signal (Ctrl-C), but as noted this is only works if Quart is run on the main thread. Instead you can specify your own shutdown_trigger and use the run_task method. The shutdown_trigger should be an awaitable that is done when you want the app to shutdown.
    sferdi0
    @sferdi0
    I've noticed that CTRL-C'ing hypercorn takes a second or two to quit, possibly related to some cleanup process... Can I somehow replace this with a SIGKILL, in favor of quickly being able to start/stop hypercorn?
    (For development purposes)
    sferdi0
    @sferdi0
    await asyncio.sleep(config.graceful_timeout)
    I FOUND YOU
    sferdi0
    @sferdi0
    Any side-effects with setting this to 0?
    Phil Jones
    @pgjones
    None
    This is on my todo list to improve, I need to somehow early exit if the relevant tasks have completed.
    McSinyx
    @McSinyx:matrix.org
    [m]
    in case hypercorn runs on trio, does nursery/cancel scope makes it any easier?
    Phil Jones
    @pgjones
    Hopefully, although I haven't got it right so far
    Vito De Tullio
    @ZeeD

    Hi.
    I've just updated quart, quart-trio and hypercorn and I'm having this mypy error:

    : error: Argument 1 to "serve" has incompatible type "QuartTrio"; expected "Union[Type[ASGI2Protocol], Callable[[Union[HTTPScope, WebsocketScope, LifespanScope], Callable[[], Awaitable[Union[HTTPRequestEvent, HTTPDisconnectEvent, WebsocketConnectEvent, WebsocketReceiveEvent, WebsocketDisconnectEvent, LifespanStartupEvent, LifespanShutdownEvent]]], Callable[[Union[HTTPResponseStartEvent, HTTPResponseBodyEvent, HTTPServerPushEvent, HTTPDisconnectEvent, WebsocketAcceptEvent, WebsocketSendEvent, WebsocketResponseStartEvent, WebsocketResponseBodyEvent, WebsocketCloseEvent, LifespanStartupCompleteEvent, LifespanStartupFailedEvent, LifespanShutdownCompleteEvent, LifespanShutdownFailedEvent]], Awaitable[None]]], Awaitable[None]]]"
    moves\web\__init__.py:85: error: Argument 1 to "serve" has incompatible type "QuartTrio"; expected "Union[Type[ASGI2Protocol], Callable[[Union[HTTPScope, WebsocketScope, LifespanScope], Callable[[], Awaitable[Union[HTTPRequestEvent, HTTPDisconnectEvent, WebsocketConnectEvent, WebsocketReceiveEvent, WebsocketDisconnectEvent, LifespanStartupEvent, LifespanShutdownEvent]]], Callable[[Union[HTTPResponseStartEvent, HTTPResponseBodyEvent, HTTPServerPushEvent, HTTPDisconnectEvent, WebsocketAcceptEvent, WebsocketSendEvent, WebsocketResponseStartEvent, WebsocketResponseBodyEvent, WebsocketCloseEvent, LifespanStartupCompleteEvent, LifespanStartupFailedEvent, LifespanShutdownCompleteEvent, LifespanShutdownFailedEvent]], Awaitable[None]]], Awaitable[None]]]"

    the "incriminated" line is await hypercorn.trio.serve(app, config), where I have

    app = cast(quart_trio.QuartTrio,
                   quart_cors.cors(quart_trio.QuartTrio(__name__),
                                   allow_origin='*',
                                   allow_methods=['POST'],
                                   allow_headers=['content-type']))
    Phil Jones
    @pgjones
    Best to ignore this at the moment, will be fixed in an upcoming release
    1 reply
    TheHolyRoger
    @TheHolyRoger

    It is the usage of the shutdown_trigger that I think is the issue for you. This is set by default to be a signal (Ctrl-C), but as noted this is only works if Quart is run on the main thread. Instead you can specify your own shutdown_trigger and use the run_task method. The shutdown_trigger should be an awaitable that is done when you want the app to shutdown.

    Thanks!

    paulinechane
    @PaulineChane

    It is the usage of the shutdown_trigger that I think is the issue for you. This is set by default to be a signal (Ctrl-C), but as noted this is only works if Quart is run on the main thread. Instead you can specify your own shutdown_trigger and use the run_task method. The shutdown_trigger should be an awaitable that is done when you want the app to shutdown.

    Thanks!

    hello! apologies for poorly phrased questions in advance, i am very new to python frameworks and asyncio!

    i am still having a hard time to get this to work -- trying to run a quart app to be used on a website along with bot that runs 24/7 on discord. my understanding is that this run_task() method would be run for the quart app?

    Baran Yildirim
    @baranyildirim
    Is it possible to make Quart work with React via templates? I would like to have a quart application where I use React components, but I do not want a single page application. I also don't want to run node and quart simultaneously.
    Phil Jones
    @pgjones
    Yes, you can just embed React as you need into the templates (via a script tag).
    I typically build a SPA and serve that with Quart
    Ernesto Ruge
    @the-infinity
    I usually use React + Quart or Fask partly jinja2-rendered, partly React-rendered. It works really fine (but Quart / Flask has not much to do with the React part, it just feeds it via API).
    It even works as a single page application including deeplinks and React Router if you set your endpoints in a correct way
    Phil Jones
    @pgjones
    @PaulineChane I'll try and write something up for this soon - short of time.
    Yes though, the run_task method would run the quart app.
    TheHolyRoger
    @TheHolyRoger
    hey @pgjones do you have plans to add "call_on_close" similar to flask to quart?
    Currently I'm using middleware around the asgi app, but it would be nice to have access to request variables within my called functions
    right now i'm manually parsing scope['query_string'] and the headers etc again myself
    Phil Jones
    @pgjones
    Could you spawn a background task for this?
    Do you need to guarantee the task doesn't start till the response has completed?
    TheHolyRoger
    @TheHolyRoger
    yeah because I don't want the response to remain open until the tasks have completed
    it's working as I want it to with middleware at the moment, I just thought it would be nice to have that flask functionality
    i was reading the quart source and wrapping the asgi app seems to be the only "hook" to execute functions after the request has closed
    Phil Jones
    @pgjones
    It is the only guaranteed way.
    Please could you open an issue for this - although I'll likely only add if Flask also adopts it, or it is clearly an async only feature
    TheHolyRoger
    @TheHolyRoger
    since flask uses Werkzeug request/response objects
    but thanks, will stick an issue on github later
    McSinyx
    @McSinyx:matrix.org
    [m]
    hi, why aren't templates observed for reloading by hypercorn?
    Phil Jones
    @pgjones
    Only knows about python files - however Quart in debug mode should observe and reload.
    See this
    McSinyx
    @McSinyx:matrix.org
    [m]
    thanks!
    András Mózes
    @mozesa
    Hello! @pgjones I created an pgjones/quart#118. Should I recreate it on GitLab? Thanks your help in advance.
    KAMAH_DANIEL_SOMTOCHUKWU
    @KDS-LIMITLESS
    Question: How do i process incoming request data in quart? in flask i could use request.get_json()....Is there any async library i could use for this?
    Phil Jones
    @pgjones
    await request.get_json()
    hypescript
    @hypescript
    Hello, I'm trying to run my Quart application with Flask_SQLAlchemy (and thus with flask_patch) inside a Docker container with uvicorn as ASGI server and I'm getting the RuntimeError: Flask Patching only works with the default event loop policy.
    In hindsight, I should've probably started with hypercorn-based Docker, but I couldn't find anything readily available at the time.
    Can you please either advise on how to make it work with uvicorn or recommend a hypercorn-based Docker image that can run quart?
    Phil Jones
    @pgjones
    You will need to disable uvloop with Uvicorn for this to work, --loop asyncio
    András Mózes
    @mozesa
    Hello! Is it possible to extract the different IP addresses of different adapters? I mean when I set hypercorn to serve my site on 0.0.0.0 it means that on localhost it will 127.0.0.1 on wireless it will 10.42.1.12 and etc. So is it possible to know all? Thanks in advance!
    1 reply
    Phil Jones
    @pgjones
    I've released Quart-Schema, 0.6.0. The headline feature is easier automated testing, as I explain in this article, https://pgjones.dev/blog/automatic-api-testing-2021/
    Phil Jones
    @pgjones
    ... and now Quart-Schema 0.7.0 which allows the JSON to be camelCased with the dataclass/models snake_cased (conversion is taken care of by Quart-Schema)
    luna
    @lun-4
    On quart-schema, is it possible to get the pydantic ValidationError that raised the RequestSchemaValidationError? On my API, I'm thinking of showing which fields did the API user fail to provide or provided incorrectly on a 400, but the given RequestSchemaValidationError does not have any other context
    Phil Jones
    @pgjones
    That is a good idea, could you open an issue?
    luna
    @lun-4
    Got it!
    Dario
    @91DarioDev
    Hello, congratulations for this good project. I had some doubts despite I read quart documentation several times. request isn’t passed to the handler but accessed globally. I had