streamlit-webrtc 0.53.10__tar.gz → 0.54.0__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.
Files changed (26) hide show
  1. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/PKG-INFO +2 -2
  2. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/pyproject.toml +1 -1
  3. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/_compat.py +3 -1
  4. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/session_info.py +2 -2
  5. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/shutdown.py +6 -1
  6. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/webrtc.py +14 -8
  7. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/.gitignore +0 -0
  8. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/LICENSE +0 -0
  9. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/README.md +0 -0
  10. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/__init__.py +0 -0
  11. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/component.py +0 -0
  12. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/components_callbacks.py +0 -0
  13. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/config.py +0 -0
  14. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/credentials.py +0 -0
  15. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/eventloop.py +0 -0
  16. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/factory.py +0 -0
  17. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/frontend/dist/assets/index-DMhSSwr2.js +0 -0
  18. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/frontend/dist/index.html +0 -0
  19. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/mix.py +0 -0
  20. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/models.py +0 -0
  21. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/process.py +0 -0
  22. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/py.typed +0 -0
  23. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/receive.py +0 -0
  24. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/relay.py +0 -0
  25. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/server.py +0 -0
  26. {streamlit_webrtc-0.53.10 → streamlit_webrtc-0.54.0}/streamlit_webrtc/source.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-webrtc
3
- Version: 0.53.10
3
+ Version: 0.54.0
4
4
  Summary: Real-time video and audio processing on Streamlit
5
5
  Project-URL: Repository, https://github.com/whitphx/streamlit-webrtc
6
6
  Author-email: "Yuichiro Tachibana (Tsuchiya)" <t.yic.yt@gmail.com>
7
7
  License-Expression: MIT
8
8
  License-File: LICENSE
9
9
  Requires-Python: !=3.9.7,>=3.9
10
- Requires-Dist: aiortc>=1.9.0
10
+ Requires-Dist: aiortc>=1.11.0
11
11
  Requires-Dist: packaging>=20.0
12
12
  Requires-Dist: streamlit>=0.84.1
13
13
  Description-Content-Type: text/markdown
@@ -10,7 +10,7 @@ dependencies = [
10
10
  # For allow-same-origin, >=0.73.0 is required. See https://blog.streamlit.io/streamlit-components-security-and-a-five-month-quest-to-ship-a-single-line-of-code/
11
11
  # 0.84.0 has an error at marshalling component values.
12
12
  "streamlit>=0.84.1",
13
- "aiortc>=1.9.0", # aiortc<1.4.0 causes an error with cryptography>=39.0.0. See https://github.com/whitphx/streamlit-webrtc/issues/1164. The fix was introduced into aiortc in https://github.com/aiortc/aiortc/commit/08b0a7e9f5030a9f7e5617382e92560d4ae763a2 that 1.4.0 included.
13
+ "aiortc>=1.11.0", # aiortc<1.4.0 causes an error with cryptography>=39.0.0. See https://github.com/whitphx/streamlit-webrtc/issues/1164. The fix was introduced into aiortc in https://github.com/aiortc/aiortc/commit/08b0a7e9f5030a9f7e5617382e92560d4ae763a2 that 1.4.0 included.
14
14
  "packaging>=20.0",
15
15
  ]
16
16
 
@@ -56,8 +56,10 @@ except ModuleNotFoundError:
56
56
  from streamlit.app_session import AppSession, AppSessionState # type: ignore
57
57
  except ModuleNotFoundError:
58
58
  # streamlit < 1.4
59
- from streamlit.report_session import ( # type: ignore # isort:skip
59
+ from streamlit.report_session import ( # type: ignore
60
60
  ReportSession as AppSession,
61
+ )
62
+ from streamlit.report_session import ( # type: ignore
61
63
  ReportSessionState as AppSessionState,
62
64
  )
63
65
 
@@ -34,11 +34,11 @@ def get_this_session_info() -> Optional[SessionInfo]:
34
34
  if VER_GTE_1_18_0:
35
35
  from streamlit.runtime.runtime import Runtime
36
36
 
37
- return Runtime.instance()._session_mgr.get_session_info(session_id) # type: ignore # noqa: E501
37
+ return Runtime.instance()._session_mgr.get_session_info(session_id) # type: ignore
38
38
  elif VER_GTE_1_14_0:
39
39
  from streamlit.runtime.runtime import Runtime
40
40
 
41
- return Runtime.instance()._get_session_info(session_id) # type: ignore # noqa: E501
41
+ return Runtime.instance()._get_session_info(session_id) # type: ignore
42
42
 
43
43
  current_server = get_current_server()
44
44
 
@@ -40,7 +40,7 @@ class SessionShutdownObserver:
40
40
  ):
