I'm running web service using sqlalchemy with apache + wsgi + pyramid 
framework.
I've initialize metadata like the following:

Base = declarative_base()
Base.metadata.reflect(bind=my_engine)
user_table = DP_Base.metadata.tables["user"]
mapper(User, user_table)

and I'm using scoped session since I'm running apache+wsgi with multiple 
processes and threads.
weird thing is that, errors occur sometimes saying

ArgumentError: Class '<class 'mypackage.User'>' already has a primary 
mapper defined. Use non_primary=True to create a non primary Mapper.  
clear_mappers() will remove *all* current mappers from all classes.

Once the error occurs, all the following requests to the web service 
encounter the same errors. Restarting httpd  seems to resolve the problem 
temporarily.

I'm afraid that I'm using reflection and mapping in the wrong way? or Is 
there something that I have to care about among multi-threaded, scoped 
session, and table mapping?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/TuEWdqXlg6EJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to