psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway
来源:互联网 发布:windows tracert 多个 编辑:程序博客网 时间:2024/06/14 15:15
psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway
Temporary solution - close connection, if error happened in it. For it, let's create class inspired by momoko.Op
:
class OpWithFallback(gen.Task): """ Run a single asynchronous operation. Behaves like `tornado.gen.Task`_, but raises an exception (one of Psycop2's exceptions_) when an error occurs related to Psycopg2 or PostgreSQL. Closes connection with error. .. _exceptions: http://initd.org/psycopg/docs/module.html#exceptions .. _tornado.gen.Task: http://www.tornadoweb.org/documentation/gen.html#tornado.gen.Task """ def get_result(self): (result, error), _ = super(OpWithFallback, self).get_result() if error: self.fallback(error, result) return result def fallback(self, error, result): log.warning('Closing dead connection or connection with idle transaction: %s' % result.connection) result.connection.close() raise error
And let's use it like:
result = yield OpWithFallback(self.db.execute, sql, [])
0 0
- psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway
- DB Query Analyzer 6.01 is released, SQL Execute Schedule function can be used
- The context cannot be used while the model is being created
- Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
- Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
- OUI-10022:The target area /oracle/oraInventory cannot be used because it is in an invalid state.
- All CUDA devices are used for display and cannot be used while debugging.
- Development cannot be enabled while your device is locked.
- Development cannot be enabled while your device is locked.
- Development cannot be enabled while your device is locked.
- Development cannot be enabled while your device is locked.
- PLS-00363: expression 'v_s' cannot be used as an assignment target
- 屏蔽Slow network is detected. Fallback font will be used while loading: http://font-path.extension
- google浏览器 屏蔽 Slow network is detected. Fallback font will be used while loading
- Chrome控制台提示“Slow network is detected. Fallback font will be used while loading”
- ORA-20782: Cannot DROP object used in Oracle GoldenGate replication while trigger is enabled
- What is an abstract class, and when should it be used?
- ORA-10485: Real-Time Query cannot be enabled while applying migration redo
- php变量什么情况下加大括号{}
- Objective-C NSString NSData Byte CGFloat等转换
- 智图—源于QQ空间图片WebP化的思考
- linux组管理
- 一个懒得程序员才是一个好的程序员
- psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway
- String.intern方法
- struts2框架——奇怪的报错
- android的样式(style)与主题(theme)
- 黑马程序员-------IO流(字节流,字符流)
- 为iPhone 6设计自适应布局
- 常用的CSS命名规则
- 实现客户端主页的菜单和切换效果
- UIButton实现setBackgroundColor:ForState功能