Skip to content

Commit

Permalink
Manual fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcferretti committed Jun 4, 2024
1 parent 82fc24b commit 108ec14
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions py/client/pydeephaven/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def sending_headers(self):
def _trace(who: str) -> None:
logger.debug(f'TRACE: {who}')

_BidiRpc = NewType("_BidiRpc", grpc.StreamStreamMultiCallable)

_NotBidiRpc = NewType(
"_NotBidiRpc",
Union[
grpc.UnaryUnaryMultiCallable,
grpc.UnaryStreamMultiCallable,
grpc.StreamUnaryMultiCallable])

class Session:
"""A Session object represents a connection to the Deephaven data server. It contains a number of convenience
Expand Down Expand Up @@ -505,23 +513,22 @@ def open_table(self, name: str) -> Table:
Raises:
DHError
"""
with self._r_lock:
ticket = ticket_pb2.Ticket(ticket=f's/{name}'.encode(encoding='ascii'))
ticket = ticket_pb2.Ticket(ticket=f's/{name}'.encode(encoding='ascii'))

faketable = Table(session=self, ticket=ticket)
faketable = Table(session=self, ticket=ticket)

try:
table_op = FetchTableOp()
return self.table_service.grpc_table_op(faketable, table_op)
except Exception as e:
if isinstance(e.__cause__, grpc.RpcError):
if e.__cause__.code() == grpc.StatusCode.INVALID_ARGUMENT:
raise DHError(f"no table by the name {name}") from None
raise e
finally:
# Explicitly close the table without releasing it (because it isn't ours)
faketable.ticket = None
faketable.schema = None
try:
table_op = FetchTableOp()
return self.table_service.grpc_table_op(faketable, table_op)
except Exception as e:
if isinstance(e.__cause__, grpc.RpcError):
if e.__cause__.code() == grpc.StatusCode.INVALID_ARGUMENT:
raise DHError(f"no table by the name {name}") from None
raise e
finally:
# Explicitly close the table without releasing it (because it isn't ours)
faketable.ticket = None
faketable.schema = None

def bind_table(self, name: str, table: Table) -> None:
"""Binds a table to the given name on the server so that it can be referenced by that name.
Expand All @@ -533,8 +540,7 @@ def bind_table(self, name: str, table: Table) -> None:
Raises:
DHError
"""
with self._r_lock:
self.console_service.bind_table(table=table, variable_name=name)
self.console_service.bind_table(table=table, variable_name=name)

def time_table(self, period: Union[int, str], start_time: Union[int, str] = None,
blink_table: bool = False) -> Table:
Expand Down

0 comments on commit 108ec14

Please sign in to comment.