diff --git a/src/main/client/batch_operate.c b/src/main/client/batch_operate.c index 476e112ce..c5ae47415 100644 --- a/src/main/client/batch_operate.c +++ b/src/main/client/batch_operate.c @@ -145,26 +145,6 @@ static PyObject *AerospikeClient_Batch_Operate_Invoke( Py_ssize_t ops_size = PyList_Size(py_ops); as_operations_inita(&ops, ops_size); - // The C client's batch write policy doesn't have a ttl option - // The correct way is to set the ttl inside the as_operations object - PyObject *py_ttl = PyDict_GetItemString(py_policy_batch_write, "ttl"); - Py_XINCREF(py_ttl); - // Default ttl - if (py_ttl != NULL) { - if (PyLong_Check(py_ttl)) { - long ttl = PyLong_AsLong(py_ttl); - if (ttl > UINT32_MAX || ttl < 0) { - as_error_update(err, AEROSPIKE_ERR_PARAM, - "ttl is out of range. It must be a 32 bit " - "unsigned integer."); - Py_DECREF(py_ttl); - goto CLEANUP; - } - ops.ttl = ttl; - } - } - Py_XDECREF(py_ttl); - PyObject *br_instance = NULL; if (!self || !self->as) { @@ -240,6 +220,26 @@ static PyObject *AerospikeClient_Batch_Operate_Invoke( &batch_write_exp_list_p) != AEROSPIKE_OK) { goto CLEANUP; } + + // The C client's batch write policy doesn't have a ttl option + // The correct way is to set the ttl inside the as_operations object + PyObject *py_ttl = PyDict_GetItemString(py_policy_batch_write, "ttl"); + Py_XINCREF(py_ttl); + // Default ttl + if (py_ttl != NULL) { + if (PyLong_Check(py_ttl)) { + long ttl = PyLong_AsLong(py_ttl); + if (ttl > UINT32_MAX || ttl < 0) { + as_error_update(err, AEROSPIKE_ERR_PARAM, + "ttl is out of range. It must be a 32 bit " + "unsigned integer."); + Py_DECREF(py_ttl); + goto CLEANUP; + } + ops.ttl = ttl; + } + } + Py_XDECREF(py_ttl); } // import batch_records helper