Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run run_script/_refresh_token under session lock #4906

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions py/client/pydeephaven/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,11 @@ def _keep_alive(self):
self._keep_alive_timer.start()

def _refresh_token(self):
with self._r_lock:
try:
self._flight_client.authenticate(self._auth_handler)
except Exception as e:
self.is_connected = False
raise DHError("failed to refresh auth token") from e
try:
self._flight_client.authenticate(self._auth_handler)
except Exception as e:
self.is_connected = False
raise DHError("failed to refresh auth token") from e

@property
def is_alive(self) -> bool:
Expand Down Expand Up @@ -385,10 +384,9 @@ def run_script(self, script: str) -> None:
Raises:
DHError
"""
with self._r_lock:
response = self.console_service.run_script(script)
if response.error_message != '':
raise DHError("could not run script: " + response.error_message)
response = self.console_service.run_script(script)
if response.error_message != '':
raise DHError("could not run script: " + response.error_message)

def open_table(self, name: str) -> Table:
"""Opens a table in the global scope with the given name on the server.
Expand Down
8 changes: 8 additions & 0 deletions py/client/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def test_time_table(self):
session.bind_table("t", t)
session.run_script("""
from deephaven import empty_table
try:
del t1
except NameError:
pass
t1 = empty_table(0) if t.is_blink else None
""")
self.assertNotIn("t1", session.tables)
Expand All @@ -64,6 +68,10 @@ def test_time_table(self):
session.bind_table("t", t)
session.run_script("""
from deephaven import empty_table
try:
del t1
except NameError:
pass
t1 = empty_table(0) if t.is_blink else None
""")
self.assertIn("t1", session.tables)
Expand Down
Loading