Skip to content

Commit

Permalink
Extend JObjectWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
arman-ddl committed Mar 15, 2024
1 parent fbc4609 commit 66fcfc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py/server/deephaven/jcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas as pd

from deephaven import dtypes, DHError
from deephaven._wrapper import unwrap, wrap_j_object
from deephaven._wrapper import unwrap, wrap_j_object, JObjectWrapper
from deephaven.dtypes import DType, _PRIMITIVE_DTYPE_NULL_MAP, _J_ARRAY_NP_TYPE_MAP

_NULL_BOOLEAN_AS_BYTE = jpy.get_type("io.deephaven.util.BooleanUtils").NULL_BOOLEAN_AS_BYTE
Expand Down Expand Up @@ -306,7 +306,7 @@ def _j_array_to_series(dtype: DType, j_array: jpy.JType, conv_null: bool) -> pd.
return s


class SafeCloseable:
class SafeCloseable(JObjectWrapper):
"""A context manager wrapper of Java SafeCloseable to emulate Java try-with-resources."""
def __init__(self, j_safe_closeable):
self._j_safe_closeable = j_safe_closeable
Expand All @@ -325,3 +325,7 @@ def __exit__(self, exc_type, exc_value, traceback):

def __del__(self):
self.close()

@property
def j_object(self) -> jpy.JType:
return self.j_safe_closeable

0 comments on commit 66fcfc8

Please sign in to comment.