python - "Sometimes" getting an InterfaceError on PostgreSQL with Peewee ORM -
i'm building website using python flask framework , peewee orm postgresql 9.3. far things going pretty well, run trouble. interfaceerror: connection closed
. code on follows:
pendingorders_q = customerorder\ .select()\ .where(customerorder.status == customerorder.status_pending)\ .where(customerorder.expiration < datetime.utcnow()) if len(list(pendingorders_q)) > 0: # stuff here..
i know way of counting number of results pretty nasty, don't know other ways of doing it. also, works, gives error below. don't understand why works fine, gives error. know whats going on here?
file "/home/kramer65/xs/app/order_management.py", line 210, in checkexpiration if len(list(pendingorders_q)) > 0: file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1988, in __iter__ return iter(self.execute()) file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1981, in execute self._qr = resultwrapper(model_class, self._execute(), query_meta) file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1698, in _execute return self.database.execute_sql(sql, params, self.require_commit) file "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 251, in execute_sql self.commit() file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2104, in __exit__ reraise(new_type, new_type(*exc_value.args), traceback) file "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 242, in execute_sql cursor = self.get_cursor() file "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 229, in get_cursor return self.get_conn().cursor(name=name) interfaceerror: connection closed
[edit] following error line:
traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/apscheduler/scheduler.py", line 512, in _run_job retval = job.func(*job.args, **job.kwargs) file "/home/kramer65/xs/app/order_management.py", line 207, in checkfordetails order in paidinorders_q: file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1411, in next obj = self.iterate() file "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1392, in iterate row = self.cursor.fetchone() interfaceerror: cursor closed
Comments
Post a Comment