{"action":"created","issue":{"url":"https://api.github.com/repos/nvie/rq/issues/582","labels_url":"https://api.github.com/repos/nvie/rq/issues/582/labels{/name}","comments_url":"https://api.github.com/repos/nvie/rq/issues/582/comments","events_url":"https://api.github.com/repos/nvie/rq/issues/582/events","html_url":"https://github.com/nvie/rq/issues/582","id":107799708,"number":582,"title":"Can't enqueue instance methods","user":{"login":"EliFinkelshteyn","id":991121,"avatar_url":"https://avatars.githubusercontent.com/u/991121?v=3","gravatar_id":"","url":"https://api.github.com/users/EliFinkelshteyn","html_url":"https://github.com/EliFinkelshteyn","followers_url":"https://api.github.com/users/EliFinkelshteyn/followers","following_url":"https://api.github.com/users/EliFinkelshteyn/following{/other_user}","gists_url":"https://api.github.com/users/EliFinkelshteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/EliFinkelshteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EliFinkelshteyn/subscriptions","organizations_url":"https://api.github.com/users/EliFinkelshteyn/orgs","repos_url":"https://api.github.com/users/EliFinkelshteyn/repos","events_url":"https://api.github.com/users/EliFinkelshteyn/events{/privacy}","received_events_url":"https://api.github.com/users/EliFinkelshteyn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-22T20:52:46Z","updated_at":"2015-11-08T11:57:09Z","closed_at":"2015-11-08T11:57:09Z","body":"This is the same issue as https://github.com/nvie/rq/issues/189, which as far as I can tell was never solved. I need to enqueue a class method instead of just a regular function, and I get:\r\n\r\n```\r\nq.enqueue(rq_worker_wrapper.do_something_with_x, x)\r\n*** PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed\r\n```\r\n\r\nIs there a recommended way around this?\r\n\r\nI really need access to a SQLAlchemy session in the function I want to enqueue, but I can't even work around it by making the function accept that separately:\r\n\r\n```\r\nq.enqueue(some_func, sql_sess, some_data)\r\n*** PicklingError: Can't pickle <class 'sqlalchemy.orm.session.Session'>: it's not the same object as sqlalchemy.orm.session.Session\r\n```"},"comment":{"url":"https://api.github.com/repos/nvie/rq/issues/comments/154813074","html_url":"https://github.com/nvie/rq/issues/582#issuecomment-154813074","issue_url":"https://api.github.com/repos/nvie/rq/issues/582","id":154813074,"user":{"login":"selwin","id":188658,"avatar_url":"https://avatars.githubusercontent.com/u/188658?v=3","gravatar_id":"","url":"https://api.github.com/users/selwin","html_url":"https://github.com/selwin","followers_url":"https://api.github.com/users/selwin/followers","following_url":"https://api.github.com/users/selwin/following{/other_user}","gists_url":"https://api.github.com/users/selwin/gists{/gist_id}","starred_url":"https://api.github.com/users/selwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selwin/subscriptions","organizations_url":"https://api.github.com/users/selwin/orgs","repos_url":"https://api.github.com/users/selwin/repos","events_url":"https://api.github.com/users/selwin/events{/privacy}","received_events_url":"https://api.github.com/users/selwin/received_events","type":"User","site_admin":false},"created_at":"2015-11-08T11:57:09Z","updated_at":"2015-11-08T11:57:09Z","body":"We use Python's `pickle` to serialize data into Redis and `pickle` can't realiably pickle instance method. I suggest rewriting your function so that it doesn't take instance method as parameter."}}