Threads for pgjones

  1. 1

    See also FastAPI, which seems to be gaining a lot of traction and is pretty pleasant to use.

    Is there a production ready Flask + Pydantic + APISpec library doing the rounds? I’m a bit wary of by async by default, at least for the time being.

    1. 1

      I’ve just been introduced to instant_api which may be similar enough to the Flask + Pydantic + APISpec library you are looking for.

      1. 1

        I don’t understand your wariness; FastAPI is async by default being an ASGI framework built on Starlette. If it is the route handlers, Quart also allows for sync route handlers. Quart runs the sync route handlers on a thread executor - as I think FastAPI/Starlette does.

        I’m not aware of a Flask extension that works with Pydantic - although you can just strip out the async and await keywords from Quart-Schema and it will work with Flask (Quart is a re-implementation of Flask’s API using async/await).

      1. 3

        I think the article is incorrect claiming Flask does not support support multi-threading or workers. As Flask is a WSGI framework it is required to let the WSGI server setup multi-threading or workers (gevent/eventlet) which it does. In addition it supports both, as can be seen when looking into the Werkzeug-local code used for the maligned Flask-globals.

        I’ll also add that Flask is exploring async support and that Quart exists as the Flask API implemented with async-await.

        1. 2

          Have/are any of you used/using async-await with Flask, or Quart?

          (I’m the Quart author)

          1. 1

            Not yet, but it certainly is on my list.

            As someone without a formal computer science background, async programming has taken me a little bit of time to wrap my head around. I’ve definitely looked at Quart though and gotten a hello world running, just haven’t spend any meaningful time with it yet.

            2020 has a long list of goals and having a meaningful grasp of asyncio is on that list :)

          1. 2

            Why does a blog need React?

            1. 2

              Speaking of that: @pgjones might want to look into fixing the navigation. This article works, but the links along the top result in a mash of text on top of other text on MobileSafari: https://imgur.com/a/JV3GQRX

              At least scrolling in the article isn’t broken and the back button works (for me), both of which are common complaints about React apps used for more traditional websites.

              1. 1

                Thanks, I’m not sure why that happens but I’ll try and find out.

              2. 1

                It doesn’t, it is written in React so I can continue to develop my React skills on a hobby project. You can see the source here. The raw blog markdown is available here if you want it.

              1. 2

                Neat! Any idea what’s happening for HTTP/3 & QUIC?

                1. 2

                  The RFC describes how WebSocket frames are to be encapsulated in HTTP/2 frames, but does not specify how HTTP/2 frames are represented or transmitted. So I assume any HTTP/2 implementation support WebSockets will continue to support WebSockets when adding HTTP/3 or QUIC support. I would wager that most major HTTP/3 implementations will support both WebSockets and QUIC.

                  1. 1

                    Sorry, I’ve no extra insight.

                  1. 3

                    I write mostly about using asyncio to build web frameworks and servers, specifically Quart and Hypercorn.

                    https://medium.com/@pgjones/