Ian Bicking said:
> Sessions can be accessed from multiple threads, though usually that
> would only happen when a browser was downloading dependent files (e.g.,
> images), that were also served off WebKit. But you still don't want to
> put these in the session, because they aren't pickleable, and the
> session persists over restarts by using pickle.
> You should either be able to use DBPool (or something like it), or do
> some other simple resource sharing. Lists work better than you might
> _storage =3D 
> def getResource():
> return _storage.pop()
> except IndexError:
> return makeNewResource()
> def returnResource(rsrc):
> .append and .pop are threadsafe (enough) so it's pretty simple to
I'm not sure if we have made it clear that regardless of what "pooling"
method you use, the variable that stores the reference to the pool should
be defined at either the module level or class level, not at the instance
level. This insures that only a single instance of the pool exists for
the entire python process.
The above example is of a module level pool referenced by the "_storage"
Here is an example of the pool reference at the class level:
# Do this, since it creates a class variable.
_storage =3D 
def __init__(self, ...):
# Don't do this, since it creates an instance variable.
#self._storage =3D 
def returnResource(self, rsrc):
The choice of pooling method and where you put the reference to the pool
depends on your application.