> Currently, I create a single instance of my "persistence layer API", > which makes a call to global_connect(), and optionally to > default_metadata.create_all() (for tests). I then pass this instance > to all the threads that need to talk to my database.
global_connect() uses a DynamicMetadata, which is thread-specific: you need to define it each time a new thread is created. Depending on the architecture, you might want to add a func called on each thread (eg. on_start_thread_list within cherrypy,...) which will do the job. It would look like (not tested): import sqlalchemy as sa # blabla def init_thread(): if sa.default_metadata.is_bound(): pass # ok, thread is already init' else: sa.global_connect() # assert sa.default_metadata.is_bound() == True Hope that helps. Cheers Seb -- Sébastien LELONG sebastien.lelong[at]sirloon.net http://www.sirloon.net http://sirbot.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---