Tags: univention/python-notifier
Tags
Bug #47114: Fix memory leak - traceback The Python garbage collector (GC) nowadays can free cyclic structure, but keeping a Traceback object is still considered a bad idea: It contains a reference to all stack frames, which reference all local variables, and thus the traceback itself. Format the traceback once and replace the reference with None. The standard traceback library handles this fine. <https://docs.python.org/2/library/sys.html#sys.exc_info>
Fix KeyError if socket is removed in timer The following script demonstrates a KeyError which is caused if a socket which currently has some pending input/output was removed in a notifier timer. The problem is that step() first poll()s, then executes the timers() and then uses the polled FD's. $ cat timer_bug.py import notifier import subprocess notifier.init() fd = None def on_read(sock): print 'on_read' return True def on_timer(): print 'on_timer' notifier.socket_remove(fd) return True p = subprocess.Popen('python -c "import sys; sys.stdin.read()"', shell=True, stdin=subprocess.PIPE) fd = p.stdin.fileno() notifier.socket_add(fd, on_read) notifier.timer_add(0, on_timer) p.communicate('A') notifier.step() $ python timer_bug.py on_timer Traceback (most recent call last): File "timer_bug.py", line 18, in <module> notifier.step() File "/home/git/python-notifier/notifier/nf_generic.py", line 259, in step sock_obj = __sock_objects[ fd ] KeyError: 4