From 0e3845ef88190707c3fbf484a9dae0a0d9f30ac7 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 28 Feb 2021 20:56:32 +0100 Subject: [PATCH] The vlc _reset_state logic should be wrapped within a lock context to make sure that two threads don't try to deallocate the context at the same time --- platypush/plugins/media/vlc.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/platypush/plugins/media/vlc.py b/platypush/plugins/media/vlc.py index 0c313984fd..08dc033883 100644 --- a/platypush/plugins/media/vlc.py +++ b/platypush/plugins/media/vlc.py @@ -51,6 +51,7 @@ class MediaVlcPlugin(MediaPlugin): self._filename = None self._monitor_thread: Optional[threading.Thread] = None self._on_stop_event = threading.Event() + self._stop_lock = threading.RLock() @classmethod def _watched_event_types(cls): @@ -93,20 +94,21 @@ class MediaVlcPlugin(MediaPlugin): self._reset_state() def _reset_state(self): - self._latest_seek = None - self._title = None - self._filename = None - self._on_stop_event.clear() + with self._stop_lock: + self._latest_seek = None + self._title = None + self._filename = None + self._on_stop_event.clear() - if self._player: - self.logger.info('Releasing VLC player resource') - self._player.release() - self._player = None + if self._player: + self.logger.info('Releasing VLC player resource') + self._player.release() + self._player = None - if self._instance: - self.logger.info('Releasing VLC instance resource') - self._instance.release() - self._instance = None + if self._instance: + self.logger.info('Releasing VLC instance resource') + self._instance.release() + self._instance = None @staticmethod def _post_event(evt_type, **evt):