adafruit / Adafruit_CircuitPython_NTP

Network Time Protocol (NTP) Helper for CircuitPython
MIT License
9 stars 18 forks source link

Improve documentation of ntp.datetime access behavior and exceptions #23

Closed jdimpson closed 2 years ago

jdimpson commented 2 years ago

I've been running this on a qt-py-esp32-s2 for a couple days and had intermittent random code failures. It turns out that very occasionally the NTP response wasn't coming back within socket_timeout seconds, which manifested as an OSError exception that caused my code.py to exit. Took a while to recreate but fairly obvious how to fix.

In order to save others the time of having to recreate the problem in order to witness it in the REPL, I'd like to add some words to the inline documentation about both how 1) accesses to ntp.datetime are what cause the NTP request to be sent, and therefore 2) accesses to ntp.datetime may throw an OSError exception, which should be caught and handled appropriately. I will (attempt to) open a PR with these changes.

Thanks for making this NTP code. It was just what I needed for my project!

jdimpson commented 2 years ago

PR#24

(I don't think I connected the PR here correctly. Still new at this.)

askpatrickw commented 2 years ago

Ah, in your PR, you can say "Fixes #1234" or whatever the number is, and then it will automatically link and close the issue when you merged. Something to try next time. :-)

tekktrik commented 2 years ago

Closed via #24