Skip to content

Commit 6cc477d

Browse files
committed
Rename async -> asynchronous arguments (but keep async for now) confluentinc#21
1 parent 19365a0 commit 6cc477d

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

confluent_kafka/kafkatest/verifiable_consumer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def on_revoke(self, consumer, partitions):
9797
# Send final consumed records prior to rebalancing to make sure
9898
# latest consumed is in par with what is going to be committed.
9999
self.send_records_consumed(immediate=True)
100-
self.do_commit(immediate=True, async=False)
100+
self.do_commit(immediate=True, asynchronous=False)
101101
self.assignment = list()
102102
self.assignment_dict = dict()
103103
self.send_assignment('revoked', partitions)
@@ -133,7 +133,7 @@ def on_commit(self, err, partitions):
133133

134134
self.send(d)
135135

136-
def do_commit(self, immediate=False, async=None):
136+
def do_commit(self, immediate=False, asynchronous=None):
137137
""" Commit every 1000 messages or whenever there is a consume timeout
138138
or immediate. """
139139
if (self.use_auto_commit
@@ -146,10 +146,10 @@ def do_commit(self, immediate=False, async=None):
146146
if self.consumed_msgs_at_last_commit < self.consumed_msgs:
147147
self.send_records_consumed(immediate=True)
148148

149-
if async is None:
149+
if asynchronous is None:
150150
async_mode = self.use_async_commit
151151
else:
152-
async_mode = async
152+
async_mode = asynchronous
153153

154154
self.dbg('Committing %d messages (Async=%s)' %
155155
(self.consumed_msgs - self.consumed_msgs_at_last_commit,
@@ -159,7 +159,7 @@ def do_commit(self, immediate=False, async=None):
159159
while True:
160160
try:
161161
self.dbg('Commit')
162-
offsets = self.consumer.commit(async=async_mode)
162+
offsets = self.consumer.commit(asynchronous=async_mode)
163163
self.dbg('Commit done: offsets %s' % offsets)
164164

165165
if not async_mode:
@@ -300,7 +300,7 @@ def to_dict(self):
300300
vc.dbg('Closing consumer')
301301
vc.send_records_consumed(immediate=True)
302302
if not vc.use_auto_commit:
303-
vc.do_commit(immediate=True, async=False)
303+
vc.do_commit(immediate=True, asynchronous=False)
304304

305305
vc.consumer.close()
306306

confluent_kafka/src/Consumer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ Consumer_offset_commit_return_cb (rd_kafka_t *rk, rd_kafka_resp_err_t err,
369369

370370

371371
static PyObject *Consumer_commit (Handle *self, PyObject *args,
372-
PyObject *kwargs) {
373-
372+
PyObject *kwargs) {
374373
rd_kafka_resp_err_t err;
375374
PyObject *msg = NULL, *offsets = NULL, *async_o = NULL;
376375
rd_kafka_topic_partition_list_t *c_offsets;
377376
int async = 1;
378-
static char *kws[] = { "message", "offsets", "async",NULL };
377+
static char *kws[] = { "message", "offsets",
378+
"async", "asynchronous", NULL };
379379
rd_kafka_queue_t *rkqu = NULL;
380380
struct commit_return commit_return;
381381
PyThreadState *thread_state;
@@ -386,8 +386,8 @@ static PyObject *Consumer_commit (Handle *self, PyObject *args,
386386
return NULL;
387387
}
388388

389-
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO", kws,
390-
&msg, &offsets, &async_o))
389+
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO", kws,
390+
&msg, &offsets, &async_o, &async_o))
391391
return NULL;
392392

393393
if (msg && offsets) {
@@ -1123,7 +1123,7 @@ static PyMethodDef Consumer_methods[] = {
11231123
"\n"
11241124
},
11251125
{ "commit", (PyCFunction)Consumer_commit, METH_VARARGS|METH_KEYWORDS,
1126-
".. py:function:: commit([message=None], [offsets=None], [async=True])\n"
1126+
".. py:function:: commit([message=None], [offsets=None], [asynchronous=True])\n"
11271127
"\n"
11281128
" Commit a message or a list of offsets.\n"
11291129
"\n"
@@ -1133,14 +1133,14 @@ static PyMethodDef Consumer_methods[] = {
11331133
"\n"
11341134
" :param confluent_kafka.Message message: Commit message's offset+1.\n"
11351135
" :param list(TopicPartition) offsets: List of topic+partitions+offsets to commit.\n"
1136-
" :param bool async: Asynchronous commit, return None immediately. "
1136+
" :param bool asynchronous: Asynchronous commit, return None immediately. "
11371137
"If False the commit() call will block until the commit succeeds or "
11381138
"fails and the committed offsets will be returned (on success). Note that specific partitions may have failed and the .err field of each partition will need to be checked for success.\n"
11391139
" :rtype: None|list(TopicPartition)\n"
11401140
" :raises: KafkaException\n"
11411141
" :raises: RuntimeError if called on a closed consumer\n"
11421142
"\n"
1143-
},
1143+
},
11441144
{ "committed", (PyCFunction)Consumer_committed,
11451145
METH_VARARGS|METH_KEYWORDS,
11461146
".. py:function:: committed(partitions, [timeout=None])\n"

examples/integration_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def verify_avro():
308308
(msg.topic(), msg.partition(), msg.offset(),
309309
msg.key(), msg.value(), tstype, timestamp))
310310

311-
c.commit(msg, async=False)
311+
c.commit(msg, asynchronous=False)
312312

313313
# Close consumer
314314
c.close()
@@ -507,9 +507,9 @@ def print_wmark(consumer, parts):
507507

508508
if (msg.offset() % 5) == 0:
509509
# Async commit
510-
c.commit(msg, async=True)
510+
c.commit(msg, asynchronous=True)
511511
elif (msg.offset() % 4) == 0:
512-
offsets = c.commit(msg, async=False)
512+
offsets = c.commit(msg, asynchronous=False)
513513
assert len(offsets) == 1, 'expected 1 offset, not %s' % (offsets)
514514
assert offsets[0].offset == msg.offset()+1, \
515515
'expected offset %d to be committed, not %s' % \
@@ -679,9 +679,9 @@ def verify_batch_consumer():
679679

680680
if (msg.offset() % 5) == 0:
681681
# Async commit
682-
c.commit(msg, async=True)
682+
c.commit(msg, asynchronous=True)
683683
elif (msg.offset() % 4) == 0:
684-
offsets = c.commit(msg, async=False)
684+
offsets = c.commit(msg, asynchronous=False)
685685
assert len(offsets) == 1, 'expected 1 offset, not %s' % (offsets)
686686
assert offsets[0].offset == msg.offset()+1, \
687687
'expected offset %d to be committed, not %s' % \

tests/test_Consumer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ def dummy_assign_revoke(consumer, partitions):
8484

8585
kc.unassign()
8686

87-
kc.commit(async=True)
87+
kc.commit(asynchronous=True)
8888

8989
try:
90-
kc.commit(async=False)
90+
kc.commit(asynchronous=False)
9191
except KafkaException as e:
9292
assert e.args[0].code() in (KafkaError._TIMED_OUT, KafkaError._NO_OFFSET)
9393

@@ -163,7 +163,7 @@ def commit_cb(cs, err, ps):
163163
if cs.once:
164164
# Try commit once
165165
try:
166-
c.commit(async=False)
166+
c.commit(asynchronous=False)
167167
except KafkaException as e:
168168
print('commit failed with %s (expected)' % e)
169169
assert e.args[0].code() == KafkaError._NO_OFFSET

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy