Commit 98fa36ca authored by Denis Bilenko's avatar Denis Bilenko

resolver_ares: configuration by os.environ

resolver_ares.Resolver: if use_environ is True (default) then
kwargs is default-set from the environment: parameter xxx is set from
variable GEVENTARES_XXX (servers -> GEVENTARES_SERVERS)
parent 0b94b787
......@@ -15,7 +15,7 @@ class Resolver(object):
ares_class = channel
def __init__(self, hub=None, use_threadpool=True, **kwargs):
def __init__(self, hub=None, use_threadpool=True, use_environ=True, **kwargs):
if hub is None:
hub = get_hub()
self.hub = hub
......@@ -26,6 +26,13 @@ class Resolver(object):
self.pool = self.hub.threadpool
else:
self.pool = None
if use_environ:
for key in os.environ.iterkeys():
if key.startswith('GEVENTARES_'):
name = key[11:].lower()
if name:
value = os.environ[key]
kwargs.setdefault(name, value)
self.ares = self.ares_class(hub.loop, **kwargs)
self.pid = os.getpid()
self.params = kwargs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment