fix: _on_candle_closed async 콜백 구조 수정 — asyncio.create_task 제거
동기 콜백 내부에서 asyncio.create_task()를 호출하면 이벤트 루프 컨텍스트 밖에서 실패하여 캔들 처리가 전혀 이루어지지 않는 버그 수정. - _on_candle_closed: 동기 → async, create_task → await - handle_message (KlineStream/MultiSymbolStream): 동기 → async, on_candle await - test_callback_called_on_closed_candle: AsyncMock + await handle_message로 수정 Made-with: Cursor
This commit is contained in:
@@ -63,11 +63,11 @@ async def test_kline_stream_parses_message():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_callback_called_on_closed_candle():
|
||||
received = []
|
||||
callback = AsyncMock()
|
||||
stream = KlineStream(
|
||||
symbol="XRPUSDT",
|
||||
interval="1m",
|
||||
on_candle=lambda c: received.append(c),
|
||||
on_candle=callback,
|
||||
)
|
||||
raw_msg = {
|
||||
"k": {
|
||||
@@ -80,8 +80,8 @@ async def test_callback_called_on_closed_candle():
|
||||
"x": True,
|
||||
}
|
||||
}
|
||||
stream.handle_message(raw_msg)
|
||||
assert len(received) == 1
|
||||
await stream.handle_message(raw_msg)
|
||||
assert callback.call_count == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user