sqlalchemy 是非异步库

The "scope" in scoped_session is a thread, which makes it inappropriate for use in an asynchronous framework like Tornado. It's been a long time since I've used sqlalchemy sessions, but I think what you want to do is put a sessionmaker on the Application, and make a session from it in RequestHandler.prepare (not initialize - they're almost equivalent, but if something goes wrong you generally get nicer error pages from prepare).

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,136评论 0 10
  • 那是错过的时间(二) 我越看越被她的经历折服,她用不一样的人生,活出了更为通透的幸福生活!从那时候起,我才第...
    少东家_阅读 1,768评论 1 0
  • 匆匆又是一年元宵,人约黄昏后。 阳光很好,明亮迷人。梦云多年前相遇余荫,元宵节在此地逛花灯看月亮。那时候梦云一脸的...
    海深深阅读 1,774评论 0 0
  • 跟着小小、飞猪,我们开始了在拉萨惬意的日子。 开始几天,在青旅睡到自然醒,确实是自然醒;自然到早上7点醒,跟在路上...
    韦小露阅读 3,725评论 2 0