177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
timeout = None
eof = False
buffer = ''
while True:
# checking if there is any data or witing for data to arrive
kevs = self._kq.control(None, 1, timeout)
assert len(kevs) > 0, 'Fatal error: we should receive at least one event.'
# detect end of stream and exit if possible
if kevs[0].flags >> 15 == 1:
eof = True
if kevs[0].filter == self._select.KQ_FILTER_READ and kevs[0].data > 0:
# reading data in
new_buffer = sys.stdin.read(kevs[0].data)
# if no data was sent - we have reached end of file
if len(new_buffer) == 0:
eof = True
else:
# adding current buffer to old buffer remains
|
<
<
|
|
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
timeout = None
eof = False
buffer = ''
while True:
# checking if there is any data or witing for data to arrive
kevs = self._kq.control(None, 1, timeout)
# detect end of stream and exit if possible
if len(kevs) > 0 and kevs[0].flags >> 15 == 1:
eof = True
if len(kevs) > 0 and kevs[0].filter == self._select.KQ_FILTER_READ and kevs[0].data > 0:
# reading data in
new_buffer = sys.stdin.read(kevs[0].data)
# if no data was sent - we have reached end of file
if len(new_buffer) == 0:
eof = True
else:
# adding current buffer to old buffer remains
|