ritratt
ritratt

Reputation: 1858

gunicorn server hangs when calling itself

I have a Django REST Framework service that runs on a gunicorn server. Here is what the config looks like:

exec gunicorn \
        --pid /web/gunicorn.pid \
        --workers 4 \
        --threads 8 \
        --worker-class gthread \
        --name my-api \
        --chdir /src/api \
        --bind unix:/web/.sock \
        --timeout 300 \
        --limit-request-line 8190 \
        wsgi:application

I have two views:

def view1(request):
  # Call DB etc.

def view2(request):
  my_api_python_client.call_view1(request)  # Hangs!

This results in the requesting hanging indefinitely. I understand that calling one view from another sounds counter-intuitive but it has to be done to leverage caching, async calls etc.

What is curious is that when I run it as a Pycharm server, it works perfectly well!

Question - Why does my request never get processed? How do I fix it?

Upvotes: 1

Views: 1080

Answers (1)

Yuber Nguyen
Yuber Nguyen

Reputation: 11

You should check your configuration of gunicorn worker, it have to be more than 1 to run a thread that will call itself.

For example: (2n+1 as number of processors)

gunicorn app.wsgi:application --workers=4 --bind 0.0.0.0:8000 

Upvotes: 1

Related Questions