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