Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def catch(self):
return self._raw_catch()
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def release(self):
if self.socket is not None:
self.socket.shutdown(socket.SHUT_RDWR)
self.socket.close()
self.socket = None
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def read(self):
return self._raw_read()
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def read(self):
try:
return self.socket.recv()
except:
logger.exception('read error')
return ''
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def release(self):
return self._raw_release()
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def catch(self):
self.socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
self.socket.connect((self.address, self.port))
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def write(self, data):
return self._raw_write(data)
@backoff(
max_tries=config.retry.max_tries,
delay=config.retry.delay,
factor=config.retry.factor,
exceptions=_RETRY_EXCEPTIONS)
def write(self, data):
totalsent = 0
while totalsent < len(data):
sent = self.socket.send(data[totalsent:])
if sent == 0:
self._raise_with_details('socket connection broken')
totalsent += sent