Opened 6 years ago

Closed 6 years ago

#29305 closed Bug (wontfix)

GET or POST requests outside of the browser to the LiveServerTestCase server hang

Reported by: Santiago García Owned by: nobody
Component: Testing framework Version: 1.11
Severity: Normal Keywords: Test
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Santiago García)

We have an integration test where we start two separate Django processes and the second process makes a POST request to the first process with the requests library. This testcase broke once we upgraded to Django 1.11, while it still worked in Django 1.10.

To reproduce the issue:

  • Create a simple Django app.
  • Install selenium and requests
  • Add a testcase like so:


import time

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.urls import reverse
from selenium import webdriver


class TestExample(StaticLiveServerTestCase):
    def test_example(self):
        driver = webdriver.Chrome()
        driver.get(self.live_server_url + reverse('admin:index'))
        # wait "forever"
        time.sleep(60 * 60 * 24)

I.e it just opens the admin page in Chrome, then waits for 24 hours. In a Python console, type the following:

import requests
requests.get('http://localhost:47256/admin') # replace 47256 with whatever port number the LiveServerTestCase picked

and you will see that the request hangs indefinitely. Interestingly, it sometimes helps to press refresh in the Chrome window spawned by Selenium.

I am seeing this issue on Windows 7 and Windows 10 machines

Change History (7)

comment:1 Changed 6 years ago by Santiago García

Description: modified (diff)

comment:2 Changed 6 years ago by Santiago García

Summary: GET or POST requests outside of the browser to the LiveServerTestCase hangGET or POST requests outside of the browser to the LiveServerTestCase server hang

comment:3 Changed 6 years ago by Santiago García

Description: modified (diff)

comment:4 Changed 6 years ago by Santiago García

Description: modified (diff)

comment:5 Changed 6 years ago by Tim Graham

I can reproduce with Django 1.11.x but not with Django 2.0.x. Do you get the same result? If so, it might be a bit late to fix the issue for Django 1.11.x unless the fix is trivial.

comment:6 Changed 6 years ago by Santiago García

Yes, it does work for me on Django 2.0

comment:7 Changed 6 years ago by Tim Graham

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top