summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@rd.io>2015-06-08 17:25:45 -0700
committerDana Powers <dana.powers@rd.io>2015-06-08 18:59:23 -0700
commit0dc6663d24f6b9386ac2119a4a11836391e5da65 (patch)
tree47a2fa30bfa32a4714c74afa2989944bcb86e56a
parentc0fb0de7c4ced45dae4e09cdc660ebc741e11af3 (diff)
downloadkafka-python-0dc6663d24f6b9386ac2119a4a11836391e5da65.tar.gz
Add a few extra docstring comments about thread-safe clients/connections
-rw-r--r--kafka/client.py7
-rw-r--r--kafka/conn.py8
-rw-r--r--kafka/producer/base.py2
3 files changed, 12 insertions, 5 deletions
diff --git a/kafka/client.py b/kafka/client.py
index 63c9073..20e20f2 100644
--- a/kafka/client.py
+++ b/kafka/client.py
@@ -254,8 +254,11 @@ class KafkaClient(object):
def copy(self):
"""
- Create an inactive copy of the client object
- A reinit() has to be done on the copy before it can be used again
+ Create an inactive copy of the client object, suitable for passing
+ to a separate thread.
+
+ Note that the copied connections are not initialized, so reinit() must
+ be called on the returned copy.
"""
c = copy.deepcopy(self)
for key in c.conns:
diff --git a/kafka/conn.py b/kafka/conn.py
index 7a49d8c..432e10b 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -161,9 +161,11 @@ class KafkaConnection(local):
def copy(self):
"""
- Create an inactive copy of the connection object
- A reinit() has to be done on the copy before it can be used again
- return a new KafkaConnection object
+ Create an inactive copy of the connection object, suitable for
+ passing to a background thread.
+
+ The returned copy is not connected; you must call reinit() before
+ using.
"""
c = copy.deepcopy(self)
# Python 3 doesn't copy custom attributes of the threadlocal subclass
diff --git a/kafka/producer/base.py b/kafka/producer/base.py
index 18af342..e0c086b 100644
--- a/kafka/producer/base.py
+++ b/kafka/producer/base.py
@@ -206,6 +206,8 @@ class Producer(object):
Arguments:
client (KafkaClient): instance to use for broker communications.
+ If async=True, the background thread will use client.copy(),
+ which is expected to return a thread-safe object.
codec (kafka.protocol.ALL_CODECS): compression codec to use.
req_acks (int, optional): A value indicating the acknowledgements that
the server must receive before responding to the request,