jeffreywugz / pyev

Automatically exported from code.google.com/p/pyev
0 stars 0 forks source link

Non-GCable objects in combination with SQLAlchemy #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When calling a SQLalchemy function from the event loop something gets messed up 
with the garbage collector.
This is easily seen in the echo server example by adding a __del__ method to 
the Connection class which simply displays a message

I've uploaded a small testcase to my pastebin:
https://paste.aeum.net/show/132/
When running it you'll see that only one of the two connection is deleted by 
the garbage collector. The issue also only occurs when both connections existed 
at the same time. In any case, the connection from which the query was sent is 
deleted fine, but the connection that simply existed at the same time is not 
deleted anymore once it's closed.

Original issue reported on code.google.com by adr...@planetcoding.net on 10 Aug 2012 at 6:45

GoogleCodeExporter commented 9 years ago
I'm far away from home and won't be able to really help before the beginning of 
September. Sorry about that.

As far as I can tell (without running your example) none of the connections 
should be deleted (they should be deleted when the server goes away and destroy 
the connections dictionary). That doesn't imply the watchers are still alive, 
those get cleared on connection close().

When you close the server (or after), are the connections still alive? If you 
want to delete the connections on close, I suggest you pass a ref to the server 
to each connection (on init) and delete the connection from the dictionary on 
close.

Original comment by lekma...@gmail.com on 13 Aug 2012 at 5:04

GoogleCodeExporter commented 9 years ago
Even without storing the connections in the dict the thing happens. Everything 
works fine with non-parallel connections or parallel connections without any 
calls to SA.

Original comment by adr...@planetcoding.net on 13 Aug 2012 at 5:53