Explorar el Código

Use Py3.2's threading.TIMEOUT_MAX. Closes #796

Ask Solem hace 12 años
padre
commit
4992a44d17

+ 2 - 1
celery/tests/utilities/test_datastructures.py

@@ -10,6 +10,7 @@ from celery.datastructures import (
     ConfigurationView,
     DependencyGraph,
 )
+from celery.utils.threads import TIMEOUT_MAX
 from celery.tests.utils import Case, WhateverIO
 
 
@@ -222,7 +223,7 @@ class test_LRUCache(Case):
             def stop(self):
                 self._is_shutdown.set()
                 self._is_stopped.wait()
-                self.join(1e10)
+                self.join(TIMEOUT_MAX)
 
         burglar = Burglar(x)
         burglar.start()

+ 6 - 1
celery/utils/threads.py

@@ -24,6 +24,11 @@ _Event = threading._Event
 active_count = (getattr(threading, 'active_count', None) or
                 threading.activeCount)
 
+try:
+    TIMEOUT_MAX = threading.TIMEOUT_MAX
+except AttributeError:
+    TIMEOUT_MAX = 1e10  # noqa
+
 
 class Event(_Event):
 
@@ -93,7 +98,7 @@ class bgThread(Thread):
         self._is_shutdown.set()
         self._is_stopped.wait()
         if self.is_alive():
-            self.join(1e100)
+            self.join(TIMEOUT_MAX)
 
 try:
     from greenlet import getcurrent as get_ident

+ 3 - 2
celery/utils/timer2.py

@@ -15,11 +15,12 @@ import os
 import sys
 import threading
 
+from datetime import datetime, timedelta
 from functools import wraps
 from itertools import count
 from time import time, sleep, mktime
 
-from datetime import datetime, timedelta
+from celery.utils.threads import TIMEOUT_MAX
 from kombu.log import get_logger
 
 VERSION = (1, 0, 0)
@@ -276,7 +277,7 @@ class Timer(threading.Thread):
         if self.running:
             self._is_shutdown.set()
             self._is_stopped.wait()
-            self.join(1e10)
+            self.join(TIMEOUT_MAX)
             self.running = False
 
     def ensure_started(self):