def register_user_callback(self, func):
"""
Func to be called when a subscription receives a new EventAdd command.
This function will be called by a Task in the main thread. If ``func``
needs to do CPU-intensive or I/O-related work, it should execute that
work in a separate thread of process.
"""
if inspect.ismethod(func):
self._callback = weakref.WeakMethod(func, self._callback_cleared)
else:
self._callback = weakref.ref(func, self._callback_cleared)
评论列表
文章目录