Mercurial > libervia-backend
comparison libervia/frontends/tools/aio.py @ 4233:d01b8d002619
cli (call, file), frontends: implement webRTC data channel transfer:
- file send/receive commands now supports webRTC transfer. In `send` command, the
`--webrtc` flags is currenty used to activate it.
- WebRTC related code have been factorized and moved to `libervia.frontends.tools.webrtc*`
modules.
rel 442
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Apr 2024 13:43:09 +0200 |
parents | 5de6f3595380 |
children | 7d98d894933c |
comparison
equal
deleted
inserted
replaced
4232:0fbe5c605eb6 | 4233:d01b8d002619 |
---|---|
32 Note: The function removes the task from the tracking set and logs any exceptions | 32 Note: The function removes the task from the tracking set and logs any exceptions |
33 that might have occurred. | 33 that might have occurred. |
34 """ | 34 """ |
35 background_tasks.discard(task) | 35 background_tasks.discard(task) |
36 e = task.exception() | 36 e = task.exception() |
37 if e is not None: | 37 if e is not None and not isinstance(e, SystemExit): |
38 exc_info = (type(e), e, e.__traceback__) | 38 exc_info = (type(e), e, e.__traceback__) |
39 log.error("Task failed:", exc_info=exc_info) | 39 log.error("Task failed:", exc_info=exc_info) |
40 | 40 |
41 | 41 |
42 def run_async(async_method: Coroutine | asyncio.Future) -> None: | 42 def run_async(async_method: Coroutine | asyncio.Future) -> None: |
55 background_tasks.add(task) | 55 background_tasks.add(task) |
56 task.add_done_callback(_on_task_done) | 56 task.add_done_callback(_on_task_done) |
57 | 57 |
58 | 58 |
59 def run_with_args( | 59 def run_with_args( |
60 async_method: Callable[..., Coroutine[Any, Any, Any]], *args: Any, **kwargs: Any | 60 async_method: Callable[..., Coroutine], *args: Any, **kwargs: Any |
61 ) -> None: | 61 ) -> None: |
62 """Schedules and tracks an asynchronous method with arguments. | 62 """Schedules and tracks an asynchronous method with arguments. |
63 | 63 |
64 This function wraps the provided asynchronous method with its arguments | 64 This function wraps the provided asynchronous method with its arguments |
65 and then schedules it for execution. | 65 and then schedules it for execution. |
70 """ | 70 """ |
71 run_async(async_method(*args, **kwargs)) | 71 run_async(async_method(*args, **kwargs)) |
72 | 72 |
73 | 73 |
74 def run_from_thread( | 74 def run_from_thread( |
75 async_method: Coroutine | asyncio.Future, | 75 async_method: Callable[..., Coroutine] | Callable[..., asyncio.Future], |
76 *args, | 76 *args, |
77 loop: asyncio.AbstractEventLoop | None = None, | 77 loop: asyncio.AbstractEventLoop | None = None, |
78 **kwargs, | 78 **kwargs, |
79 ) -> None: | 79 ) -> None: |
80 """Schedules an asynchronous method from another thread. | 80 """Schedules an asynchronous method from another thread. |