Running instance methods or objects in RQ?

So, RQ explicitly states that I can enqueue the object instance method here , so I tried to do this, but a PicklingError:

q.enqueue(some_obj.some_func, some_data)
*** PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

Indeed, I just need access to the SQL connection in my method, so I tried to just make it a function that explicitly uses the SQL connection. This doesn't work either:

q.enqueue(some_func, sql_sess, some_data)
*** PicklingError: Can't pickle <class 'sqlalchemy.orm.session.Session'>: it not the same object as sqlalchemy.orm.session.Session

How do I get around this? Am I doing something wrong, or is the library just broken?

+4
source share

Source: https://habr.com/ru/post/1608586/


All Articles