mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
Domainban: Use a global watch
This commit is contained in:
committed by
Neil Williams
parent
f3ff1c4f3b
commit
68d2bb9789
@@ -57,7 +57,7 @@ from r2.lib.plugin import PluginLoader
|
||||
from r2.lib.stats import Stats, CacheStats, StatsCollectingConnectionPool
|
||||
from r2.lib.translation import get_active_langs, I18N_PATH
|
||||
from r2.lib.utils import config_gold_price, thread_dump
|
||||
|
||||
from r2.lib.zookeeper import LiveDict
|
||||
|
||||
LIVE_CONFIG_NODE = "/config/live"
|
||||
|
||||
@@ -387,12 +387,16 @@ class Globals(object):
|
||||
self.throttles = LiveList(self.zookeeper, "/throttles",
|
||||
map_fn=ipaddress.ip_network,
|
||||
reduce_fn=ipaddress.collapse_addresses)
|
||||
self.banned_domains = LiveDict(self.zookeeper,
|
||||
"/banned-domains",
|
||||
watch=True)
|
||||
else:
|
||||
self.zookeeper = None
|
||||
parser = ConfigParser.RawConfigParser()
|
||||
parser.read([self.config["__file__"]])
|
||||
self.live_config = extract_live_config(parser, self.plugins)
|
||||
self.throttles = tuple() # immutable since it's not real
|
||||
self.banned_domains = dict()
|
||||
self.startup_timer.intermediate("zookeeper")
|
||||
|
||||
################# MEMCACHE
|
||||
|
||||
@@ -548,8 +548,7 @@ class Account(Thing):
|
||||
canons_by_subdomain[whole].extend(canons)
|
||||
parts.pop(0)
|
||||
|
||||
bans = LiveDict(g.zookeeper, "/banned-domains", watch=False)
|
||||
for subdomain, d in bans.iteritems():
|
||||
for subdomain, d in g.banned_domains.iteritems():
|
||||
if(d and d.get("no_email", None) and
|
||||
subdomain in canons_by_subdomain):
|
||||
for canon in canons_by_subdomain[subdomain]:
|
||||
|
||||
Reference in New Issue
Block a user