MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / _recv

Method _recv

tests/mock_server.py:396–426  ·  view source on GitHub ↗
(self, timeout=2, end=b'\x00')

Source from the content-addressed store, hash-verified

394 return resp
395
396 def _recv(self, timeout=2, end=b'\x00'):
397 self._caves_sock.setblocking(0)
398 buf = []
399 data = ''
400 chunk = 4096
401 start = time.time()
402 while True:
403 # if received data and passed timeout
404 # return the received data
405 if buf and time.time() - start > timeout:
406 break
407 # if no data received, allow a bit more time
408 elif time.time() - start > timeout * 1.1:
409 break
410
411 try:
412 data = self._caves_sock.recv(chunk)
413 if data:
414 if end and end in data:
415 buf.append(str(data[:len(data)-1], encoding='utf-8'))
416 break
417
418 buf.append(str(data, encoding='utf-8'))
419 start = time.time()
420 else:
421 time.sleep(0.1)
422 except Exception:
423 pass
424
425 result = ''.join(buf)
426 return result

Callers 1

_read_commandMethod · 0.95

Calls 2

appendMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected