Don't start new server every time of use


#1

Heya , I am using TmpAuthenticator for JupyterHub in my organization TmpAuthenticator . Because I dont want people to login for Jupyterhub separately , so they use the serices of Jupyter through passing my system to Jupyterhub.
But I am facing few issues which cause less user to use my platform .

Issues :

  1. In TmpAuthenticator it is written that each time it forces the server of user to terminate and end , But this cause too much time like upto 3-4 mins in some of the cases, which I want to reduce , So my question is that instead of forcing restart every time Can't we just create a new server when every time user logins, so this will make the whole thing pretty fast .? Because this is stopping my user to open multiple times Jupyter Hub as it terminates the older ones

I am sharing snap of config.yaml , In this I am editing the changes… I want to open multiple servers of a user , so I have edited the raw_user as None , to treat every req as new and it will not terminate the old instances, But When user is making a new req it redirects to his open session… Can anyone help me out.

class TmpAuthenticateHandler(BaseHandler):
          """
          Handler for /tmplogin
          Creates a new user with a random UUID, and auto starts their server
          """
          def initialize(self, force_new_server, process_user):
              super().initialize()
              self.force_new_server = force_new_server
              self.process_user = process_user

          @gen.coroutine
          def get(self):
              kwargs = {}
              if self.subdomain_host:
                  kwargs['domain'] = self.domain
              session_id = self.get_session_cookie()

              if session_id:
                  # clear session id
                  self.clear_cookie('jupyterhub-session-id' , **kwargs)
              # clear hub cookie
              # self.clear_cookie(self.hub.cookie_name, path=self.hub.base_url, **kwargs)
              # clear services cookie
              self.clear_cookie('jupyterhub-services', path=url_path_join(self.base_url, 'services'), **kwargs)

              #raw_user = self.get_current_user()
              # By making the raw_user None, req will be treated as a new user always
              raw_user = None
              if raw_user:
                  print("User exists, keep him exist !")
                  if self.force_new_server:
                      # Stop user's current server if it is running
                      # so we get a new one.
                      status = yield raw_user.spawner.poll_and_notify()
                      if status is None:
                          yield self.stop_single_user(raw_user)
              username = str(uuid.uuid4())
              raw_user = self.user_from_username(username)
              self.set_login_cookie(raw_user)
              user = yield gen.maybe_future(self.process_user(raw_user, self))
              self.redirect(self.get_argument("next", user.url))

PS : I want my user to open JupyterHub multiple times without terminating the older instances…

Thanks in advance
Vidit