2019-08-05 15:12:27 +02:00
|
|
|
# test sys.atexit() function
|
|
|
|
|
2022-08-18 16:57:45 +10:00
|
|
|
import sys
|
2020-03-22 21:26:08 -05:00
|
|
|
|
2019-08-05 15:12:27 +02:00
|
|
|
try:
|
2022-08-18 16:57:45 +10:00
|
|
|
sys.atexit
|
2019-08-05 15:12:27 +02:00
|
|
|
except AttributeError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
some_var = None
|
|
|
|
|
2020-03-22 21:26:08 -05:00
|
|
|
|
2019-08-05 15:12:27 +02:00
|
|
|
def do_at_exit():
|
|
|
|
print("done at exit:", some_var)
|
|
|
|
|
2020-03-22 21:26:08 -05:00
|
|
|
|
2022-08-18 16:57:45 +10:00
|
|
|
sys.atexit(do_at_exit)
|
2019-08-05 15:12:27 +02:00
|
|
|
|
|
|
|
some_var = "ok"
|
|
|
|
print("done before exit")
|