Opened 23 months ago

Closed 6 months ago

#20238 closed Bug (wontfix)

StoppableWSGIServer is not multithread support

Reported by: jwxiao@… Owned by: nobody
Component: Testing framework Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Run a selenium test with LiveServerTestCase. Django starts StoppableWSGIServer. The StoppableWSGIServer is not multithread support. When the codes to be tested call urllib.urlopen to the same server (ie: StoppableWSGIServer) the selenium test will hang and fail because of time-out.

Change History (5)

comment:1 Changed 22 months ago by julien

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

Thank you for the report, however there is too little information here to identify if or where there is an issue. Could you please provide a detailed explanation of how to reproduce the issue you're facing, or even better, could you provide some code or a test case? Thanks!

comment:2 Changed 22 months ago by julien

Just a clarification: please feel free to reopen this ticket if you can provide more detailed information.

comment:3 Changed 20 months ago by joeri

Although this is not my ticket, I just ran into the same issue.

The problem occurs typically when, within a request/response cycle, another request is done to the same StoppableWSGIServer. Now, the first request can never finish because the second request is waiting for the StoppableWSGIServer to respond (but it never will because it's waiting for the first request...)

# view
def index(self, request):
    if request.GET.get('inner_request') == 'true':
        # Within a request/response, perform another request to the same live server.
        # This one get's stuck.
        urllib.urlopen(request.build_absolute_uri())
    return HttpResponse()

# test
class LiveServerTests(LiveServerTestCase):
    def test_request_within_request(self):
        response = requests.get(self.live_server_url, params={'inner_request': 'true'})

        # This code is never reached (or the live server throws a timeout)
        self.assertEqual(response.status_code, 200)

The use case is somewhat fictional.

Last edited 20 months ago by joeri (previous) (diff)

comment:4 Changed 7 months ago by bdrennan@…

  • Resolution needsinfo deleted
  • Status changed from closed to new

comment:5 Changed 6 months ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

Considering that:

  • "the use case is somewhat fictional",
  • the ticket was reopened without any additional information,
  • more threading will certainly create more race conditions on shutdown, especially when it comes to the database connections — it's taken months to eliminate most from LiveServerTestCase, and I'm sure there are still some left,

I don't think we should add threading without more compelling arguments.

Note: See TracTickets for help on using tickets.
Back to Top