2019-08-05 09:12:27 -04:00
|
|
|
# test sys.atexit() function
|
|
|
|
|
|
|
|
import sys
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-08-05 09:12:27 -04:00
|
|
|
try:
|
|
|
|
sys.atexit
|
|
|
|
except AttributeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("SKIP")
|
2019-08-05 09:12:27 -04:00
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
some_var = None
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-08-05 09:12:27 -04:00
|
|
|
def do_at_exit():
|
|
|
|
print("done at exit:", some_var)
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-08-05 09:12:27 -04:00
|
|
|
sys.atexit(do_at_exit)
|
|
|
|
|
|
|
|
some_var = "ok"
|
|
|
|
print("done before exit")
|