{"action":"created","issue":{"url":"https://api.github.com/repos/bear/python-twitter/issues/214","labels_url":"https://api.github.com/repos/bear/python-twitter/issues/214/labels{/name}","comments_url":"https://api.github.com/repos/bear/python-twitter/issues/214/comments","events_url":"https://api.github.com/repos/bear/python-twitter/issues/214/events","html_url":"https://github.com/bear/python-twitter/pull/214","id":57817165,"number":214,"title":"Fix race condition in _InitializeRootDirectory","user":{"login":"dzuelke","id":27900,"avatar_url":"https://avatars.githubusercontent.com/u/27900?v=3","gravatar_id":"","url":"https://api.github.com/users/dzuelke","html_url":"https://github.com/dzuelke","followers_url":"https://api.github.com/users/dzuelke/followers","following_url":"https://api.github.com/users/dzuelke/following{/other_user}","gists_url":"https://api.github.com/users/dzuelke/gists{/gist_id}","starred_url":"https://api.github.com/users/dzuelke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzuelke/subscriptions","organizations_url":"https://api.github.com/users/dzuelke/orgs","repos_url":"https://api.github.com/users/dzuelke/repos","events_url":"https://api.github.com/users/dzuelke/events{/privacy}","received_events_url":"https://api.github.com/users/dzuelke/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-16T15:27:33Z","updated_at":"2015-02-16T16:33:45Z","closed_at":"2015-02-16T16:33:34Z","pull_request":{"url":"https://api.github.com/repos/bear/python-twitter/pulls/214","html_url":"https://github.com/bear/python-twitter/pull/214","diff_url":"https://github.com/bear/python-twitter/pull/214.diff","patch_url":"https://github.com/bear/python-twitter/pull/214.patch"},"body":"When running e.g. gunicorn, sometimes the worker processes concurrently check for the tmp dir and then both attempt to create it:\r\n\r\n```\r\n[2015-02-16 15:01:46 +0000] [14] [ERROR] Exception in worker process:\r\nTraceback (most recent call last):\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py\", line 503, in spawn_worker\r\n    worker.init_process()\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py\", line 116, in init_process\r\n    self.wsgi = self.app.wsgi()\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py\", line 67, in wsgi\r\n    self.callable = self.load()\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py\", line 65, in load\r\n    return self.load_wsgiapp()\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py\", line 52, in load_wsgiapp\r\n    return util.import_app(self.app_uri)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py\", line 355, in import_app\r\n    __import__(module)\r\n  File \"/app/app.py\", line 1, in <module>\r\n    from tweety import app\r\n  File \"/app/tweety/__init__.py\", line 7, in <module>\r\n    from tweety import routes\r\n  File \"/app/tweety/routes/__init__.py\", line 8, in <module>\r\n    api=twitter.Api(consumer_key=configuration['consumer_key'], consumer_secret=configuration['consumer_secret'], access_token_key=configuration['access_token_key'], access_token_secret=configuration['access_token_secret'])\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/twitter/api.py\", line 160, in __init__\r\n    self.SetCache(cache)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/twitter/api.py\", line 3286, in SetCache\r\n    self._cache = _FileCache()\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/twitter/_file_cache.py\", line 15, in __init__\r\n    self._InitializeRootDirectory(root_directory)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/twitter/_file_cache.py\", line 78, in _InitializeRootDirectory\r\n    os.mkdir(root_directory)\r\nOSError: [Errno 17] File exists: '/tmp/python.cache_nobody'\r\n```\r\n\r\nThis change prevents exceptions on existing dirs, but lets all other error cases bubble up."},"comment":{"url":"https://api.github.com/repos/bear/python-twitter/issues/comments/74535461","html_url":"https://github.com/bear/python-twitter/pull/214#issuecomment-74535461","issue_url":"https://api.github.com/repos/bear/python-twitter/issues/214","id":74535461,"user":{"login":"bear","id":1267,"avatar_url":"https://avatars.githubusercontent.com/u/1267?v=3","gravatar_id":"","url":"https://api.github.com/users/bear","html_url":"https://github.com/bear","followers_url":"https://api.github.com/users/bear/followers","following_url":"https://api.github.com/users/bear/following{/other_user}","gists_url":"https://api.github.com/users/bear/gists{/gist_id}","starred_url":"https://api.github.com/users/bear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bear/subscriptions","organizations_url":"https://api.github.com/users/bear/orgs","repos_url":"https://api.github.com/users/bear/repos","events_url":"https://api.github.com/users/bear/events{/privacy}","received_events_url":"https://api.github.com/users/bear/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T16:33:45Z","updated_at":"2015-02-16T16:33:45Z","body":"thanks for reporting and fixing this issue!"}}