Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Using flask-rq with flask-sqlalchemy occasionally raise ResourceClosedError #30

Open
jkryanchou opened this issue Nov 3, 2017 · 0 comments

Comments

@jkryanchou
Copy link

jkryanchou commented Nov 3, 2017

Recently, I run the flask rq-worker with the flask-sqlalchemy in order to do some model operations by async-task in the worker. While it occasionally raised the Error

ResourceClosedError: This result object does not return rows. It has been closed automatically.

I don't know what happen to the worker cause the issue. I could not reproduce the error and have searched for a long time on the problem. While get nothing solution on it.

I wonder if any examples on flask-rq worked with flask-sqlalchemy? Here are the code snippets my own.

if __name__ == '__main__':
    with app.app_context():
        QUEUE = get_queue()
        worker = get_worker()
        worker.push_exc_handler(retry_handler)
        worker.work()

And the async task

@job
def async_restart_task(task_id):
    creating_info = {"status": TaskStatus.Creating}  # NOTE: Reset created_at ?
    task = TaskModel.update_task(task_id, creating_info)

    task = TaskModel.get_task_by_id(task_id)
    service = get_service(task.service)

    for jobs in iter_group(10, service.gen_jobs(task)):
        JobModel.add_jobs(jobs)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant