vsview-remote 0.3.0__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vsview-remote
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A VSView plugin that provides remote execution for VapourSynth, leveraging the vsremote library.
5
5
  Project-URL: Documentation, https://jaded-encoding-thaumaturgy.github.io/vs-view/usage/workspaces/remote/
6
6
  Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/tree/main/src/workspaces/remote/
@@ -57,6 +57,8 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
57
57
  def __init__(self, parent: QWidget | None = None) -> None:
58
58
  super().__init__(parent)
59
59
  self._client: RemoteClient | None = None
60
+ self._client_config: ConnectionConfig | None = None
61
+ self._client_lock = threading.RLock()
60
62
  self._config: ConnectionConfig | None = None
61
63
  self._output_metadata = dict[int, VideoMetadata]()
62
64
  self._session_secrets = SessionSecrets(self.secrets, self._on_secrets_error)
@@ -82,32 +84,36 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
82
84
 
83
85
  @property
84
86
  def client(self) -> RemoteClient:
85
- if self._config is None:
86
- raise RuntimeError("This shouldn't happen")
87
-
88
- if self._client and not self._client.is_running:
89
- logger.warning("Remote client transport is not running; resetting client.")
90
- self._discard_client()
91
-
92
- if self._client:
93
- return self._client
94
-
95
- logger.info("Connecting to vsremote server at %s...", self._config.address)
96
- curve_server_key, curve_public_key, curve_secret_key = self._config.active_curve_keys
97
- self._client = RemoteClient(
98
- self._config.address,
99
- compression=self._config.compression,
100
- auth_token=self._config.auth_token,
101
- curve_server_key=curve_server_key,
102
- curve_public_key=curve_public_key,
103
- curve_secret_key=curve_secret_key,
104
- forward_logs=self._config.forward_logs,
105
- subscribe_streams=self._config.subscribe_streams,
106
- replay_history=False,
107
- hwm=self._config.effective_hwm,
108
- tcp_keepalive=self._config.tcp_keepalive,
109
- )
110
- return self._client.start()
87
+ with self._client_lock:
88
+ if (config := self._config) is None:
89
+ raise RuntimeError("This shouldn't happen")
90
+
91
+ if self._client and not self._client.is_running:
92
+ logger.warning("Remote client transport is not running; resetting client.")
93
+ self._discard_client()
94
+ elif self._client and self._client_config != config:
95
+ self._discard_client()
96
+
97
+ if self._client:
98
+ return self._client
99
+
100
+ logger.info("Connecting to vsremote server at %s...", config.address)
101
+ curve_server_key, curve_public_key, curve_secret_key = config.active_curve_keys
102
+ self._client = RemoteClient(
103
+ config.address,
104
+ compression=config.compression,
105
+ auth_token=config.auth_token,
106
+ curve_server_key=curve_server_key,
107
+ curve_public_key=curve_public_key,
108
+ curve_secret_key=curve_secret_key,
109
+ forward_logs=config.forward_logs,
110
+ subscribe_streams=config.subscribe_streams,
111
+ replay_history=False,
112
+ hwm=config.effective_hwm,
113
+ tcp_keepalive=config.tcp_keepalive,
114
+ )
115
+ self._client_config = config
116
+ return self._client.start()
111
117
 
112
118
  @override
113
119
  def dropEvent(self, event: QDropEvent) -> None:
@@ -119,14 +125,14 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
119
125
  QTimer.singleShot(0, self, lambda: self._connect_and_load(dropped_file))
120
126
 
121
127
  @override
122
- def deleteLater(self) -> None:
128
+ def on_teardown_started(self) -> None:
123
129
  self._discard_client()
124
- super().deleteLater()
130
+ super().on_teardown_started()
125
131
 
126
132
  @override
127
- def clear_environment(self) -> None:
133
+ def _release_content(self) -> None:
128
134
  self._output_metadata.clear()
129
- super().clear_environment()
135
+ super()._release_content()
130
136
 
131
137
  @override
132
138
  def get_output_metadata(self) -> dict[int, VideoMetadata]:
@@ -143,12 +149,13 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
143
149
  raise ConnectionNotConfiguredError("Remote connection not configured")
144
150
 
145
151
  code = self.content.read_text(encoding="utf-8")
146
- output_items = self.client.load_code(code, filename=str(self.content)).result(
152
+ client = self.client
153
+ output_items = client.load_code(code, filename=str(self.content)).result(
147
154
  timeout=self.settings.global_.load_timeout
148
155
  )
149
156
  logger.info("Remote script execution completed successfully (%d outputs)", len(output_items))
150
157
 
151
- for idx, clip in self.client.get_outputs(
158
+ for idx, clip in client.get_outputs(
152
159
  config.prefetch,
153
160
  config.backlog,
154
161
  frame_timeout=config.frame_timeout,
@@ -212,24 +219,20 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
212
219
  self.api.statusMessage.emit(message)
213
220
  self.dialog.set_status(message, "#e74c3c")
214
221
 
215
- def _apply_config(self, config: ConnectionConfig) -> None:
216
- if config != self._config:
217
- self._discard_client()
218
-
219
- self._config = config
220
-
221
222
  def _connect_and_load(self, path: Path) -> None:
222
223
  if (config := self.prompt_connection_dialog()) is None:
223
224
  return
224
225
 
225
- self._apply_config(config)
226
+ self._config = config
226
227
  self.load_content(path)
227
228
 
228
229
  def _discard_client(self) -> None:
229
- if (client := self._client) is None:
230
+ with self._client_lock:
231
+ client, self._client = self._client, None
232
+
233
+ if client is None:
230
234
  return
231
235
 
232
- self._client = None
233
236
  # Closes the client in a fire and forget background task so the GUI thread does not wait for it
234
237
  threading.Thread(target=client.close, name="CloseRemoteClient", daemon=True).start()
235
238
 
@@ -239,7 +242,7 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
239
242
  if (config := self.prompt_connection_dialog()) is None:
240
243
  return
241
244
 
242
- self._apply_config(config)
245
+ self._config = config
243
246
  super()._on_open_file_button_clicked()
244
247
 
245
248
  @Slot()
@@ -247,7 +250,7 @@ class RemoteWorkspace(PythonScriptWorkspace, PluginWorkspace[GlobalSettings, Non
247
250
  if (config := self.prompt_connection_dialog()) is None:
248
251
  return
249
252
 
250
- self._apply_config(config)
253
+ self._config = config
251
254
  if not getattr(self, "content", None):
252
255
  return
253
256
 
File without changes
File without changes
File without changes