![](https://secure.gravatar.com/avatar/674230ee025212c1201174538094c63b.jpg?s=120&d=mm&r=g)
Hi I found the cause of html_fibo.py at the EuroPython Hands-on. This case, HtmlTag destructor isn’t call when the object didn’t use. Is this garbage collection’s problem? (pypy-trunk(1.6.0-dev) same too.) === def html_fibo(f): f.write('<ul>\n') try: for n in fibo(): tag = HtmlTag(f, 4, 'li') yield n tag = None # doesn’t call destructor here. finally: tag = None # here, too. f.write('</ul>\n') def write_file(): f = open('fibo.txt', 'w') # f.close does’nt call, too. for n in html_fibo(f): f.write('%d' % n) if n > 100: break runing code and patch are the following link.(not pypy source code patch.) https://gist.github.com/1117550 and is this problem in bugs.pypy.org? I can’nt found it. Cheers. Kenji
![](https://secure.gravatar.com/avatar/cdc3cafa377f0e0e93fc69636021ef65.jpg?s=120&d=mm&r=g)
On 01/08/11 07:25, Kenji Yano wrote:
Hi
I found the cause of html_fibo.py at the EuroPython Hands-on. This case, HtmlTag destructor isn’t call when the object didn’t use. Is this garbage collection’s problem? (pypy-trunk(1.6.0-dev) same too.)
yes. The difference with CPython is that CPython destroys the object as soon as it forgets the last reference to the object (and thus it is deterministic), while on PyPy the objects are destroyed only the the GC runs (which is not deterministic).
runing code and patch are the following link.(not pypy source code patch.) https://gist.github.com/1117550
your patch works but it's suboptimal and slower than it need. The proper solution would be to add the appropriate calls to .close() to the file and to the generator (possibily using the with statement) and also to provide a method to HtmlTag to explicitly close the tag instead of relying on the __del__.
and is this problem in bugs.pypy.org? I can’nt found it.
it works for me: https://bugs.pypy.org/ you need to explicitly allow our custom SSL certificate, but that's all. ciao, Anto
![](https://secure.gravatar.com/avatar/674230ee025212c1201174538094c63b.jpg?s=120&d=mm&r=g)
Hi, Anto Thanks for your reply. 2011/8/1 Antonio Cuni <anto.cuni@gmail.com>:
On 01/08/11 07:25, Kenji Yano wrote:
Hi
I found the cause of html_fibo.py at the EuroPython Hands-on. This case, HtmlTag destructor isn’t call when the object didn’t use. Is this garbage collection’s problem? (pypy-trunk(1.6.0-dev) same too.)
yes. The difference with CPython is that CPython destroys the object as soon as it forgets the last reference to the object (and thus it is deterministic), while on PyPy the objects are destroyed only the the GC runs (which is not deterministic).
OK, I understand.
runing code and patch are the following link.(not pypy source code patch.) https://gist.github.com/1117550
your patch works but it's suboptimal and slower than it need. The proper solution would be to add the appropriate calls to .close() to the file and to the generator (possibily using the with statement) and also to provide a method to HtmlTag to explicitly close the tag instead of relying on the __del__.
yes, I know. I wanted to say gc doesn't work. That's the only reason.
and is this problem in bugs.pypy.org? I can’nt found it.
it works for me: https://bugs.pypy.org/
you need to explicitly allow our custom SSL certificate, but that's all. ciao, Anto
I created new issue, because pypy have compatibility problem. but, I learned that pypy has different garbage collection strategies. so I remove that issue. Cheers Kenji
participants (2)
-
Antonio Cuni
-
Kenji Yano