Django: BlockingIOError: [Errno 11] запись не может быть завершена без блокировки - PullRequest
0 голосов
/ 11 апреля 2020

У меня есть следующее представление в DJango:

def index(request):
    try:
        if request.GET['format'] is None: # The variable
            print('It is None')
    except:
        print ("This variable is not defined")
        format_hare = 'XYZ'
        pass
    else:
        print ("It is defined and has a value")
        format_hare = request.GET['format']


    url_get= request.GET['url']
    print(url_get)
    print(format_hare)

    subprocess.Popen(['/usr/bin/zsh','/home/test.sh', url_get, format_hare])

    html = "<html><body>"+url_get+"</body></html>"
    return HttpResponse(html)

Я иногда получаю следующую ошибку. Не всегда.

Traceback (most recent call last):
  File "/home/web_dev/django_download/.venv/lib/python3.7/site-packages/django/utils/datastructures.py", line 78, in __getitem__
    list_ = super().__getitem__(key)
KeyError: 'format'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/web_dev/django_download/download/download/views.py", line 7, in index
    if request.GET['format'] is None: # The variable
  File "/home/web_dev/django_download/.venv/lib/python3.7/site-packages/django/utils/datastructures.py", line 80, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'format'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/web_dev/django_download/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/web_dev/django_download/.venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/web_dev/django_download/.venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/web_dev/django_download/download/download/views.py", line 10, in index
    print ("This variable is not defined")
BlockingIOError: [Errno 11] write could not complete without blocking
[11/Apr/2020 11:56:30] "GET /run-sh?url=test.com HTTP/1.1" 500 80341

Как это решить.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...