[Twisted-Python] adbapi,adodbapi and pythoncom.CoInitialize()
dave at krondo.com
Mon Jun 14 21:00:27 EDT 2004
I think that is a good solution. I've used something similar on occasion.
Note that if you create the connection pool after the reactor has started,
you may need to stop the old threadpool.
---- Original Message ----
From: Andrew Bennetts
Date: Mon 6/14/04 17:45
To: Twisted discussion stuff
Subject: Re: [Twisted-Python] adbapi,adodbapi and pythoncom.CoInitialize()
On Mon, Jun 14, 2004 at 05:47:45PM -0600, Craig H. Anderson wrote:
> I would like to use adbapi with the com based adodbapi.
> I found that the connect call hangs unless I add a call
> to pythoncom.CoInitialize().
That doesn't surprise me, seeing as adbapi runs stuff in threads to make it
asynchronous, and COM requires each thread that uses COM stuff to be
I'm not sure how to cleanly arrange for that to happen, though. Perhaps
from twisted.python import threadpool
from twisted.enterprise import adbapi
def _worker(self, o):
def __init__(self, dbapiName, *args, **kwargs):
adbapi.ConnectionPool.__init__(self, dbapiName, *args, **kwargs)
self.threadpool = COMThreadPool(self.min, self.max)
Then use COMConnectionPool rather than adbapi.ConnectionPool.
More information about the Twisted-Python