Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

in LiveServerTestCase.
  • Loading branch information...
commit 688678e7c091e4549777d8cc47e8984d5e672976 1 parent e98cb05
@aaugustin aaugustin authored
Showing with 19 additions and 16 deletions.
  1. +19 −16 django/test/testcases.py
View
35 django/test/testcases.py
@@ -917,23 +917,26 @@ def log_message(*args):
pass
-class _ImprovedEvent(threading._Event):
- """
- Does the same as `threading.Event` except it overrides the wait() method
- 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.
- """
+if sys.version_info >= (2, 6, 0):
@charettes Collaborator

@aaugustin shouldn't we check against (2, 7, 0)?

@claudep Collaborator
claudep added a note

Fixed in d69bd23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ _ImprovedEvent = threading._Event
+else:
+ class _ImprovedEvent(threading._Event):
+ """
+ Does the same as `threading.Event` except it overrides the wait() method
+ 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):
- self._Event__cond.acquire()
- try:
- if not self._Event__flag:
- self._Event__cond.wait(timeout)
- return self._Event__flag
- finally:
- self._Event__cond.release()
+ def wait(self, timeout=None):
+ self._Event__cond.acquire()
+ try:
+ if not self._Event__flag:
+ self._Event__cond.wait(timeout)
+ return self._Event__flag
+ finally:
+ self._Event__cond.release()
class StoppableWSGIServer(WSGIServer):
@charettes

@aaugustin shouldn't we check against (2, 7, 0)?

@claudep

Fixed in d69bd23

Please sign in to comment.
Something went wrong with that request. Please try again.