From 108ec145215bd2b3199599919882f8a6d8e23c6b Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Tue, 4 Jun 2024 12:52:39 -0400 Subject: [PATCH] Manual fixes. --- py/client/pydeephaven/session.py | 40 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/py/client/pydeephaven/session.py b/py/client/pydeephaven/session.py index 987f374a881..6a824f3308d 100644 --- a/py/client/pydeephaven/session.py +++ b/py/client/pydeephaven/session.py @@ -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 @@ -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. @@ -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: