Interview Q&A · questions with model answers

Flask Interview Questions

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Why should you release resources in teardown_request rather than after_request in Flask?

    after_request functions are for modifying the response and can be skipped, for example when an earlier after_request function raises or an exception propagates. teardown_request (and…

  2. Why is starting a thread from a Flask view to do background work risky?

    The thread doesn't have the request/app context (proxies fail), work is lost if the worker restarts or is recycled, there are no retries or monitoring, and unbounded threads can exhaust resources.

Was this page helpful?

Report a mistake