0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

[py3] Avoided relying on 2.x-only internals

in LiveServerTestCase.
This commit is contained in:
Aymeric Augustin 2012-08-16 09:56:42 +02:00
parent e98cb05edf
commit 688678e7c0

View File

@ -917,23 +917,26 @@ class QuietWSGIRequestHandler(WSGIRequestHandler):
pass pass
class _ImprovedEvent(threading._Event): if sys.version_info >= (2, 6, 0):
""" _ImprovedEvent = threading._Event
Does the same as `threading.Event` except it overrides the wait() method else:
with some code borrowed from Python 2.7 to return the set state of the class _ImprovedEvent(threading._Event):
event (see: http://hg.python.org/cpython/rev/b5aa8aa78c0f/). This allows """
to know whether the wait() method exited normally or because of the Does the same as `threading.Event` except it overrides the wait() method
timeout. This class can be removed when Django supports only Python >= 2.7. with some code borrowed from Python 2.7 to return the set state of the
""" event (see: http://hg.python.org/cpython/rev/b5aa8aa78c0f/). This allows
to know whether the wait() method exited normally or because of the
timeout. This class can be removed when Django supports only Python >= 2.7.
"""
def wait(self, timeout=None): def wait(self, timeout=None):
self._Event__cond.acquire() self._Event__cond.acquire()
try: try:
if not self._Event__flag: if not self._Event__flag:
self._Event__cond.wait(timeout) self._Event__cond.wait(timeout)
return self._Event__flag return self._Event__flag
finally: finally:
self._Event__cond.release() self._Event__cond.release()
class StoppableWSGIServer(WSGIServer): class StoppableWSGIServer(WSGIServer):