{"action":"created","issue":{"url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/56","repository_url":"https://api.github.com/repos/metabrainz/listenbrainz-server","labels_url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/56/comments","events_url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/56/events","html_url":"https://github.com/metabrainz/listenbrainz-server/pull/56","id":111171006,"number":56,"title":"Create connections to external services on each flask request","user":{"login":"alastair","id":19217,"avatar_url":"https://avatars.githubusercontent.com/u/19217?v=3","gravatar_id":"","url":"https://api.github.com/users/alastair","html_url":"https://github.com/alastair","followers_url":"https://api.github.com/users/alastair/followers","following_url":"https://api.github.com/users/alastair/following{/other_user}","gists_url":"https://api.github.com/users/alastair/gists{/gist_id}","starred_url":"https://api.github.com/users/alastair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alastair/subscriptions","organizations_url":"https://api.github.com/users/alastair/orgs","repos_url":"https://api.github.com/users/alastair/repos","events_url":"https://api.github.com/users/alastair/events{/privacy}","received_events_url":"https://api.github.com/users/alastair/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2015-10-13T12:36:57Z","updated_at":"2016-07-19T15:15:30Z","closed_at":"2016-07-19T15:15:30Z","pull_request":{"url":"https://api.github.com/repos/metabrainz/listenbrainz-server/pulls/56","html_url":"https://github.com/metabrainz/listenbrainz-server/pull/56","diff_url":"https://github.com/metabrainz/listenbrainz-server/pull/56.diff","patch_url":"https://github.com/metabrainz/listenbrainz-server/pull/56.patch"},"body":"Instead of having a single connection open for the life of the\r\nserver, make a new connection to kafka and listenstore on each\r\nrequest (this was already the case for listenstore). Store\r\nthe connections in flask.g, as that's what it's designed for\r\n\r\nA kafka threaded example does basically the same thing: https://github.com/mumrah/kafka-python/blob/master/example.py, creating a connection and producer in each thread. As far as I'm aware, this is about the same kind of thing we get with multiple requests in flask.\r\n\r\nRenamed cassandra to listenstore, as it better reflects what we are connecting to. I removed the `from listenstore.listenstore import ...`, so we will then have to actually install listenstore into the virtualenv each time we update it. Either with `setup.py develop`, or we add an install command into `fab deploy`\r\n\r\nI've still not tested it, therefore marking as WIP.\r\n\r\nI'm unsure if any connections have to be closed after connections are shut down. There is a `producer.stop` method in kafka, so perhaps we should be calling this."},"comment":{"url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/comments/233665587","html_url":"https://github.com/metabrainz/listenbrainz-server/pull/56#issuecomment-233665587","issue_url":"https://api.github.com/repos/metabrainz/listenbrainz-server/issues/56","id":233665587,"user":{"login":"alastair","id":19217,"avatar_url":"https://avatars.githubusercontent.com/u/19217?v=3","gravatar_id":"","url":"https://api.github.com/users/alastair","html_url":"https://github.com/alastair","followers_url":"https://api.github.com/users/alastair/followers","following_url":"https://api.github.com/users/alastair/following{/other_user}","gists_url":"https://api.github.com/users/alastair/gists{/gist_id}","starred_url":"https://api.github.com/users/alastair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alastair/subscriptions","organizations_url":"https://api.github.com/users/alastair/orgs","repos_url":"https://api.github.com/users/alastair/repos","events_url":"https://api.github.com/users/alastair/events{/privacy}","received_events_url":"https://api.github.com/users/alastair/received_events","type":"User","site_admin":false},"created_at":"2016-07-19T15:15:30Z","updated_at":"2016-07-19T15:15:30Z","body":"nope!"}}
{"actor":{"display_login":"alastair"}}