wrap session methods
351182
function wrapmethods(sess) {
  var _save = sess.save;

  function save() {
    debug('saving %s', this.id);
    savedHash = hash(this);
    _save.apply(this, arguments);
  }

  Object.defineProperty(sess, 'save', {
    configurable: true,
    enumerable: false,
    value: save,
    writable: true
  });
}
215259
def user_method(user_event):
    """"""
    def wrapper(self, *args):
        stdin = self.stdin
        is_sock = isinstance(stdin, RemoteSocket)
        try:
            try:
                if is_sock and not stdin.connect():
                    return
                return user_event(self, *args)
            except Exception:
                self.close()
                raise
        finally:
            if is_sock and stdin.closed():
                self.do_detach(None)
    return wrapper
1284550
function generateSession() {
    const session = {}
    //you can alter the cookie options in nexts
    session.cookie = {}
    for (const prop in cookie) {
      session.cookie[prop] = cookie[prop]
    }
    compatMaxage(session.cookie)
    return session
  }
186965
def refresh_session_if_necessary(f):
    

    @functools.wraps(f)
    def wrapped(self, *args, **kwargs):
        try:
            result = f(self, *args, **kwargs)
        except Exception as ex:
            if hasattr(ex, 'code') and ex.code in (401, 403):
                self.refresh_session()
                # retry now
                result = f(self, *args, **kwargs)
            else:
                raise ex

        return result

    return wrapped
968547
def db_access_point(func):
    
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        """
        Wrapper responsible for handling
        sessions
        """
        session = self.session_handler.get_session()
        try:
            resp = func(self, session, *args, **kwargs)
        except Exception as exc:
            self.session_handler.handle_session(session, exc=exc)
            raise exc
        else:
            self.session_handler.handle_session(session)
            return resp
    return wrapper
301997
function wrapSuccess(result) {
      return {
        url: page.url,
        body: getContent(),
        headers: pageInformation.response.headers,
        status: pageInformation.response.status,
        error: result.error ? helpers.serializeError(result.error) : null,
        data: result.data
      };
    }
332732
function generateSession() {
    const session = {};
    // you can alter the cookie options in nexts
    session.cookie = {};
    Object.keys(cookie).forEach((prop) => {
      session.cookie[prop] = cookie[prop];
    });
    return session;
  }
91839
function wrapBehavior(obj, action) {
  if (obj['_wrap_' + action]) {
    return obj['_wrap_' + action];
  }
  const method = e => {
    obj[action](e);
  };
  obj['_wrap_' + action] = method;
  return method;
}
897056
def wrap(http_method, url, params)
      params = params.merge(:appid => @appid)
      params[:sig] = Gateway.signature( "#{@appkey}&", Gateway.make_source(http_method.to_s.upcase, url, params) )
      params
    end
906146
function wrap(callback, name) {
  var isLST
    , stack
    , d

  if ('function' !== typeof callback || callback && callback.name === '_trycatchOnError') return callback

  isLST = options['long-stack-traces']
  d = process.domain
  if (isLST) {
    stack = getStack(d)
  }

  // Inherit from callback for when properties are added
  newCallback.__proto__ = callback
  return newCallback

  function newCallback() {
    if (isLST && d) d.currentStack = stack

    runInDomain(d, callback, trycatchitApply, [this, arguments])
  }
}
227504
function wrap(callback, name) {
  var isLST
    , stack
    , d
    , oldStack

  if ('function' !== typeof callback || callback && callback.name === '_trycatchOnError') return callback

  isLST = options['long-stack-traces']
  d = process.domain
  if (isLST) {
    oldStack = trycatch.currentStack
    stack = getUpdatedCurrentStack()
  }

  // Inherit from callback for when properties are added
  _trycatchNewCallback.__proto__ = callback
  _trycatchNewCallback._trycatchCurrentStack = stack
  return _trycatchNewCallback

  function _trycatchNewCallback() {
    // Don't stomp stack in synchronous EventEmitter case
    if (isLST) {
      if (trycatch.currentStack !== oldStack) {
        trycatch.currentStack = stack
      } else if (trycatch.currentStack !== null) {
        trycatch.currentStack = stack
      }
    }
    runInDomain(d, callback, trycatchit, this, arguments)
  }
}
1275023
def _wrap(method: Callable, wrapper: Callable) -> Callable:
        
        def wrapped(*args, **kwargs):
            return wrapper(method, *args, **kwargs)
        return wrapped
359688
def _instantiate_session(self, method_name, proxy=None, *args, **kwargs):
        """"""
        if 'manager' in kwargs:
            session_class = getattr(kwargs['manager'], method_name)
            del kwargs['manager']
        else:
            session_class = getattr(self._provider_manager, method_name)
        if proxy is None:
            try:
                return session_class(bank_id=self._catalog_id, *args, **kwargs)
            except AttributeError:
                return session_class(*args, **kwargs)
        else:
            try:
                return session_class(bank_id=self._catalog_id, proxy=proxy, *args, **kwargs)
            except AttributeError:
                return session_class(proxy=proxy, *args, **kwargs)
303926
public static function wrapped_session_flush(&$session_object)
    {
        global $TSUGI_SESSION_OBJECT;
        if ( $session_object === null && isset($TSUGI_SESSION_OBJECT) ) $session_object = $TSUGI_SESSION_OBJECT;
        if ( is_object($session_object) ) {
            $session_object->flush();
            return;
        }
        if ( is_array($session_object) ) {
            foreach($session_object as $k => $v ) {
                unset($session_object[$k]);
            }
            for ($i = 0; $i < count($session_object); $i++) {
                unset($session_object[$i]);
            }
        }
        session_unset();
    }
498904
function wrapper() {
        context = this;
        args = arguments;
        if (!no_postpone) {
          cancel();
          timeout = $timeout(ping, wait);
        } else if (executed) {
          executed = false;
          timeout = $timeout(ping, wait);
        }
      }
638251
def _tmp_session(self, session, close=True):
        """"""
        if session:
            # Don't call end_session.
            yield session
            return

        s = self._ensure_session(session)
        if s and close:
            with s:
                # Call end_session when we exit this scope.
                yield s
        elif s:
            try:
                # Only call end_session on error.
                yield s
            except Exception:
                s.end_session()
                raise
        else:
            yield None
330092
public static function wrapped_session_get($session_object,$key,$default=null)
    {
        global $TSUGI_SESSION_OBJECT;
        if ( $session_object === null && isset($TSUGI_SESSION_OBJECT) ) $session_object = $TSUGI_SESSION_OBJECT;
        if ( is_object($session_object) ) {
            return $session_object->get($key,$default);
        }
        if ( is_array($session_object) ) {
            if ( isset($session_object[$key]) ) return $session_object[$key];
            return $default;
        }
        if ( ! isset($_SESSION) ) return $default;
        if ( ! isset($_SESSION[$key]) ) return $default;
        return $_SESSION[$key];
    }