On Sat, 2002-10-26 at 12:14, Edmund Lian wrote:
> I've been testing the autoreload feature, and it is very nice. I'm still
> getting used to the lightning fast responses as compared to OneShot!
> I do have a problem though... I have a module that exports a global
> database pool. On instantiation and subsequent first use, a bunch of
> persistent connections to one or more databases are opened. I notice
> however, that when the autoreload is triggered, a bunch of new connections
> is created (because the global db pool is being reinstantiated), but the
> old global pool persists. So, I'm leaking connections on a reload despite
> the global pool being a singleton.
> Is there a way to resolve this problem automatically, or will I have to
> register a shutdownhandler to explicitly delete the global pool instance?
Hmmm... I suspect your problem would be fixed if the file descriptors
representing your database connections had the close-on-exec flag set
(man fcntl for details).
It would be nice if the autoreload code could set all file descriptors
to close-on-exec before restarting, but I don't know if there's a way to
get a list of all open file descriptors. Anyone?
Jason D. Hildebrand