This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Blog post: | |
https://gmpy.dev/blog/2023/recognize-connection-errors | |
""" | |
import errno, socket, ssl | |
# Network errors, usually related to DHCP or wpa_supplicant (Wi-Fi). | |
NETWORK_ERRNOS = frozenset(( | |
errno.ENETUNREACH, # "Network is unreachable" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
People erroneously think that any function registered via atexit.register() | |
will be executed on interpreter exit. | |
This is not always true. For example, in case of SIGTERM: | |
import atexit, os, signal | |
@atexit.register | |
def cleanup(): | |
print("on exit") # XXX this never gets printed |