Miguel Grinberg - Flask at Scale - PyCon 2016

PyCon 2016 · 55K views · 2016 · 3:05:01

Open on YouTube

Web developmentPython, Ruby & scripting languagesSoftware architecture & designtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about running background or asynchronous tasks in Flask, pointing to the specific segments on threading, Celery and async handlers.

Recommended by 4 people across 4 different months, 2016 to 2023.

What it is

A three-hour PyCon 2016 tutorial by Miguel Grinberg, author of the Flask Mega-Tutorial, on patterns and best practices for taking Flask beyond small apps. It walks through a full example application (Flack) covering Celery background tasks, Socket.IO, async request handling and unit testing.

What people said

Recommends Miguel Grinberg · 2016-07 · Stack Overflow · on “How to unittest Flask websocket server (Flask-SocketIO)”

Some people prefer separate apps for HTTP and WebSocket, but that is not something I would recommend blindly. There are cases in which it makes sense to do so, others that do not, specially if you are using Flask-SocketIO, which gives you a fairly powerful integration. The Flask-SocketIO extension includes a test client, similar in concept to Flask's test client, but meant to be used with socket routes. Have you looked at that? If you want an example application that uses Flask, Celery, Socket.IO and has a nice set of unit tests for everything, have a look at Flack: [LINK] . I gave a tutorial session at PyCon 2016 in which I cover this application in detail: [this video] .

Recommends MrLeeh · 2016-12 · Stack Overflow · on “Background tasks in flask”

If you've got some time have a look at Miguel Grinbergs keynote at FlaskCon ( [this video] ). At 1:25:38 he begins to describe how to handle async requests and turn routes in async request handlers by using an async decorator.

Recommends Jurgen Strydom · 2019-03 · Stack Overflow · on “Making an asynchronous task in Flask”

Threading is another possible solution. Although the Celery based solution is better for applications at scale, if you are not expecting too much traffic on the endpoint in question, threading is a viable alternative. This solution is based on Miguel Grinberg's PyCon 2016 Flask at Scale presentation [this video] , specifically slide 41 [LINK] in his slide deck. His code is also available on github [LINK] for those interested in the original source. From a user perspective the code works as follows: You make a call to the endpoint that performs the long running task. This endpoint returns 202 Accepted with a link to check on the task status. Calls to the status link returns 202 while the taks is s

Recommends Lenntror · 2023-11 · Stack Overflow · on “Search on Products in Flask and Flask-SQLAlchemy”

Yes it is. If you run into issues (unlikely from my point of view), you can make the search request async using background workers. ( [this video] explained here at 1h30min). I would start with elasticsearch and look if you run into performance issues but I do not think this will happen