A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033619.html below:

[Python-Dev] Traceback problem

[Python-Dev] Traceback problemMark Hammond mhammond@skippinet.com.au
Tue, 25 Feb 2003 11:05:51 +1100
I'm not completely clear on the problem being described here, but:

> Sure, it is possible for long-running functions to wrap
> any exception-raising stuff into an extra wrapping function
> that always returns after the exception has happened,
> and to let the main worker function run without try..except.
> But is this very cool?

I point out that the following code:

import sys
def a():
    try:
        1/0
    except:
        t, v, tb = sys.exc_info()

if __name__=='__main__':
    while 1:
        a()

When garbage collection is not enabled will cause huge memory leaks.  The
problem is the "tb" variable - the traceback holds a reference to the stack
frame, which holds references to the locals, which holds a reference back to
"tb".

gc clears these cycles, so later Python versions work fine - does stackless
enable gc?  Explicitly setting "tb" to None in the exception handler also
fixes it.

No idea if it is related or not, but this problem caused me such grief years
ago that I thought it worth mentioning.

Mark.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4