Add a few extra docstring comments about thread-safe clients/connections
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user