Skip to content

Commit

Permalink
Don't run run_scrip/_refresh_token under lock (#4906)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Dec 1, 2023
1 parent 19b1d7e commit 414be28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
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

0 comments on commit 414be28

Please sign in to comment.