Ticket #2879: 2879-error-fixes.diff

File 2879-error-fixes.diff, 1.5 KB (added by akaariai, 4 years ago)

Incremental to .10.diff

  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index 30d6e98..5625b91 100644
    a b class StoppableWSGIServer(WSGIServer): 
    778778            r, w, e = select.select([self], [], [], poll_interval)
    779779            if r:
    780780                self._handle_request_noblock()
     781        self.__serving = None
    781782        self.__is_shut_down.set()
    782783
    783784    def shutdown(self):
    class StoppableWSGIServer(WSGIServer): 
    788789        deadlock.
    789790        """
    790791        self.__serving = False
    791         self.__is_shut_down.wait()
     792        self.__is_shut_down.wait(2)
     793        if self.__serving is not None:
     794            raise RuntimeError("Failed to shutdown the server in 2 seconds. "
     795                               "The server might be stuck, or generating a slow response.")
    792796
    793797    def handle_request(self):
    794798        """Handle one request, possibly blocking.
    class LiveServerThread(threading.Thread): 
    865869        except WSGIServerException, e:
    866870            self.error = e
    867871            self.is_ready.set()
     872        except Exception, e:
     873            self.error = e
     874            self.is_ready.set()
    868875
    869876    def join(self, timeout=None):
    870877        self.httpd.shutdown()
    class LiveServerTestCase(TransactionTestCase): 
    904911            settings.LIVE_TEST_SERVER_HOST,
    905912            int(settings.LIVE_TEST_SERVER_PORT),
    906913            connections_override)
     914        cls.server_thread.daemon = True
    907915        cls.server_thread.start()
    908916
    909917        # Wait for the Django server to be ready
Back to Top