{"action":"created","issue":{"url":"https://api.github.com/repos/dchevell/flask-executor/issues/1","repository_url":"https://api.github.com/repos/dchevell/flask-executor","labels_url":"https://api.github.com/repos/dchevell/flask-executor/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/dchevell/flask-executor/issues/1/comments","events_url":"https://api.github.com/repos/dchevell/flask-executor/issues/1/events","html_url":"https://github.com/dchevell/flask-executor/issues/1","id":361654990,"node_id":"MDU6SXNzdWUzNjE2NTQ5OTA=","number":1,"title":"Flask request: RuntimeError: Working outside of request context.","user":{"login":"mrtarunjain","id":4311642,"node_id":"MDQ6VXNlcjQzMTE2NDI=","avatar_url":"https://avatars3.githubusercontent.com/u/4311642?v=4","gravatar_id":"","url":"https://api.github.com/users/mrtarunjain","html_url":"https://github.com/mrtarunjain","followers_url":"https://api.github.com/users/mrtarunjain/followers","following_url":"https://api.github.com/users/mrtarunjain/following{/other_user}","gists_url":"https://api.github.com/users/mrtarunjain/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtarunjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtarunjain/subscriptions","organizations_url":"https://api.github.com/users/mrtarunjain/orgs","repos_url":"https://api.github.com/users/mrtarunjain/repos","events_url":"https://api.github.com/users/mrtarunjain/events{/privacy}","received_events_url":"https://api.github.com/users/mrtarunjain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-19T09:20:29Z","updated_at":"2018-09-19T09:43:02Z","closed_at":null,"author_association":"NONE","body":"Environment:\r\nI am running a flask application on gunicorn with gevent workers.\r\nI am using flask's request variable in all the functions that I am calling through executor.\r\nI verified that package is using app.app_context wrapper in case of Thread.\r\nBut still it is not getting flask request variable.\r\nHow to pass request variable to other threads.\r\n\r\nPlease help."},"comment":{"url":"https://api.github.com/repos/dchevell/flask-executor/issues/comments/422731128","html_url":"https://github.com/dchevell/flask-executor/issues/1#issuecomment-422731128","issue_url":"https://api.github.com/repos/dchevell/flask-executor/issues/1","id":422731128,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjczMTEyOA==","user":{"login":"mrtarunjain","id":4311642,"node_id":"MDQ6VXNlcjQzMTE2NDI=","avatar_url":"https://avatars3.githubusercontent.com/u/4311642?v=4","gravatar_id":"","url":"https://api.github.com/users/mrtarunjain","html_url":"https://github.com/mrtarunjain","followers_url":"https://api.github.com/users/mrtarunjain/followers","following_url":"https://api.github.com/users/mrtarunjain/following{/other_user}","gists_url":"https://api.github.com/users/mrtarunjain/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtarunjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtarunjain/subscriptions","organizations_url":"https://api.github.com/users/mrtarunjain/orgs","repos_url":"https://api.github.com/users/mrtarunjain/repos","events_url":"https://api.github.com/users/mrtarunjain/events{/privacy}","received_events_url":"https://api.github.com/users/mrtarunjain/received_events","type":"User","site_admin":false},"created_at":"2018-09-19T09:43:02Z","updated_at":"2018-09-19T09:43:02Z","author_association":"NONE","body":"Gunicorn:\r\n```\r\nexec gunicorn app:app \\\r\n  --name $NAME \\\r\n  --workers $NUM_WORKERS \\\r\n  -k gevent \\\r\n  --bind=0.0.0.0:80 \\\r\n  --log-level=info \\\r\n  --access-logfile=- \\\r\n  --timeout=15 \\\r\n  --reload\r\n```\r\n\r\nIn Flask middleware I set current user id in request.\r\n```\r\n@app.before_request\r\ndef set_viewer_context():\r\n    request.current_user_id = 'some-id'\r\n```\r\n\r\nI am calling 1 API which internally calls 4 API(that can be executed concurrently).\r\nThese 4 API's needs current user id and it gets it from request variable.\r\n\r\nThough, I know I can do this if I start concurrent request after I have the current_user_id from request variable and then submitting this function to executor.\r\n\r\nBut is there a way where I can access current thread's request variable in the other thread?\r\n\r\n"}}
{"actor":{"display_login":"mrtarunjain"}}