X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=daklib%2Fdbconn.py;h=6cd84de3f30da9fe9c93167c9954b17929dbc8d1;hb=783e9564f8747a8939404746d13a6ba9318e17d7;hp=1bf5a0f997c7bb84aa5821aa4f9ab3c074ec3422;hpb=144898960af3c564c0a93203cafff457636d2163;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 1bf5a0f9..6cd84de3 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -59,7 +59,7 @@ import sqlalchemy from sqlalchemy import create_engine, Table, MetaData, Column, Integer, desc, \ Text, ForeignKey from sqlalchemy.orm import sessionmaker, mapper, relation, object_session, \ - backref, MapperExtension, EXT_CONTINUE, object_mapper + backref, MapperExtension, EXT_CONTINUE, object_mapper, clear_mappers from sqlalchemy import types as sqltypes # Don't remove this, we re-export the exceptions to scripts which import us @@ -3198,6 +3198,15 @@ class DBConn(object): def session(self): return self.db_smaker() + def reset(self): + ''' + Resets the DBConn object. This function must be called by subprocesses + created by the multiprocessing module. See tests/dbtest_multiproc.py + for an example. + ''' + clear_mappers() + self.__createconn() + __all__.append('DBConn')