tgdata 0.0.6__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tgdata-0.0.6 → tgdata-0.0.7}/PKG-INFO +1 -1
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/__init__.py +3 -2
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/connection_engine.py +36 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata.egg-info/PKG-INFO +1 -1
- {tgdata-0.0.6 → tgdata-0.0.7}/README.md +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/setup.cfg +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/setup.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/message_engine.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/models.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/progress.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/__init__.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/my_test.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_00_connection.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_01_list_group_chats.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_02_get_message_count.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_03_get_all_messages.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_04_get_all_messages_in_batches.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_05_with_progress_feature.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_06_polling_simple.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_07_on_new_message_simple.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_07_real_time_event_handler.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_08_batch_callback.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_08_polling.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_10_advanced_features.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_debug_min_id.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_polling_debug.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/smoke_tests/test_username_support.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/tgdata.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata/utils.py +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata.egg-info/SOURCES.txt +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata.egg-info/dependency_links.txt +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata.egg-info/requires.txt +0 -0
- {tgdata-0.0.6 → tgdata-0.0.7}/tgdata.egg-info/top_level.txt +0 -0
|
@@ -33,7 +33,7 @@ from .utils import (
|
|
|
33
33
|
# Progress tracking
|
|
34
34
|
from .progress import ProgressTracker
|
|
35
35
|
|
|
36
|
-
__version__ = "0.0.
|
|
36
|
+
__version__ = "0.0.7"
|
|
37
37
|
|
|
38
38
|
__all__ = [
|
|
39
39
|
# Main class
|
|
@@ -60,4 +60,5 @@ __all__ = [
|
|
|
60
60
|
|
|
61
61
|
# Progress
|
|
62
62
|
"ProgressTracker"
|
|
63
|
-
]
|
|
63
|
+
]
|
|
64
|
+
from tgdata.connection_engine import AuthRequiredError # noqa: E402,F401
|
|
@@ -67,6 +67,14 @@ class ConnectionPool:
|
|
|
67
67
|
self.connections.clear()
|
|
68
68
|
|
|
69
69
|
|
|
70
|
+
class AuthRequiredError(RuntimeError):
|
|
71
|
+
"""The session is not authorized and this code path is non-interactive.
|
|
72
|
+
|
|
73
|
+
Raised by ephemeral_client() instead of Telethon's start() prompt —
|
|
74
|
+
a headless process must FAIL LOUDLY here, never sit on input().
|
|
75
|
+
Fix: run an interactive login for this account once, by hand."""
|
|
76
|
+
|
|
77
|
+
|
|
70
78
|
class ConnectionEngine:
|
|
71
79
|
"""
|
|
72
80
|
Manages Telegram connections with advanced features.
|
|
@@ -189,6 +197,34 @@ class ConnectionEngine:
|
|
|
189
197
|
yield client
|
|
190
198
|
# Intentionally NO disconnect here — the connection is persistent.
|
|
191
199
|
|
|
200
|
+
@asynccontextmanager
|
|
201
|
+
async def ephemeral_client(self):
|
|
202
|
+
"""USE-AND-CLOSE (2026-08-05): a fresh client on the same resolved
|
|
203
|
+
session, connected WITHOUT start() (never interactive), disconnected
|
|
204
|
+
in finally — for short, human-triggered lookups (identity fetch,
|
|
205
|
+
access probe) that must not park a live transport next to a standing
|
|
206
|
+
loop sharing the session file. The persistent session()/pool path
|
|
207
|
+
above is untouched — it remains correct for the loop's own fetches,
|
|
208
|
+
where ONE process owns the session for its lifetime.
|
|
209
|
+
|
|
210
|
+
Raises AuthRequiredError when the session is not authorized: the
|
|
211
|
+
one situation start() would have prompted for a login code and hung
|
|
212
|
+
a headless process on stdin forever."""
|
|
213
|
+
config = self._load_config()
|
|
214
|
+
client = TelegramClient(config.session_file, config.api_id, config.api_hash)
|
|
215
|
+
try:
|
|
216
|
+
await client.connect()
|
|
217
|
+
if not await client.is_user_authorized():
|
|
218
|
+
raise AuthRequiredError(
|
|
219
|
+
f"session {config.session_file!r} is not authorized — "
|
|
220
|
+
f"run an interactive login for this account once, then retry")
|
|
221
|
+
yield client
|
|
222
|
+
finally:
|
|
223
|
+
try:
|
|
224
|
+
await client.disconnect()
|
|
225
|
+
except Exception: # noqa: BLE001 — teardown must never mask the work
|
|
226
|
+
pass
|
|
227
|
+
|
|
192
228
|
async def _init_primary_client(self):
|
|
193
229
|
"""Create and authenticate the primary client once (may be interactive)."""
|
|
194
230
|
config = self._load_config()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|