Explorar o código

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

Ask Solem %!s(int64=12) %!d(string=hai) anos
pai
achega
4992a44d17

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

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

+ 6 - 1
celery/utils/threads.py

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

+ 3 - 2
celery/utils/timer2.py

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