Changeset - 7949bc80b3b1
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-08-22 13:30:52
marcin@python-works.com
more py25 compat fixes
2 files changed with 58 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/compat.py
Show inline comments
 
@@ -530,3 +530,56 @@ else:
 
            memo[id(self)] = result
 
            result.__init__(deepcopy(tuple(self), memo))
 
            return result
 

	
 

	
 
#==============================================================================
 
# threading.Event
 
#==============================================================================
 

	
 
if __py_version__ >= (2, 6):
 
    from threading import Event
 
else:
 
    from threading import _Verbose, Condition, Lock
 

	
 
    def Event(*args, **kwargs):
 
        return _Event(*args, **kwargs)
 

	
 
    class _Event(_Verbose):
 

	
 
        # After Tim Peters' event class (without is_posted())
 

	
 
        def __init__(self, verbose=None):
 
            _Verbose.__init__(self, verbose)
 
            self.__cond = Condition(Lock())
 
            self.__flag = False
 

	
 
        def isSet(self):
 
            return self.__flag
 

	
 
        is_set = isSet
 

	
 
        def set(self):
 
            self.__cond.acquire()
 
            try:
 
                self.__flag = True
 
                self.__cond.notify_all()
 
            finally:
 
                self.__cond.release()
 

	
 
        def clear(self):
 
            self.__cond.acquire()
 
            try:
 
                self.__flag = False
 
            finally:
 
                self.__cond.release()
 

	
 
        def wait(self, timeout=None):
 
            self.__cond.acquire()
 
            try:
 
                if not self.__flag:
 
                    self.__cond.wait(timeout)
 
            finally:
 
                self.__cond.release()
 

	
 

	
 

	
rhodecode/lib/subprocessio.py
Show inline comments
 
@@ -25,7 +25,7 @@ If not, see <http://www.gnu.org/licenses
 
import os
 
import subprocess
 
import threading
 
from rhodecode.lib.compat import deque
 
from rhodecode.lib.compat import deque, Event
 

	
 

	
 
class StreamFeeder(threading.Thread):
 
@@ -89,16 +89,16 @@ class InputStreamChunker(threading.Threa
 
        self.chunk_count_max = int(buffer_size / chunk_size) + 1
 
        self.chunk_size = chunk_size
 

	
 
        self.data_added = threading.Event()
 
        self.data_added = Event()
 
        self.data_added.clear()
 

	
 
        self.keep_reading = threading.Event()
 
        self.keep_reading = Event()
 
        self.keep_reading.set()
 

	
 
        self.EOF = threading.Event()
 
        self.EOF = Event()
 
        self.EOF.clear()
 

	
 
        self.go = threading.Event()
 
        self.go = Event()
 
        self.go.set()
 

	
 
    def stop(self):
0 comments (0 inline, 0 general)