Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gc_option parameter and rename to set_xmx_if_not_set #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jgo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .jgo import resolve_dependencies, _jgo_main as main
from .util import main_from_endpoint, maven_scijava_repository, add_jvm_args_as_necessary
from .util import main_from_endpoint, maven_scijava_repository, set_xmx_if_not_set
13 changes: 6 additions & 7 deletions jgo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@

from .jgo import _jgo_main as main

def add_jvm_args_as_necessary(argv, gc_option='-XX:+UseConcMarkSweepGC'):

def set_xmx_if_not_set(argv):
"""

Extend existing ``argv`` with reasonable default values for garbage collection and max heap size.
Extend existing ``argv`` with reasonable default values for max heap size.
If ``-Xmx`` is not specified in ``argv``, set max heap size to half the system's memory.

:param argv: arugment vector
:param gc_option: Use this garbage collector settings, if any.
:return: ``argv`` with
"""
if gc_option and not gc_option in argv:
argv += [gc_option]

for arg in argv:
if '-Xmx' in arg:
Expand All @@ -39,7 +37,8 @@ def main_from_endpoint(
repositories={'scijava.public': maven_scijava_repository()},
primary_endpoint_version=None,
primary_endpoint_main_class=None,
secondary_endpoints=()):
secondary_endpoints=(),
set_reasonable_default_xmx_if_not_set=True):
"""
Convenience method to populate appropriate argv for jgo. This is useful to distribute Java programs as Python modules.

Expand All @@ -66,6 +65,6 @@ def main_from_endpoint(
primary_endpoint = primary_endpoint + ':{}'.format(primary_endpoint_main_class) if primary_endpoint_main_class else primary_endpoint
endpoint = ['+'.join((primary_endpoint,) + secondary_endpoints)]
paintera_argv = argv if double_dash_index < 0 else argv[double_dash_index+1:]
argv = add_jvm_args_as_necessary(jgo_and_jvm_argv) + repository_strings + endpoint + paintera_argv
argv = (set_xmx_if_not_set(jgo_and_jvm_argv) if set_reasonable_default_xmx_if_not_set else jgo_and_jvm_argv) + repository_strings + endpoint + paintera_argv

main(argv=argv)