0

Use Klein for the server and want to run it via Gunicorn.

from klein import Klein
app = Klein()

@app.route('/')
def hello(request):
    return "Hello, world!"

resource = app.resource

Working good in twistd -n web --class=twistdPlugin.resource but need add threads, how to do it?

Or how to start this with Gunicorn, now it's return me Application object must be callable.

  • 2
    What are you trying to achieve? In many cases the only reason to use Gunicorn is to workaround the blocking nature single-threaded applications. When using Klein which uses Twisted under the hood, you don't need Gunicorn to handle multiple non-blocking calls. Is using Klein not enough for what you need? – pgpb.padilla Aug 14 '20 at 09:48
  • Looks like missing something, when i'm start Klein app with twistd + nginx(proxy) and got at least one GET request that takes (5-8 seconds) all else request get stuck.. Maybe you say what are wrong. In some GET request app do db connection and select that can take a few seconds, this block all else. So my point was, with Flask and Gunicorn same logic working nice as i can simple add a few threads or one more worker – Максим Дихтярь Aug 14 '20 at 15:20

0 Answers0