Skip to content

Commit 62a1721

Browse files
authored
Merge pull request #809 from deniszh/backport/1.1.x/pr-806_pr-806_pr-806_pr-808
[1.1.x] import setUpRandomResolver only for new Twisted | Keeping it simple | spacing | Taming E501 in linter
2 parents d94ab87 + 77eb5d1 commit 62a1721

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/carbon/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from carbon.util import pickle
1313
from carbon.util import PluginRegistrar
1414
from carbon.util import enableTcpKeepAlive
15-
from carbon.resolver import setUpRandomResolver
1615
from carbon import instrumentation, log, pipeline, state
1716

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

31+
try:
32+
from carbon.resolver import setUpRandomResolver
33+
except ImportError:
34+
setUpRandomResolver = None
35+
3236

3337
SEND_QUEUE_LOW_WATERMARK = settings.MAX_QUEUE_SIZE * settings.QUEUE_LOW_WATERMARK_PCT
3438

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

533541
self.router = router
534542
self.client_factories = {} # { destination : CarbonClientFactory() }

0 commit comments

Comments
 (0)