sbmzhcn
2015-08-27 18:51:46 +08:00
Python gevent
'''
def get_session (scoped=False, engine=None, db_host=None, db_name=None, db_user=None, db_pass=None ):
if not engine:
engine = get_engine (db_host, db_name, db_user, db_pass )
session_factory = sessionmaker (
bind=engine,
autoflush=True,
autocommit=False,
)
if scoped:
ScopedSession = scoped_session (session_factory )
return ScopedSession
else:
return session_factory
Session = get_session (db_host=db_host, db_name=db_name, db_user=db_user, db_pass=db_pass )
session = Session ()
server = DebuggingServer ((HOST, PORT ), session=session )
server_thread = threading.Thread (target=server.serve_forever )
'''
这样写有啥问题?