Hi list, I've been getting ResoruceClosedError with MySQL server, which worked fine with SQLite. I'am using Celery queue, and those erros always happen within the celery tasks.
@celery.task def do_something(): records = SomeTable.pop_timeout() .... and for SomeTable.pop_timeout(), the pop_timeout method is as follows: class SomeTable(DeclarativeBase): ... def pop_timeout(klass): stamp = str(time()) now = time() klass.query(klass).filter((klass.transtamp == None) & (now - klass.timestamp > TIMEOUT)).update({'transtamp': stamp}) klass.commit() records = klass.get_by(transtamp=stamp, order_by=order_by, eager=eager) klass.delete_by(transtamp=stamp) klass.commit() return records And the tracebak is: caches = ImageCache.pop_timeout() File "/home/aitjcize/Work/shotwill/shotwill/backend/database.py", line 1081, i n pop_timeout now - ImageCache.timestamp >= app.config['IMAGE_CACHE_TIMEOUT'] File "/home/aitjcize/Work/shotwill/shotwill/backend/database.py", line 226, in pop records = klass.get_by(transtamp=stamp, order_by=order_by, eager=eager) File "/home/aitjcize/Work/shotwill/shotwill/backend/database.py", line 204, in get_by return query_object.all() File "/home/aitjcize/Work/shotwill/python/SQLAlchemy-0.7.2-py2.7- linux-x86_64. egg/sqlalchemy/orm/query.py", line 1729, in all return list(self) File "/home/aitjcize/Work/shotwill/python/SQLAlchemy-0.7.2-py2.7- linux-x86_64. egg/sqlalchemy/orm/query.py", line 1953, in instances fetch = cursor.fetchall() File "/home/aitjcize/Work/shotwill/python/SQLAlchemy-0.7.2-py2.7- linux-x86_64. egg/sqlalchemy/engine/base.py", line 2979, in fetchall l = self.process_rows(self._fetchall_impl()) File "/home/aitjcize/Work/shotwill/python/SQLAlchemy-0.7.2-py2.7- linux-x86_64. egg/sqlalchemy/engine/base.py", line 2948, in _fetchall_impl self._non_result() File "/home/aitjcize/Work/shotwill/python/SQLAlchemy-0.7.2-py2.7- linux-x86_64. egg/sqlalchemy/engine/base.py", line 2953, in _non_result "This result object does not return rows. " ResourceClosedError: This result object does not return rows. It has been closed automatically. Does anyone has any idea what is going on? It only happen when using mysql. And another thing, because there maybe multiple worker executing the same celery task at the same time, so the pop_timeout() function is what I came up with. Is there a better solution for popping records from a database? Thanks in advance. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.