Hi all.

I know Python but I'm pretty new to Django. It seems to me this is a bug, 
but I'd like your opinions before actually filing a bug report.

this is my function, executed by an http call:

@csrf_exempt
def main(request):

    obj = MyClass()
    # raise AssertionError

    return HttpResponse('OK\n', content_type='text/plain')


this is MyClass:

class MyClass:

    def __init__(self):
        pass

    def __del__(self) :
        print('>>>>>>>>>>>>> DEL')


without raising the AssertionError, everything works fine and I see the 
print() output in the server log as soon the function main() terminates.
But uncommenting the raise line I don't see the print() output; triggering 
the server reload by saving a source file, the print() output shows up.

This happens with the internal webserver as well as with Lighttpd + 
Gunicorn.

I think Django is keeping some reference to the frame object of the 
function main(). This behaviour doesn't let me to close things like file 
descriptors or sockets in case of untrapped exception.

Is this a bug? Or... what I'm doing wrong?

I'm running Django 2.0.7, Python 3.6.1, Linux.
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cccaaf31-1958-415a-831f-ef3ad0150399%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to