Skip to content

Commit

Permalink
Merge pull request #809 from deniszh/backport/1.1.x/pr-806_pr-806_pr-…
Browse files Browse the repository at this point in the history
…806_pr-808

[1.1.x] import setUpRandomResolver only for new Twisted | Keeping it simple | spacing | Taming E501 in linter
  • Loading branch information
deniszh authored Sep 3, 2018
2 parents d94ab87 + 77eb5d1 commit 62a1721
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/carbon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from carbon.util import pickle
from carbon.util import PluginRegistrar
from carbon.util import enableTcpKeepAlive
from carbon.resolver import setUpRandomResolver
from carbon import instrumentation, log, pipeline, state

try:
Expand All @@ -29,6 +28,11 @@
except ImportError:
log.debug("Couldn't import signal module")

try:
from carbon.resolver import setUpRandomResolver
except ImportError:
setUpRandomResolver = None


SEND_QUEUE_LOW_WATERMARK = settings.MAX_QUEUE_SIZE * settings.QUEUE_LOW_WATERMARK_PCT

Expand Down Expand Up @@ -528,7 +532,11 @@ def __init__(self, router):
# If we decide to open multiple TCP connection to a replica, we probably
# want to try to also load-balance accross hosts. In this case we need
# to make sure rfc3484 doesn't get in the way.
setUpRandomResolver(reactor)
if setUpRandomResolver:
setUpRandomResolver(reactor)
else:
print("Import error, Twisted >= 17.1.0 needed for using DESTINATION_POOL_REPLICAS.")
raise SystemExit(1)

self.router = router
self.client_factories = {} # { destination : CarbonClientFactory() }
Expand Down

0 comments on commit 62a1721

Please sign in to comment.