41
41
  # Use polling because event-based methods are not available
42
42
  # to observe the session lifecycle.
43
- while not self._polling_thread_stop_event.wait(1.0):
43
+ while True:
44
44
  app_session = app_session_ref()
45
45
  if not app_session:
46
46
  logger.debug("AppSession has removed.")
@@ -51,6 +51,11 @@ class SessionShutdownObserver:
51
51
  app_session.id,
52
52
  )
53
53
  break
54
+ if self._polling_thread_stop_event.wait(1.0):
55
+ logger.debug(
56
+ "The polling thread should be stopped. Exit the polling loop and return."
57
+ )
58
+ return
54
59
 
55
60
  # Ensure the flag is set
56
61
  self._polling_thread_stop_event.set()
@@ -4,7 +4,7 @@ import itertools
4
4
  import logging
5
5
  import queue
6
6
  import threading
7
- from typing import Callable, Generic, Literal, Optional, Union, cast
7
+ from typing import TYPE_CHECKING, Callable, Generic, Literal, Optional, Union, cast
8
8
 
9
9
  from aiortc import RTCConfiguration, RTCPeerConnection, RTCSessionDescription
10
10
  from aiortc.contrib.media import MediaPlayer, MediaRecorder, MediaRelay
@@ -39,6 +39,9 @@ from .process import (
39
39
  from .receive import AudioReceiver, VideoReceiver
40
40
  from .relay import get_global_relay
41
41
 
42
+ if TYPE_CHECKING:
43
+ import concurrent.futures
44
+
42
45
  __all__ = [
43
46
  "AudioProcessorBase",
44
47
  "AudioProcessorFactory",
@@ -48,7 +51,7 @@ __all__ = [
48
51
  "MediaRecorderFactory",
49
52
  "VideoProcessorFactory",
50
53
  "WebRtcMode",
51
- "TimeoutError",
54
+ "SignallingTimeoutError",
52
55
  "WebRtcWorker",
53
56
  ]
54
57
 
@@ -63,7 +66,7 @@ class WebRtcMode(enum.Enum):
63
66
  SENDRECV = enum.auto()
64
67
 
65
68
 
66
- class TimeoutError(Exception):
69
+ class SignallingTimeoutError(Exception):
67
70
  pass
68
71
 
69
72
 
@@ -522,7 +525,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
522
525
  if self.pc.iceConnectionState == "failed":
523
526
  await self.pc.close()
524
527
 
525
- process_offer_task = loop.create_task(
528
+ process_offer_task = asyncio.run_coroutine_threadsafe(
526
529
  _process_offer_coro(
527
530
  self.mode,
528
531
  self.pc,
@@ -540,10 +543,11 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
540
543
  sendback_video=self.sendback_video,
541
544
  sendback_audio=self.sendback_audio,
542
545
  on_track_created=on_track_created,
543
- )
546
+ ),
547
+ loop=loop,
544
548
  )
545
549
 
546
- def callback(done_task: asyncio.Task):
550
+ def callback(done_task: "concurrent.futures.Future"):
547
551
  e = done_task.exception()
548
552
  if e:
549
553
  logger.debug("Error occurred in process_offer")
@@ -574,7 +578,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
574
578
  result = self._answer_queue.get(block=True, timeout=timeout)
575
579
  except queue.Empty:
576
580
  self.stop(timeout=1)
577
- raise TimeoutError(
581
+ raise SignallingTimeoutError(
578
582
  "Processing offer and initializing the worker "
579
583
  f"has not finished in {timeout} seconds"
580
584
  )
@@ -672,6 +676,8 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
672
676
  self._relayed_source_video_track = None
673
677
 
674
678
  def stop(self, timeout: Union[float, None] = 1.0):
679
+ logger.debug("Stopping the WebRTC worker")
680
+
675
681
  self._unset_processors()
676
682
  if self._process_offer_thread:
677
683
  self._process_offer_thread.join(timeout=timeout)
@@ -680,7 +686,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
680
686
  if self.pc and self.pc.connectionState != "closed":
681
687
  loop = get_global_event_loop()
682
688
  if loop.is_running():
683
- loop.create_task(self.pc.close())
689
+ asyncio.run_coroutine_threadsafe(self.pc.close(), loop=loop)
684
690
  else:
685
691
  loop.run_until_complete(self.pc.close())
686
692