How to use the tempora.parse_timedelta function in tempora

To help you get started, we’ve selected a few tempora examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yougov / pmxbot / pmxbot / irc.py View on Github external
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)