Cool - thanks. I hadn't seen the addShutdownHandler() method

Has this been added to the CVS??

Mike
On Monday, December 2, 2002, at 01:11  PM, Ken Lalonde wrote:

What I did was add a hook to MiscUtils/DBPool.py
to shut down the pool's connections:

	--- /tmp/Webware/MiscUtils/DBPool.py	Sat Mar 30 23:19:07 2002
	+++ ./DBPool.py	Wed Oct  9 18:01:26 2002
	@@ -86,10 +86,16 @@
	
			# @@ 2000-12-04 ce: Should we really make all the connections now?
			# Couldn't we do this on demand?
	+		self._cons = []
			for i in range(maxConnections):
				con = apply(dbModule.connect, args, kwargs)
				self.addConnection(con)
	+			self._cons.append(con)
	
	+	def shutDown(self):
	+		for con in self._cons:
	+			try: con.close()
	+			except: pass
	
When you create your DBPool instance, typically in contextInitialize(),
arrange to have pool.shutDown() called at application shutdown.
I find it convenient to make the pool an attribute of the
current application:

	def contextInitialize(app, contextDir):
		...
		app._dbpool = DBPool(...)
		app.addShutDownHandler(app._dbpool.shutDown)


-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to