D
D
Dnomin2019-01-12 19:50:32
Python
Dnomin, 2019-01-12 19:50:32

Flask + gunicorn multithreading not working?

function body:

@app.route('/allusers')
def all():
  buff = []

  for u in User.query.all():
    buff.append([u.username, u.email, u.password])
  print("before")
  time.sleep(10)
  print("after")
  return str(buff)

called:
gunicorn --bind 0.0.0.0:6789 main_app:app -w 3 --threads 12

But when you try to load two pages at the same time,
before
after
before
after is printed
and the second page is loaded after 20 seconds, but I would like 10 and
before
before
after
after

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question