Skip to content

Commit

Permalink
Merge pull request #74 from Qabel/m/tp
Browse files Browse the repository at this point in the history
fix leak of redis fildes + monitoring
  • Loading branch information
enkore authored Jan 15, 2017
2 parents f503335 + 1c2225e commit e9198f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/blockserver/backend/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ async def redis(self):
if not self._redis:
loop = ioloop.IOLoop.current().asyncio_loop
self._redis = await aioredis.create_redis((self.host, self.port), loop=loop)
monitoring.PUBSUB_OPEN_CONNECTIONS.inc()
return self._redis

async def close(self):
(await self.redis()).close()
monitoring.PUBSUB_OPEN_CONNECTIONS.dec()

async def subscribe(self, channel, wildcard=False):
if wildcard:
Expand Down
3 changes: 3 additions & 0 deletions src/blockserver/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
PUBSUB_PUBLISHED = Counter('pubsub_published',
'Messages published via pubsub')

PUBSUB_OPEN_CONNECTIONS = Gauge('pubsub_connections',
'Open connections to the pubsub broker (normally redis)')


def time(metric):
@asyncio.coroutine
Expand Down
1 change: 1 addition & 0 deletions src/blockserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def delete(self, prefix, file_path):
'prefix': prefix,
'path': path,
})
yield pubsub.close()
self.finish()

def on_finish(self):
Expand Down

0 comments on commit e9198f2

Please sign in to comment.