[Web-SIG] [DB-SIG] WSGI thread affinity/interleaving
mal at egenix.com
Mon Dec 19 15:17:51 CET 2005
James Y Knight wrote:
> On Dec 18, 2005, at 6:57 PM, M.-A. Lemburg wrote:
>> Ian Bicking wrote:
>>> James Y Knight wrote:
>>>> I'm worried about database access. Most DBAPI adapters have
>>>> threadsafety level 2: "Threads may share the module and
>>>> connections.". So with those, at least, it should be fine to move a
>>>> connection between threads, since "share OK" implies "move OK".
>> What exactly do you mean with "move" ? Sharing a
>> connection refers to multiple threads creating cursors
>> on this connection.
> I'm asking about moving a cursor, that is, accessing it sequentially
> first from one thread, then later from another thread. This is
> potentially asking less than sharing, that is, accessing it
> simultaneously from two threads.
> For example, a simple class without any locking, that only modifies
> itself, would generally be movable between threads, but not sharable.
> Adding a mutex would make it both.
Ok. In that sense, I think "moving" is not really possible
with database connections or cursors: these always rely on
external resources and these may be relying on having the
same thread context around when being called.
Why would you want to "move" cursors or connections around ?
Professional Python Services directly from the Source (#1, Dec 19 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Web-SIG