Skip to content

Commit 808d6cd

Browse files
committed
remove wait when disconnecting http transport
1 parent d276fd6 commit 808d6cd

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

janus_client/transport_http.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,15 @@ async def dispatch_session_destroyed(self, session_id: int) -> None:
149149

150150
logger.info(f"Destroy session_receive_response task ({session_id})")
151151
receiver_task = self.__receive_response_task_map[session_id]
152-
# Don't use task.cancel() to avoid
153-
# Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000027A269465F0>
154-
receiver_task.destroyed_event.set()
155-
156-
# Destroying sessions could cost some time because it needs to
157-
# wait for the long-poll request to complete
158-
await asyncio.wait([receiver_task.task])
152+
receiver_task.task.cancel()
153+
# I think the following problem was fixed when aiohttp version was updated
154+
# # Don't use task.cancel() to avoid
155+
# # Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000027A269465F0>
156+
# receiver_task.destroyed_event.set()
157+
158+
# # Destroying sessions could cost some time because it needs to
159+
# # wait for the long-poll request to complete
160+
# await asyncio.wait([receiver_task.task])
159161

160162

161163
def protocol_matcher(base_url: str):

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ dependencies = [
4646
"python-dotenv>=1.0.0",
4747
]
4848

49+
[[tool.hatch.envs.default.matrix]]
50+
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
51+
4952
[tool.hatch.envs.default.scripts]
5053
docs-build = "python -W ignore::DeprecationWarning:mkdocs_autorefs -m mkdocs build --clean --strict"
5154
docs-serve = "mkdocs serve"

test_echotest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import asyncio
22
import logging
33
import os
4+
from urllib.parse import urljoin
5+
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
49

510
# from janus_client.transport import JanusTransportHTTP
611
from janus_client import JanusSession, JanusEchoTestPlugin
@@ -14,8 +19,14 @@ async def main():
1419
# transport = JanusTransportHTTP(
1520
# uri="https://janusmy.josephgetmyip.com/janusbase/janus"
1621
# )
17-
session = JanusSession(base_url="wss://janusmy.josephgetmyip.com/janusbasews/janus")
18-
# session = JanusSession(base_url="https://janusmy.josephgetmyip.com/janusbase/janus")
22+
# session = JanusSession(base_url="wss://janusmy.josephgetmyip.com/janusbasews/janus")
23+
session = JanusSession(
24+
base_url=urljoin(
25+
os.getenv("JANUS_HTTP_URL", ""),
26+
os.getenv("JANUS_HTTP_BASE_PATH", ""),
27+
),
28+
api_secret=os.getenv("JANUS_API_SECRET", ""),
29+
)
1930

2031
plugin_handle = JanusEchoTestPlugin()
2132

0 commit comments

Comments
 (0)