Show More
@@ -530,3 +530,56 b' else:' | |||||
530 | memo[id(self)] = result |
|
530 | memo[id(self)] = result | |
531 | result.__init__(deepcopy(tuple(self), memo)) |
|
531 | result.__init__(deepcopy(tuple(self), memo)) | |
532 | return result |
|
532 | return result | |
|
533 | ||||
|
534 | ||||
|
535 | #============================================================================== | |||
|
536 | # threading.Event | |||
|
537 | #============================================================================== | |||
|
538 | ||||
|
539 | if __py_version__ >= (2, 6): | |||
|
540 | from threading import Event | |||
|
541 | else: | |||
|
542 | from threading import _Verbose, Condition, Lock | |||
|
543 | ||||
|
544 | def Event(*args, **kwargs): | |||
|
545 | return _Event(*args, **kwargs) | |||
|
546 | ||||
|
547 | class _Event(_Verbose): | |||
|
548 | ||||
|
549 | # After Tim Peters' event class (without is_posted()) | |||
|
550 | ||||
|
551 | def __init__(self, verbose=None): | |||
|
552 | _Verbose.__init__(self, verbose) | |||
|
553 | self.__cond = Condition(Lock()) | |||
|
554 | self.__flag = False | |||
|
555 | ||||
|
556 | def isSet(self): | |||
|
557 | return self.__flag | |||
|
558 | ||||
|
559 | is_set = isSet | |||
|
560 | ||||
|
561 | def set(self): | |||
|
562 | self.__cond.acquire() | |||
|
563 | try: | |||
|
564 | self.__flag = True | |||
|
565 | self.__cond.notify_all() | |||
|
566 | finally: | |||
|
567 | self.__cond.release() | |||
|
568 | ||||
|
569 | def clear(self): | |||
|
570 | self.__cond.acquire() | |||
|
571 | try: | |||
|
572 | self.__flag = False | |||
|
573 | finally: | |||
|
574 | self.__cond.release() | |||
|
575 | ||||
|
576 | def wait(self, timeout=None): | |||
|
577 | self.__cond.acquire() | |||
|
578 | try: | |||
|
579 | if not self.__flag: | |||
|
580 | self.__cond.wait(timeout) | |||
|
581 | finally: | |||
|
582 | self.__cond.release() | |||
|
583 | ||||
|
584 | ||||
|
585 |
@@ -25,7 +25,7 b' If not, see <http://www.gnu.org/licenses' | |||||
25 | import os |
|
25 | import os | |
26 | import subprocess |
|
26 | import subprocess | |
27 | import threading |
|
27 | import threading | |
28 | from rhodecode.lib.compat import deque |
|
28 | from rhodecode.lib.compat import deque, Event | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | class StreamFeeder(threading.Thread): |
|
31 | class StreamFeeder(threading.Thread): | |
@@ -89,16 +89,16 b' class InputStreamChunker(threading.Threa' | |||||
89 | self.chunk_count_max = int(buffer_size / chunk_size) + 1 |
|
89 | self.chunk_count_max = int(buffer_size / chunk_size) + 1 | |
90 | self.chunk_size = chunk_size |
|
90 | self.chunk_size = chunk_size | |
91 |
|
91 | |||
92 |
self.data_added = |
|
92 | self.data_added = Event() | |
93 | self.data_added.clear() |
|
93 | self.data_added.clear() | |
94 |
|
94 | |||
95 |
self.keep_reading = |
|
95 | self.keep_reading = Event() | |
96 | self.keep_reading.set() |
|
96 | self.keep_reading.set() | |
97 |
|
97 | |||
98 |
self.EOF = |
|
98 | self.EOF = Event() | |
99 | self.EOF.clear() |
|
99 | self.EOF.clear() | |
100 |
|
100 | |||
101 |
self.go = |
|
101 | self.go = Event() | |
102 | self.go.set() |
|
102 | self.go.set() | |
103 |
|
103 | |||
104 | def stop(self): |
|
104 | def stop(self): |
General Comments 0
You need to be logged in to leave comments.
Login now