mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-17 13:05:58 +00:00
fix(channel): unsubscribe channel listeners by equality (#3608)
This commit is contained in:
@@ -148,6 +148,27 @@ class TestMessageBus:
|
||||
|
||||
_run(go())
|
||||
|
||||
def test_unsubscribe_outbound_removes_fresh_bound_method_reference(self):
|
||||
bus = MessageBus()
|
||||
received = []
|
||||
|
||||
class Handler:
|
||||
async def callback(self, msg):
|
||||
received.append((self, msg))
|
||||
|
||||
handler = Handler()
|
||||
other_handler = Handler()
|
||||
|
||||
async def go():
|
||||
bus.subscribe_outbound(handler.callback)
|
||||
bus.subscribe_outbound(other_handler.callback)
|
||||
bus.unsubscribe_outbound(handler.callback)
|
||||
out = OutboundMessage(channel_name="test", chat_id="c1", thread_id="t1", text="reply")
|
||||
await bus.publish_outbound(out)
|
||||
assert received == [(other_handler, out)]
|
||||
|
||||
_run(go())
|
||||
|
||||
def test_outbound_error_does_not_crash(self):
|
||||
bus = MessageBus()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user