I'm getting an error on my Flask app using SQLAlchemy (flask.ext.sqlalchemy) and Postgres. The error doesn't happen consistently, it only happens every few requests. After some research, it appeared it could be related to mismanagement of sessions, but I think Flask-SQLAlchemy is supposed to take care of that. I've never seen this locally or with my other apps.
2016-02-29 12:22:18,429 : File "/home/mritchie712/bhApp/run.py", line 459, in get_tasks
2016-02-29 12:22:18,430 : uId = current_user.id
2016-02-29 12:22:18,430 : File "/home/mritchie712/.local/lib/python2.7/site-packages/werkzeug/local.py", line 336, in __getattr__
2016-02-29 12:22:18,432 : return getattr(self._get_current_object(), name)
2016-02-29 12:22:18,432 : File "/home/mritchie712/.local/lib/python2.7/site-packages/werkzeug/local.py", line 295, in _get_current_object
2016-02-29 12:22:18,432 : return self.__local()
2016-02-29 12:22:18,432 : File "/home/mritchie712/.local/lib/python2.7/site-packages/flask_login.py", line 46, in <lambda>
2016-02-29 12:22:18,433 : current_user = LocalProxy(lambda: _get_user())
2016-02-29 12:22:18,433 : File "/home/mritchie712/.local/lib/python2.7/site-packages/flask_login.py", line 794, in _get_user
2016-02-29 12:22:18,434 : current_app.login_manager._load_user()
2016-02-29 12:22:18,434 : File "/home/mritchie712/.local/lib/python2.7/site-packages/flask_login.py", line 363, in _load_user
2016-02-29 12:22:18,435 : return self.reload_user()
2016-02-29 12:22:18,435 : File "/home/mritchie712/.local/lib/python2.7/site-packages/flask_login.py", line 325, in reload_user
2016-02-29 12:22:18,435 : user = self.user_callback(user_id)
2016-02-29 12:22:18,436 : File "/home/mritchie712/bhApp/run.py", line 331, in load_user
2016-02-29 12:22:18,436 : return AppUsers.query.filter_by(email=email).first()
2016-02-29 12:22:18,436 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2341, in first
2016-02-29 12:22:18,438 : ret = list(self[0:1])
2016-02-29 12:22:18,439 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2208, in __getitem__
2016-02-29 12:22:18,439 : return list(res)
2016-02-29 12:22:18,440 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 66, in instances
2016-02-29 12:22:18,440 : fetch = cursor.fetchall()
2016-02-29 12:22:18,441 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 787, in fetchall
2016-02-29 12:22:18,442 : self.cursor, self.context)
2016-02-29 12:22:18,442 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1163, in _handle_dbapi_exception
2016-02-29 12:22:18,443 : util.reraise(*exc_info)
2016-02-29 12:22:18,445 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 781, in fetchall
2016-02-29 12:22:18,445 : l = self.process_rows(self._fetchall_impl())
2016-02-29 12:22:18,445 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 750, in _fetchall_impl
2016-02-29 12:22:18,446 : self._non_result()
2016-02-29 12:22:18,446 : File "/home/mritchie712/.local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 755, in _non_result
2016-02-29 12:22:18,447 : "This result object does not return rows. "
2016-02-29 12:22:18,447 :sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically.
2016-02-29 12:22:21,710 :IOError: write error