Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _set_keepalive(self, connection):
if 'TCP keepalive' not in pmxbot.config:
return
period = pmxbot.config['TCP keepalive']
if isinstance(period, numbers.Number):
period = datetime.timedelta(seconds=period)
if isinstance(period, str):
period = tempora.parse_timedelta(period)
log.info("Setting keepalive for %s", period)
connection.set_keepalive(period)