diff --git a/python/opendht.pyx b/python/opendht.pyx index aaad403ba7ddabbc95860a39221ff3270f7317e1..4854de13f056311a65be322eaee176dfdeeae36d 100644 --- a/python/opendht.pyx +++ b/python/opendht.pyx @@ -50,7 +50,6 @@ cdef inline void lookup_callback(cpp.vector[cpp.shared_ptr[cpp.IndexValue]]* val v._value = val vals.append(v) cbs['lookup'](vals, p.toString()) - ref.Py_DECREF(cbs) cdef inline void shutdown_callback(void* user_data) with gil: cbs = <object>user_data @@ -435,6 +434,7 @@ cdef class Pht(object): done_cb -- Called when the operation is completed. """ cb_obj = {'done':done_cb} + ref.Py_INCREF(cb_obj) cdef cpp.IndexKey cppk for kk, v in key.items(): cppk[bytes(kk, 'utf-8')] = cpp.Prefix(bytes(v))