2019-08-05 14:12:27 +01:00
|
|
|
# test sys.atexit() function
|
|
|
|
|
2020-06-18 10:19:14 +01:00
|
|
|
import usys
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2019-08-05 14:12:27 +01:00
|
|
|
try:
|
2020-06-18 10:19:14 +01:00
|
|
|
usys.atexit
|
2019-08-05 14:12:27 +01:00
|
|
|
except AttributeError:
|
2020-03-23 02:26:08 +00:00
|
|
|
print("SKIP")
|
2019-08-05 14:12:27 +01:00
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
some_var = None
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2019-08-05 14:12:27 +01:00
|
|
|
def do_at_exit():
|
|
|
|
print("done at exit:", some_var)
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2020-06-18 10:19:14 +01:00
|
|
|
usys.atexit(do_at_exit)
|
2019-08-05 14:12:27 +01:00
|
|
|
|
|
|
|
some_var = "ok"
|
|
|
|
print("done before exit")
|