{"action":"created","issue":{"url":"https://api.github.com/repos/segmentio/analytics-python/issues/51","labels_url":"https://api.github.com/repos/segmentio/analytics-python/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/segmentio/analytics-python/issues/51/comments","events_url":"https://api.github.com/repos/segmentio/analytics-python/issues/51/events","html_url":"https://github.com/segmentio/analytics-python/issues/51","id":88856570,"number":51,"title":"Segment causing celery workers to hang in django","user":{"login":"gitumarkk","id":3369114,"avatar_url":"https://avatars.githubusercontent.com/u/3369114?v=3","gravatar_id":"","url":"https://api.github.com/users/gitumarkk","html_url":"https://github.com/gitumarkk","followers_url":"https://api.github.com/users/gitumarkk/followers","following_url":"https://api.github.com/users/gitumarkk/following{/other_user}","gists_url":"https://api.github.com/users/gitumarkk/gists{/gist_id}","starred_url":"https://api.github.com/users/gitumarkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitumarkk/subscriptions","organizations_url":"https://api.github.com/users/gitumarkk/orgs","repos_url":"https://api.github.com/users/gitumarkk/repos","events_url":"https://api.github.com/users/gitumarkk/events{/privacy}","received_events_url":"https://api.github.com/users/gitumarkk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-16T22:29:53Z","updated_at":"2016-01-21T19:28:26Z","closed_at":null,"body":"We use the django post save signal to trigger segment analytics tracking asynchronously using celery. However when multiple events (about 350 in 20 seconds) are created, all the celery workers hang up consistently at the following output.\r\n\r\n`[2015-06-12 22:41:34,245: INFO/Worker-2] Starting new HTTPS connection (1): api.segment.io\r\n[2015-06-12 22:41:34,574: DEBUG/Worker-2] \"POST /v1/batch HTTP/1.1\" 200 21\r\n[2015-06-12 22:41:34,578: DEBUG/Worker-2] data uploaded successfully`\r\n\r\nWhen the analytics tracking is commented out the workers function as expected. When the the celery rate limit is set to \"600/m\" the celery workers run without hanging. We have a celery hard time limit of 30 seconds to prevent segment from hanging. We found at a higher rate limit, the hard time limit was hit at high frequency and the analytics tracking was not sent through.\r\n\r\nNot sure why the segment library is causing this to happen, please advice."},"comment":{"url":"https://api.github.com/repos/segmentio/analytics-python/issues/comments/173682779","html_url":"https://github.com/segmentio/analytics-python/issues/51#issuecomment-173682779","issue_url":"https://api.github.com/repos/segmentio/analytics-python/issues/51","id":173682779,"user":{"login":"calvinfo","id":487539,"avatar_url":"https://avatars.githubusercontent.com/u/487539?v=3","gravatar_id":"","url":"https://api.github.com/users/calvinfo","html_url":"https://github.com/calvinfo","followers_url":"https://api.github.com/users/calvinfo/followers","following_url":"https://api.github.com/users/calvinfo/following{/other_user}","gists_url":"https://api.github.com/users/calvinfo/gists{/gist_id}","starred_url":"https://api.github.com/users/calvinfo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvinfo/subscriptions","organizations_url":"https://api.github.com/users/calvinfo/orgs","repos_url":"https://api.github.com/users/calvinfo/repos","events_url":"https://api.github.com/users/calvinfo/events{/privacy}","received_events_url":"https://api.github.com/users/calvinfo/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T19:28:26Z","updated_at":"2016-01-21T19:28:26Z","body":"Unfortunately I haven't gotten a chance to deeply investigate here.\n\nOne question though, how are you using celery (multiprocessing, eventlet,\ngevent)? Since the library itself does its own threading, there might be\nsome issues when used with other multi-threaded libraries. We keep one\nthread per client-instance (so it's non-blocking), so you won't want to\nconstantly create new clients in the workers.\n\nWe might move this to be a coroutine approach since other libraries might\nnot play nicely when it comes to the threading.\n\nOn Thu, Jan 21, 2016 at 2:16 AM, Christian Peters <notifications@github.com>\nwrote:\n\n> Updates?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/segmentio/analytics-python/issues/51#issuecomment-173525253>\n> .\n>\n"}}