1

I have a flask app which I was running using command line. however when I checked the processes it shows me two processes are running, shouldn't it be just one?

#!/usr/bin/env bash

# Activate virtual environment
source .venv/bin/activate

export FLASK_APP=migration_status.py
export FLASK_ENV=development
flask run --host=0.0.0.0 --port=5005

If I run above script, and then run check the linux processes. it shows me two instance.

igns      6590   324  1 16:34 pts/2    00:00:00 /home1/igns/git/emsr/.venv/bin/python2.7 /home1/igns/git/emsr/.venv/bin/flask run --host=0.0.0.0 --port=5005
igns      6616  6590  2 16:35 pts/2    00:00:00 /home1/igns/git/emsr/.venv/bin/python2.7 /home1/igns/git/emsr/.venv/bin/flask run --host=0.0.0.0 --port=5005

Am i doing something wrong in starting an app? or it's just how it works?

davidism
  • 121,510
  • 29
  • 395
  • 339
Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137

1 Answers1

3

Flask's Development Server is multithread. Web Dev servers usually use multiple proccesses so they can do two things at the same time.

  1. Listen to http requests and return responses
  2. Watch for code changes and reload dev server on change

If you run it using the flag flask run --no-reload you should see only one process.

Flask 1.0 Change Log

The development server uses threads by default. (#2529)

Development Server

davidism
  • 121,510
  • 29
  • 395
  • 339
gtalarico
  • 4,409
  • 1
  • 20
  • 42