aboutsummaryrefslogtreecommitdiffstats
path: root/libs/tiny_atexit/atexit.py
blob: 7cc9f9e014717715ac5a4dfdf88276c215400517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
__all__ = [ "register", "unregister", ]
_exitfuncs = []

import sys
if hasattr(sys, "atexit"):
	def _exitfunc():
		for f, a, k in _exitfuncs:
			f(*a, **k)
	sys.atexit(_exitfunc)

def register(func, *args, **kwargs):
	_exitfuncs.append((func, args, kwargs))
	return func

def unregister(func):
	global _exitfuncs
	_exitfuncs = [ (f, a, k)
		       for f, a, k in _exitfuncs
		       if f is not func ]
bues.ch cgit interface