From be5c71180d44d02ebd7fe53724a2ef04bc950c6e Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Mon, 17 Oct 2022 14:32:52 +0200 Subject: [PATCH] net/ntptime/ntptime.py: Allow overriding default NTP timeout. * The default 1 second timeout is sometimes not enough depending on the host and network latencies. This patch makes timeout configurable. --- micropython/net/ntptime/ntptime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/micropython/net/ntptime/ntptime.py b/micropython/net/ntptime/ntptime.py index 05d7e9717..fdd9434db 100644 --- a/micropython/net/ntptime/ntptime.py +++ b/micropython/net/ntptime/ntptime.py @@ -11,6 +11,8 @@ # The NTP host can be configured at runtime by doing: ntptime.host = 'myhost.org' host = "pool.ntp.org" +# The NTP socket timeout can be configured at runtime by doing: ntptime.timeout = 1.0 +timeout = 1.0 def time(): @@ -19,7 +21,7 @@ def time(): addr = socket.getaddrinfo(host, 123)[0][-1] s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: - s.settimeout(1) + s.settimeout(timeout) res = s.sendto(NTP_QUERY, addr) msg = s.recv(48) finally: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy