@@ -73,9 +73,10 @@ def db_config(db_dir):
73
73
f .close ()
74
74
return db_config_name
75
75
76
- def _support_arg ( arg ):
76
+ def _support_args ( args ):
77
77
ret = subprocess .check_output ([get_rstudio_executable ('rserver' ), '--help' ])
78
- return ret .decode ().find (arg ) != - 1
78
+ help_output = ret .decode ()
79
+ return {arg : (help_output .find (f"--{ arg } " ) != - 1 ) for arg in args }
79
80
80
81
def _get_www_frame_origin (default = "same" ):
81
82
try :
@@ -101,15 +102,33 @@ def _get_cmd(port, unix_socket):
101
102
]
102
103
# Support at least v1.2.1335 and up
103
104
104
- if _support_arg ('www-root-path' ):
105
+ supported_args = _support_args ([
106
+ 'www-root-path' ,
107
+ 'server-data-dir' ,
108
+ 'database-config-file' ,
109
+ 'www-thread-pool-size' ,
110
+ 'www-socket' ,
111
+ ])
112
+ if supported_args ['www-root-path' ]:
105
113
cmd .append ('--www-root-path={base_url}rstudio/' )
106
- if _support_arg ( 'server-data-dir' ) :
114
+ if supported_args [ 'server-data-dir' ] :
107
115
cmd .append (f'--server-data-dir={ server_data_dir } ' )
108
- if _support_arg ( 'database-config-file' ) :
116
+ if supported_args [ 'database-config-file' ] :
109
117
cmd .append (f'--database-config-file={ database_config_file } ' )
110
118
119
+ if supported_args ['www-thread-pool-size' ]:
120
+ thread_pool_size_env = os .getenv ('JUPYTER_RSESSION_PROXY_THREAD_POOL_SIZE' , None )
121
+ try :
122
+ if thread_pool_size_env is not None :
123
+ thread_pool_size = int (thread_pool_size_env )
124
+ if thread_pool_size > 0 :
125
+ cmd .append ('--www-thread-pool-size=' + str (thread_pool_size ))
126
+ except ValueError :
127
+ print ("Invalid value for JUPYTER_RSESSION_PROXY_THREAD_POOL_SIZE. Must be an integer." )
128
+ pass
129
+
111
130
if unix_socket != "" :
112
- if _support_arg ( 'www-socket' ) :
131
+ if supported_args [ 'www-socket' ] :
113
132
cmd .append ('--www-socket={unix_socket}' )
114
133
else :
115
134
raise NotImplementedError (f'rstudio-server does not support requested socket connection' )
0 commit comments