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

minimize overhead when checking the supported args by RStudio #160

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
add suggestions
goebbert1 committed Jan 3, 2025

Verified

This commit was signed with the committer’s verified signature.
truthbk Jaime Fullaondo
commit cc509612d8fdf80c989f2cc10f88252dfca43118
13 changes: 8 additions & 5 deletions jupyter_rsession_proxy/__init__.py
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ def db_config(db_dir):
def _support_args(args):
ret = subprocess.check_output([get_rstudio_executable('rserver'), '--help'])
help_output = ret.decode()
return {arg: (help_output.find(arg) != -1) for arg in args}
return {arg: (help_output.find(f"--{arg}") != -1) for arg in args}

def _get_www_frame_origin(default="same"):
try:
@@ -117,11 +117,14 @@ def _get_cmd(port, unix_socket):
cmd.append(f'--database-config-file={database_config_file}')

if supported_args['www-thread-pool-size']:
thread_pool_size_env = os.getenv('JUPYTER_RSESSION_PROXY_THREAD_POOL_SIZE', None)
try:
thread_pool_size = int(os.getenv('JUPYTER_RSESSION_PROXY_THREAD_POOL_SIZE', ""))
if thread_pool_size > 0:
cmd.append('--www-thread-pool-size=' + str(thread_pool_size))
except:
if thread_pool_size_env is not None:
thread_pool_size = int(thread_pool_size_env)
if thread_pool_size > 0:
cmd.append('--www-thread-pool-size=' + str(thread_pool_size))
except ValueError:
print("Invalid value for JUPYTER_RSESSION_PROXY_THREAD_POOL_SIZE. Must be an integer.")
pass

if unix_socket != "":