Show More
@@ -407,6 +407,15 b' except ImportError:' | |||
|
407 | 407 | |
|
408 | 408 | |
|
409 | 409 | #============================================================================== |
|
410 | # bytes | |
|
411 | #============================================================================== | |
|
412 | if __py_version__ >= (2, 6): | |
|
413 | _bytes = bytes | |
|
414 | else: | |
|
415 | # in py2.6 bytes is a synonim for str | |
|
416 | _bytes = str | |
|
417 | ||
|
418 | #============================================================================== | |
|
410 | 419 | # deque |
|
411 | 420 | #============================================================================== |
|
412 | 421 | |
@@ -420,7 +429,7 b' else:' | |||
|
420 | 429 | if not hasattr(self, 'data'): |
|
421 | 430 | self.left = self.right = 0 |
|
422 | 431 | self.data = {} |
|
423 | self.maxlen = maxlen | |
|
432 | self.maxlen = maxlen or -1 | |
|
424 | 433 | self.extend(iterable) |
|
425 | 434 | |
|
426 | 435 | def append(self, x): |
@@ -537,9 +546,9 b' else:' | |||
|
537 | 546 | #============================================================================== |
|
538 | 547 | |
|
539 | 548 | if __py_version__ >= (2, 6): |
|
540 | from threading import Event | |
|
549 | from threading import Event, Thread | |
|
541 | 550 | else: |
|
542 | from threading import _Verbose, Condition, Lock | |
|
551 | from threading import _Verbose, Condition, Lock, Thread | |
|
543 | 552 | |
|
544 | 553 | def Event(*args, **kwargs): |
|
545 | 554 | return _Event(*args, **kwargs) |
@@ -24,11 +24,10 b' If not, see <http://www.gnu.org/licenses' | |||
|
24 | 24 | ''' |
|
25 | 25 | import os |
|
26 | 26 | import subprocess |
|
27 | import threading | |
|
28 | from rhodecode.lib.compat import deque, Event | |
|
27 | from rhodecode.lib.compat import deque, Event, Thread, _bytes | |
|
29 | 28 | |
|
30 | 29 | |
|
31 |
class StreamFeeder( |
|
|
30 | class StreamFeeder(Thread): | |
|
32 | 31 | """ |
|
33 | 32 | Normal writing into pipe-like is blocking once the buffer is filled. |
|
34 | 33 | This thread allows a thread to seep data from a file-like into a pipe |
@@ -39,9 +38,9 b' class StreamFeeder(threading.Thread):' | |||
|
39 | 38 | super(StreamFeeder, self).__init__() |
|
40 | 39 | self.daemon = True |
|
41 | 40 | filelike = False |
|
42 | self.bytes = bytes() | |
|
43 | if type(source) in (type(''), bytes, bytearray): # string-like | |
|
44 | self.bytes = bytes(source) | |
|
41 | self.bytes = _bytes() | |
|
42 | if type(source) in (type(''), _bytes, bytearray): # string-like | |
|
43 | self.bytes = _bytes(source) | |
|
45 | 44 | else: # can be either file pointer or file-like |
|
46 | 45 | if type(source) in (int, long): # file pointer it is |
|
47 | 46 | ## converting file descriptor (int) stdin into file-like |
@@ -77,7 +76,7 b' class StreamFeeder(threading.Thread):' | |||
|
77 | 76 | return self.readiface |
|
78 | 77 | |
|
79 | 78 | |
|
80 |
class InputStreamChunker( |
|
|
79 | class InputStreamChunker(Thread): | |
|
81 | 80 | def __init__(self, source, target, buffer_size, chunk_size): |
|
82 | 81 | |
|
83 | 82 | super(InputStreamChunker, self).__init__() |
@@ -121,6 +120,7 b' class InputStreamChunker(threading.Threa' | |||
|
121 | 120 | da = self.data_added |
|
122 | 121 | go = self.go |
|
123 | 122 | b = s.read(cs) |
|
123 | ||
|
124 | 124 | while b and go.is_set(): |
|
125 | 125 | if len(t) > ccm: |
|
126 | 126 | kr.clear() |
@@ -180,7 +180,7 b' class BufferedGenerator():' | |||
|
180 | 180 | self.worker.data_added.wait(0.2) |
|
181 | 181 | if len(self.data): |
|
182 | 182 | self.worker.keep_reading.set() |
|
183 | return bytes(self.data.popleft()) | |
|
183 | return _bytes(self.data.popleft()) | |
|
184 | 184 | elif self.worker.EOF.is_set(): |
|
185 | 185 | raise StopIteration |
|
186 | 186 |
General Comments 0
You need to be logged in to leave comments.
Login now