Closed mattura closed 2 years ago
My code frequently hangs during the ntp call (eg if the connection is lost) Passing a socket timeout through the function could resolve this or at least allow my code to continue after a short delay
eg:
def __init__( self, socketpool, *, server: str = "0.adafruit.pool.ntp.org", port: int = 123, tz_offset: int = 0, socket_timeout = 10 ) -> None: ... self._socket_timeout = socket_timeout ... def datetime(self) -> time.struct_time: ... with self._pool.socket(self._pool.AF_INET, self._pool.SOCK_DGRAM) as sock: sock.settimeout(self._socket_timeout) sock.sendto(self._packet, (self._server, self._port)) ...
Created PR https://github.com/adafruit/Adafruit_CircuitPython_NTP/pull/22
Resolved via #22
My code frequently hangs during the ntp call (eg if the connection is lost) Passing a socket timeout through the function could resolve this or at least allow my code to continue after a short delay
eg: