Skip to content

Commit 34ef86c

Browse files
author
Josh Kappler
committed
fix(runner): drop nest_asyncio, which breaks startup on Python 3.14
nest_asyncio.apply() patches asyncio in a way that no longer holds on 3.14: asyncio.wait_for runs through asyncio.timeouts.timeout, which needs a current task, and under the patched loop that context is lost. The first wait_for inside Telethon's client.connect() then raises "RuntimeError: Timeout should be used inside a task" and the server dies before serving anything. nest_asyncio has been archived upstream since January 2024, so this will not be fixed there. The call is vestigial. Nothing under telegram_mcp/ re-enters a running loop: the only entrypoint is asyncio.run(_main()), and the HTTP/SSE transports are awaited inside that same loop. session_string_generator.py uses telethon.sync + loop.run_until_complete, but it runs standalone and never imports runner, so apply() never applied to it. Removed the import, the call, and the dependency from pyproject, requirements and uv.lock. The lock diff is nest-asyncio only. Verified on 3.14.6: before, `python main.py` dies at connect() with the error above; after, the connection completes and startup reaches the expected "not authorized" error for dummy credentials. 3.11 reaches that same point, unchanged. pytest is 149 passed with 3 pre-existing Windows path failures, identical before and after. Fixes #156
1 parent 48a6237 commit 34ef86c

5 files changed

Lines changed: 0 additions & 15 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dependencies = [
2626
"dotenv>=0.9.9",
2727
"httpx>=0.28.1",
2828
"mcp[cli]>=1.8.0",
29-
"nest-asyncio>=1.6.0",
3029
"python-dotenv>=1.1.0",
3130
"python-json-logger>=3.3.0",
3231
"qrcode>=8.2",

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
dotenv>=0.9.9
22
httpx>=0.28.1
33
mcp[cli]>=1.8.0
4-
nest-asyncio>=1.6.0
54
python-dotenv>=1.1.0
65
python-json-logger>=3.3.0
76
qrcode>=8.2

telegram_mcp/runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ async def _warm_caches() -> None:
9898
def main() -> None:
9999
_configure_allowed_roots_from_cli(sys.argv[1:])
100100
_runtime._apply_exposed_tools_mode()
101-
nest_asyncio.apply()
102101
asyncio.run(_main())
103102

104103

telegram_mcp/runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from urllib.parse import unquote, urlparse
1515

1616
# Third-party libraries
17-
import nest_asyncio
1817
from dotenv import load_dotenv
1918
from mcp.server.fastmcp import FastMCP, Context
2019
from mcp.types import Annotations, TextContent, ToolAnnotations

uv.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)