Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle None error_cb and dr_cb
  • Loading branch information
edenhill committed Aug 8, 2016
commit 631eb9b9469655488dbe7e5c5680a15e18387435
4 changes: 2 additions & 2 deletions confluent_kafka/src/Producer.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ static PyObject *Producer_produce (Handle *self, PyObject *args,
return NULL;
}

if (!dr_cb)
if (!dr_cb || dr_cb == Py_None)
dr_cb = self->u.Producer.default_dr_cb;
if (!partitioner_cb)
if (!partitioner_cb || partitioner_cb == Py_None)
partitioner_cb = self->u.Producer.partitioner_cb;

/* Create msgstate if necessary, may return NULL if no callbacks
Expand Down
10 changes: 7 additions & 3 deletions confluent_kafka/src/confluent_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,14 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
continue;

} else if (!strcmp(k, "error_cb")) {
if (h->error_cb)
if (h->error_cb) {
Py_DECREF(h->error_cb);
h->error_cb = vo;
Py_INCREF(h->error_cb);
h->error_cb = NULL;
}
if (vo != Py_None) {
h->error_cb = vo;
Py_INCREF(h->error_cb);
}
Py_DECREF(ks);
continue;
}
Expand Down