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

Optimize checking of supported args #152

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

matuskosut
Copy link
Contributor

@matuskosut matuskosut commented Sep 12, 2024

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.

@@ -1,6 +1,5 @@
import getpass
import os
import pathlib
Copy link
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
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
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

Copy link
Member

@consideRatio consideRatio Oct 21, 2024

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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants