Drops the user into an interactive Python session with the ``sess`` variable
    set to the current session instance. If keyword arguments are supplied, these
    names will also be available within the session.
537
def interact(self, **local):
    
    import code
    code.interact(local=dict(sess=self, **local))
309272
private String getSessionId(final HttpSession sess) {
    try {
      if (sess == null) {
        return "NO-SESSIONID";
      } else {
        return sess.getId();
      }
    } catch (Throwable t) {
      return "SESSION-ID-EXCEPTION";
    }
  }
1008411
def session(self, value):
        """"""

        # unset session token
        if value is None:
            self._session = None
            return

        if not isinstance(value, dict):
            raise ValueError("session info is required")

        session_parsed = {}

        for key in ["session_token", "time", "secret_key"]:
            if key not in value:
                raise ValueError("Missing parameter: {}".format(key))
            session_parsed[key] = value[key]

        for key in ["ekey", "pkey"]:
            # nice to have, but not mandatory
            if key in value:
                session_parsed[key] = value[key]

        self._session = session_parsed
591047
def use_session(self, session_id):
        
        self.session = Session(lgn=self, id=session_id)
        return self.session
1196832
def session_context(fn):
    
    @functools.wraps(fn)
    def wrap(*args, **kwargs):
        session = args[0].Session()  # obtain from self
        result = fn(*args, session=session, **kwargs)
        session.close()
        return result
    return wrap
92038
def remove(name, **kwargs):
    '''
    
    '''

    cmd = 'sysrc -v'

    if 'file' in kwargs:
        cmd += ' -f '+kwargs['file']

    if 'jail' in kwargs:
        cmd += ' -j '+kwargs['jail']

    cmd += ' -x '+name

    sysrcs = __salt__['cmd.run'](cmd)
    if "sysrc: unknown variable" in sysrcs:
        raise CommandExecutionError(sysrcs)
    else:
        return name+" removed"
763117
def get_session():
    
    if hasattr(g, 'session'):
        return g.session
    sess = create_session(bind=current_app.config['DATABASE_ENGINE'])
    try:
        g.session = sess
    except RuntimeError:
        pass
    return sess
869999
def get_session(*, env_vars=None, loop=None):
    
    loop = loop or asyncio.get_event_loop()
    return AioSession(session_vars=env_vars, loop=loop)
903288
def do_session(self, args):
        """"""
        filename = 'Not specified' if self.__session.filename is None \
            else self.__session.filename

        print('{0: <30}: {1}'.format('Filename', filename))
200056
def put(self, *args, **kwargs):
        
        return self.session.put(*args, **self.get_kwargs(**kwargs))
164461
def set_key(cls, k, v):
        
        k = cls.__name__ + "__" + k
        session[k] = v
986962
def auth_interactive(self, username, handler, event, submethods=''):
        
        self.transport.lock.acquire()
        try:
            self.auth_event = event
            self.auth_method = 'keyboard-interactive'
            self.username = username
            self.interactive_handler = handler
            self.submethods = submethods
            self._request_auth()
        finally:
            self.transport.lock.release()
959077
void give(NGSession session) {
    synchronized (lock) {
      if (done) {
        // session is already signalled shutdown and removed from all collections
        return;
      }
      workingPool.remove(session);

      if (idlePool.size() < maxIdleSessions) {
        idlePool.add(session);
        return;
      }
    }
    session.shutdown();
  }
586634
def autorun_get_interactive_session(cmds, **kargs):
    """"""
    sstdout, sstderr = sys.stdout, sys.stderr
    sw = StringWriter()
    try:
        try:
            sys.stdout = sys.stderr = sw
            res = autorun_commands(cmds, **kargs)
        except StopAutorun as e:
            e.code_run = sw.s
            raise
    finally:
        sys.stdout, sys.stderr = sstdout, sstderr
    return sw.s, res
939028
def session(sess_id_or_alias):
    '''
    
    '''
    fields = [
        ('Session ID', 'sess_id'),
        ('Role', 'role'),
        ('Image', 'image'),
        ('Tag', 'tag'),
        ('Created At', 'created_at'),
        ('Terminated At', 'terminated_at'),
        ('Agent', 'agent'),
        ('Status', 'status'),
        ('Status Info', 'status_info'),
        ('Occupied Resources', 'occupied_slots'),
        ('CPU Used (ms)', 'cpu_used'),
        ('Used Memory (MiB)', 'mem_cur_bytes'),
        ('Max Used Memory (MiB)', 'mem_max_bytes'),
        ('Number of Queries', 'num_queries'),
        ('Network RX Bytes', 'net_rx_bytes'),
        ('Network TX Bytes', 'net_tx_bytes'),
        ('IO Read Bytes', 'io_read_bytes'),
        ('IO Write Bytes', 'io_write_bytes'),
        ('IO Max Scratch Size', 'io_max_scratch_size'),
        ('IO Current Scratch Size', 'io_cur_scratch_size'),
        ('CPU Using (%)', 'cpu_using'),
    ]
    if is_legacy_server():
        del fields[3]
    q = 'query($sess_id:String) {' \
        '  compute_session(sess_id:$sess_id) { $fields }' \
        '}'
    q = q.replace('$fields', ' '.join(item[1] for item in fields))
    v = {'sess_id': sess_id_or_alias}
    with Session() as session:
        try:
            resp = session.Admin.query(q, v)
        except Exception as e:
            print_error(e)
            sys.exit(1)
        if resp['compute_session']['sess_id'] is None:
            print('There is no such running compute session.')
            return
        print('Session detail:\n---------------')
        for i, value in enumerate(resp['compute_session'].values()):
            if fields[i][1] in ['mem_cur_bytes', 'mem_max_bytes']:
                value = round(value / 2 ** 20, 1)
            print(fields[i][0] + ': ' + str(value))
579612
def close_session(self):
        
        with self._graph.as_default():
            self._sess.close()
            self._sess = None
695153
def set_uservar(self, user, name, value):
        
        self._session.set(user, {name: value})