From 5f59365d886e371a4970af7c292373cb6fc7d32b Mon Sep 17 00:00:00 2001 From: "roberto@mrspurr" Date: Sat, 10 Sep 2011 10:54:27 +0200 Subject: [PATCH 1/3] symzip GC fix --- plugins/python/symimporter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/python/symimporter.c b/plugins/python/symimporter.c index 2e1361c8..d3ef74e1 100644 --- a/plugins/python/symimporter.c +++ b/plugins/python/symimporter.c @@ -363,7 +363,8 @@ static PyMethodDef symzipimporter_methods[] = { }; static void uwsgi_symimporter_free(struct _symimporter *self) { - PyObject_Del(self); + PyObject_GC_UnTrack(self); + Py_TYPE(self)->tp_free((PyObject *)self); } From b341678d205cbf19c58a8b6f6a580a23a35f09d8 Mon Sep 17 00:00:00 2001 From: "roberto@mrspurr" Date: Sat, 10 Sep 2011 10:58:37 +0200 Subject: [PATCH 2/3] another symzip fix --- plugins/python/symimporter.c | 6 +++--- welcome.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/python/symimporter.c b/plugins/python/symimporter.c index d3ef74e1..ba4e744a 100644 --- a/plugins/python/symimporter.c +++ b/plugins/python/symimporter.c @@ -388,7 +388,7 @@ static PyTypeObject SymImporter_Type = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE |Py_TPFLAGS_HAVE_GC, "uwsgi symbols importer", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -626,7 +626,7 @@ static PyTypeObject SymZipImporter_Type = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE |Py_TPFLAGS_HAVE_GC, "uwsgi symbols zip importer", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -668,7 +668,7 @@ static PyTypeObject ZipImporter_Type = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE |Py_TPFLAGS_HAVE_GC, "uwsgi zip importer", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/welcome.py b/welcome.py index 78cfefe0..985223e4 100644 --- a/welcome.py +++ b/welcome.py @@ -1,8 +1,11 @@ import uwsgi import os import gc +import sys gc.set_debug(gc.DEBUG_SAVEALL) +print sys.modules + def xsendfile(e, sr): sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))]) return '' From bf991f8892f8c7cc3f3cfd4c44fff6ed97e5312b Mon Sep 17 00:00:00 2001 From: "roberto@mrspurr" Date: Sat, 10 Sep 2011 11:03:39 +0200 Subject: [PATCH 3/3] report gb objects in welcome.py --- welcome.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/welcome.py b/welcome.py index 985223e4..75a48004 100644 --- a/welcome.py +++ b/welcome.py @@ -43,6 +43,8 @@ def application(env, start_response): print env['wsgi.input'].fileno() gc.collect(2) + print len(gc.get_objects()) + return """ version %s