Skip to content

Commit

Permalink
feat(embedded-server): Allow for specifying extra_classpaths on start…
Browse files Browse the repository at this point in the history
…up of the embedded server. (#5282)
  • Loading branch information
supernomad authored and devinrsmith committed Mar 26, 2024
1 parent 02eb5af commit 36fc3ad
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions py/embedded-server/deephaven_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# This is explicitly not a JObjectWrapper, as that would require importing deephaven and jpy
# before the JVM was running.


class Server:
"""
Represents a Deephaven server that can be created from Python.
Expand All @@ -24,7 +26,13 @@ def j_object(self):
def port(self):
return self.j_server.getPort()

def __init__(self, host: Optional[str] = None, port: Optional[int] = None, jvm_args: Optional[List[str]] = None, dh_args: Dict[str, str] = {}):
def __init__(
self,
host: Optional[str] = None,
port: Optional[int] = None,
jvm_args: Optional[List[str]] = None,
dh_args: Dict[str, str] = {},
extra_classpath: Optional[List[str]] = None):
"""
Creates a Deephaven embedded server. Only one instance can be created at this time.
"""
Expand All @@ -34,8 +42,11 @@ def __init__(self, host: Optional[str] = None, port: Optional[int] = None, jvm_a
if Server.instance is not None:
from deephaven import DHError
raise DHError('Cannot create more than one instance of the server')
if extra_classpath is None:
extra_classpath = []

# given the jvm args, ensure that the jvm has started
start_jvm(jvm_args=jvm_args)
start_jvm(jvm_args=jvm_args, extra_classpath=extra_classpath)

# it is now safe to import jpy
import jpy
Expand Down

0 comments on commit 36fc3ad

Please sign in to comment.