Skip to content

Optimize checking of supported args#152

Open
matuskosut wants to merge 2 commits into
jupyterhub:mainfrom
huntdatacenter:rstudio-2024
Open

Optimize checking of supported args#152
matuskosut wants to merge 2 commits into
jupyterhub:mainfrom
huntdatacenter:rstudio-2024

Conversation

@matuskosut

@matuskosut matuskosut commented Sep 12, 2024

Copy link
Copy Markdown
Contributor

Hi all,

As @yuvipanda suggested in comments of this PR #151 (comment) I have split out a part that optimizes checking of supported arguments.

It would be great if we could merge this before upping the require jupyter-server-kernel. If that is possible I am happy to help with making separate PR for the other part that deals with support of unix_socket.

Comment thread jupyter_rsession_proxy/__init__.py Outdated
@@ -1,6 +1,5 @@
import getpass
import os
import pathlib

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed pathlib since it is not used

Comment on lines +81 to +84
try:
return os.getenv('JUPYTER_RSESSION_PROXY_WWW_FRAME_ORIGIN', default)
except Exception:
return default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a try/except block is relevant here, I don't know of an error to be raised that we want that can be raised in this situation using os.getenv.

Suggested change
try:
return os.getenv('JUPYTER_RSESSION_PROXY_WWW_FRAME_ORIGIN', default)
except Exception:
return default
return os.getenv('JUPYTER_RSESSION_PROXY_WWW_FRAME_ORIGIN', default)

Could you update the PR title or description to try capture this is now configurable via an environment variable? Whatever is put in the title will be visible via the changelog btw

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I've seen #148 now.

So this PR isn't really introducing this after all, its already there?

Comment on lines +125 to +131
try:
thread_pool_size = int(os.getenv('RSERVER_THREAD_POOL_SIZE', ""))
if thread_pool_size > 0:
cmd.append('--www-thread-pool-size=' + str(thread_pool_size))
except Exception:
pass

@consideRatio consideRatio Oct 21, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is errorously configured, such as having RSERVER_THREAD_POOL_SIZE set to "asdf", I think it can make sense to error loudly instead. Of course, if its an empty string though, we shouldn't error, but we can check that without a try/except block.

I think maybe something like...

int(os.getenv('RSERVER_THREAD_POOL_SIZE') or "0") can do the trick, assuming we only want to configure --ww-thread-pool-size if its set to something else than 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants