Show More
@@ -68,7 +68,7 b' def ismainthread():' | |||
|
68 | 68 | return threading.current_thread() == threading.main_thread() |
|
69 | 69 | |
|
70 | 70 | |
|
71 |
class _blockingreader |
|
|
71 | class _blockingreader: | |
|
72 | 72 | def __init__(self, wrapped): |
|
73 | 73 | self._wrapped = wrapped |
|
74 | 74 | |
@@ -114,37 +114,6 b' class _blockingreader(object):' | |||
|
114 | 114 | return bytes(buf) |
|
115 | 115 | |
|
116 | 116 | |
|
117 | class _blockingreader: | |
|
118 | def __init__(self, wrapped): | |
|
119 | self._wrapped = wrapped | |
|
120 | ||
|
121 | # Do NOT implement readinto() by making it delegate to | |
|
122 | # _wrapped.readinto(), since that is unbuffered. The unpickler is fine | |
|
123 | # with just read() and readline(), so we don't need to implement it. | |
|
124 | ||
|
125 | def readline(self): | |
|
126 | return self._wrapped.readline() | |
|
127 | ||
|
128 | # issue multiple reads until size is fulfilled | |
|
129 | def read(self, size=-1): | |
|
130 | if size < 0: | |
|
131 | return self._wrapped.readall() | |
|
132 | ||
|
133 | buf = bytearray(size) | |
|
134 | view = memoryview(buf) | |
|
135 | pos = 0 | |
|
136 | ||
|
137 | while pos < size: | |
|
138 | ret = self._wrapped.readinto(view[pos:]) | |
|
139 | if not ret: | |
|
140 | break | |
|
141 | pos += ret | |
|
142 | ||
|
143 | del view | |
|
144 | del buf[pos:] | |
|
145 | return bytes(buf) | |
|
146 | ||
|
147 | ||
|
148 | 117 | if pycompat.isposix or pycompat.iswindows: |
|
149 | 118 | _STARTUP_COST = 0.01 |
|
150 | 119 | # The Windows worker is thread based. If tasks are CPU bound, threads |
General Comments 0
You need to be logged in to leave comments.
Login now