File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import time
1010import datetime
1111import decimal
12+ import gc
1213from itertools import chain , islice
1314from operator import itemgetter
1415
@@ -317,6 +318,27 @@ def testItsClosed(self):
317318 c .close ()
318319 self .db .close ()
319320
321+ def testGarbage (self ):
322+ ps = self .db .prepare ('select 1' )
323+ sid = ps .statement_id
324+ ci = ps .chunks ()
325+ ci_id = ci .cursor .cursor_id
326+ c = ps .declare ()
327+ cid = c .cursor_id
328+ # make sure there are no remaining xact references..
329+ self .db ._pq_complete ()
330+ # ci and c both hold references to ps, so they must
331+ # be removed before we can observe the effects __del__
332+ del c
333+ gc .collect ()
334+ self .failUnless (self .db .typio .encode (cid ) in self .db ._closeportals )
335+ del ci
336+ gc .collect ()
337+ self .failUnless (self .db .typio .encode (ci_id ) in self .db ._closeportals )
338+ del ps
339+ gc .collect ()
340+ self .failUnless (self .db .typio .encode (sid ) in self .db ._closestatements )
341+
320342 def testStatementCall (self ):
321343 ps = self .db .prepare ("SELECT 1" )
322344 r = ps ()
You can’t perform that action at this time.
0 commit comments