Re: [Zope3-dev] Re: Leak in zope.component?

2007-08-23 Thread Jim Fulton


On Aug 23, 2007, at 1:53 AM, Christian Zagrodnick wrote:


On 2007-08-22 16:12:42 +0200, Jim Fulton [EMAIL PROTECTED] said:


On Aug 22, 2007, at 8:16 AM, Christian Zagrodnick wrote:

Hi,
I'm doing things wich z3c.zalchemy and trying to find out why my   
database connections are kept open  even after unregistering   
everything.

Given the following very simple test:

import sys
import zope.component
import zope.interface
class IUtil(zope.interface.Interface):

... pass

gsm = zope.component.getGlobalSiteManager()
utility = object()
sys.getrefcount(utility)

2

gsm.registerUtility(utility, IUtil)
sys.getrefcount(utility)

6

gsm.unregisterUtility(utility, IUtil)

True

sys.getrefcount(utility)  # this fails

2
 
--
File /Users/zagy/development/z3c.zalchemy/src/z3c/zalchemy/ 
tests/ dispose.txt, line 17, in dispose.txt

Failed example:
   sys.getrefcount(utility)  # this fails
Expected:
   2
Got:
   4
So there are now two more references than before register/  
unregister. Am I missing something? Or is it leaking somewhere?

Here's what I get with the trunk of zope.component:
[EMAIL PROTECTED]:~/p/zope/component/trunk$ bin/py
  import sys, zope.component, zope.interface
  class IUtil(zope.interface.Interface): pass
...
  gsm = zope.component.getGlobalSiteManager()
  utility = object(); sys.getrefcount(utility)
2
  gsm.registerUtility(utility, IUtil); sys.getrefcount(utility)
5
  gsm.unregisterUtility(utility, IUtil); sys.getrefcount(utility)
True
2
So I can't reproduce what you are seeing.
Try adding:
 import gc; gc.collect()
before your last getrefcount call.


That doesn't change a thing. Could it be the testrunner having an  
eye on registrations?


I don't know what you mean.  I ran my example interactively.  What  
happens when you run my example interactively?


Jim

--
Jim Fulton  mailto:[EMAIL PROTECTED]Python 
Powered!
CTO (540) 361-1714  
http://www.python.org
Zope Corporationhttp://www.zope.com http://www.zope.org



___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] Re: Leak in zope.component?

2007-08-22 Thread Christian Zagrodnick

On 2007-08-22 16:12:42 +0200, Jim Fulton [EMAIL PROTECTED] said:



On Aug 22, 2007, at 8:16 AM, Christian Zagrodnick wrote:


Hi,

I'm doing things wich z3c.zalchemy and trying to find out why my  
database connections are kept open  even after unregistering  
everything.


Given the following very simple test:


import sys
import zope.component
import zope.interface
class IUtil(zope.interface.Interface):

... pass


gsm = zope.component.getGlobalSiteManager()
utility = object()
sys.getrefcount(utility)

2

gsm.registerUtility(utility, IUtil)
sys.getrefcount(utility)

6


gsm.unregisterUtility(utility, IUtil)

True

sys.getrefcount(utility)  # this fails

2

--
File /Users/zagy/development/z3c.zalchemy/src/z3c/zalchemy/tests/ 
dispose.txt, line 17, in dispose.txt

Failed example:
   sys.getrefcount(utility)  # this fails
Expected:
   2
Got:
   4



So there are now two more references than before register/ unregister. 
Am I missing something? Or is it leaking somewhere?


Here's what I get with the trunk of zope.component:

[EMAIL PROTECTED]:~/p/zope/component/trunk$ bin/py

  import sys, zope.component, zope.interface
  class IUtil(zope.interface.Interface): pass
...
  gsm = zope.component.getGlobalSiteManager()
  utility = object(); sys.getrefcount(utility)
2
  gsm.registerUtility(utility, IUtil); sys.getrefcount(utility)
5
  gsm.unregisterUtility(utility, IUtil); sys.getrefcount(utility)
True
2

So I can't reproduce what you are seeing.

Try adding:

 import gc; gc.collect()

before your last getrefcount call.


That doesn't change a thing. Could it be the testrunner having an eye 
on registrations?


--
Christian Zagrodnick

gocept gmbh  co. kg  ·  forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon. +49 345 12298894 · fax. +49 345 12298891



___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com