Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

fix: kill dead_cache, it's no longer used #624

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions autopush/router/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
"""
import json
import requests
import time
from urllib import urlencode
from StringIO import StringIO

from boto.dynamodb2.exceptions import (
ItemNotFound,
ProvisionedThroughputExceededException,
)
from repoze.lru import LRUCache
from twisted.internet.threads import deferToThread
from twisted.internet.defer import (
inlineCallbacks,
Expand All @@ -36,14 +34,6 @@
)


dead_cache = LRUCache(150)


def node_key(node_id):
"""Generate a node key for the dead node cache"""
return node_id + "-%s" % int(time.time() / 3600)


class SimpleRouter(object):
"""Implements :class:`autopush.router.interface.IRouter` for internal
routing to an Autopush node
Expand Down Expand Up @@ -102,7 +92,6 @@ def route_notification(self, notification, uaid_data):
notification)
except (ConnectError, UserError, ConnectionRefusedError) as exc:
self.metrics.increment("updates.client.host_gone")
dead_cache.put(node_key(node_id), True)
yield deferToThread(router.clear_node,
uaid_data).addErrback(self._eat_db_err)
if isinstance(exc, ConnectionRefusedError):
Expand Down Expand Up @@ -159,7 +148,6 @@ def route_notification(self, notification, uaid_data):
result = yield self._send_notification_check(uaid, node_id)
except (ConnectError, UserError, ConnectionRefusedError) as exc:
self.metrics.increment("updates.client.host_gone")
dead_cache.put(node_key(node_id), True)
if isinstance(exc, ConnectionRefusedError):
self.log.debug("Could not route message: {exc}", exc=exc)
yield deferToThread(
Expand Down
10 changes: 0 additions & 10 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from autopush.router import (APNSRouter, GCMRouter,
SimpleRouter, WebPushRouter,
FCMRouter)
from autopush.router.simple import dead_cache
from autopush.router.interface import RouterException, RouterResponse, IRouter
from autopush.settings import AutopushSettings

Expand Down Expand Up @@ -724,9 +723,6 @@ def setUp(self):
settings.agent = self.agent_mock
self.router.metrics = Mock()

def tearDown(self):
dead_cache.clear()

def _raise_connect_error(self):
raise ConnectError()

Expand Down Expand Up @@ -861,7 +857,6 @@ def verify_deliver(result):
return d

def test_route_to_busy_node_saves_looks_up_and_send_check_fails(self):
import autopush.router.simple as simple
response_mock = Mock()
self.agent_mock.request.side_effect = MockAssist(
[response_mock, self._raise_connection_refused_error])
Expand All @@ -876,13 +871,10 @@ def verify_deliver(result):
ok_(isinstance(result, RouterResponse))
eq_(result.status_code, 202)
assert(self.router_mock.clear_node.called)
nk = simple.node_key(router_data["node_id"])
eq_(simple.dead_cache.get(nk), True)
d.addBoth(verify_deliver)
return d

def test_route_busy_node_saves_looks_up_and_send_check_fails_and_db(self):
import autopush.router.simple as simple
response_mock = Mock()
self.agent_mock.request.side_effect = MockAssist(
[response_mock, self._raise_connect_error])
Expand All @@ -900,8 +892,6 @@ def verify_deliver(result):
ok_(isinstance(result, RouterResponse))
eq_(result.status_code, 202)
assert(self.router_mock.clear_node.called)
nk = simple.node_key(router_data["node_id"])
eq_(simple.dead_cache.get(nk), True)
d.addBoth(verify_deliver)
return d

Expand Down
1 change: 0 additions & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pyflakes==1.2.3
python-dateutil==2.5.3
python-jose==0.6.1
raven==5.16.0
repoze.lru==0.6
requests==2.10.0
service-identity==16.0.0
simplejson==3.8.2
Expand Down
1 change: 0 additions & 1 deletion pypy-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pyflakes==1.2.3
python-dateutil==2.5.3
python-jose==0.6.1
raven==5.16.0
repoze.lru==0.6
requests==2.10.0
service-identity==16.0.0
simplejson==3.8.2
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pyflakes==1.2.3
python-dateutil==2.5.3
python-jose==0.6.1
raven==5.16.0
repoze.lru==0.6
requests==2.10.0
service-identity==16.0.0
simplejson==3.8.2
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pyflakes==1.2.3
python-dateutil==2.5.3
python-jose==0.6.1
raven==5.16.0
repoze.lru==0.6
requests==2.10.0
service-identity==16.0.0
simplejson==3.8.2
Expand Down