Skip to content

Commit

Permalink
wip: python: Finalize callback instead of resetting it on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
shramov committed Oct 21, 2023
1 parent 71284f8 commit 9952648
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions python/tll/channel/channel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ cdef int ccallback_destroy_cb(const tll_channel_t * c, const tll_msg_t *msg, voi
try:
o = wr()
if o is not None:
o.reset()
Py_INCREF(wr)
o.finalize()
Py_DECREF(wr)
except:
pass
return 0
Expand Down Expand Up @@ -175,14 +175,16 @@ cdef class CCallback:
self._self_ref = None

def add(self):
cdef int r = tll_channel_callback_add(self._channel, ccallback_destroy_cb, <void *>self._self_ref, self._mask)
cdef int r
r = tll_channel_callback_add(self._channel, ccallback_cb, <void *>self, self._mask)
if r:
raise TLLError("Callback add failed", r)
Py_INCREF(self._self_ref)

r = tll_channel_callback_add(self._channel, ccallback_cb, <void *>self, self._mask)
r = tll_channel_callback_add(self._channel, ccallback_destroy_cb, <void *>self._self_ref, self._mask)
if r:
raise TLLError("Callback add failed", r)
Py_INCREF(self._self_ref)

self._run_guard.enable()

def remove(self):
Expand Down

0 comments on commit 9952648

Please sign in to comment.