Prepare the session after the connection has been established.
194640
def session_preparation(self):
        """"""
        self.ansi_escape_codes = True
        self._test_channel_read()
        self.set_base_prompt()
        self.disable_paging()
        self.set_terminal_width(command="terminal width 511")
        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()
1214985
def session_preparation(self):
        
        delay_factor = self.select_delay_factor(delay_factor=0)
        i = 1
        while i <= 4:
            # Comware can have a banner that prompts you to continue
            # 'Press Y or ENTER to continue, N to exit.'
            time.sleep(0.5 * delay_factor)
            self.write_channel("\n")
            i += 1

        time.sleep(0.3 * delay_factor)
        self.clear_buffer()
        self._test_channel_read(pattern=r"[>\]]")
        self.set_base_prompt()
        command = self.RETURN + "screen-length disable"
        self.disable_paging(command=command)
        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()
830723
public synchronized void connectionEstablished (
        PresentsConnection conn, Name authname, AuthRequest req, AuthResponse rsp)
    {
        String type = authname.getClass().getSimpleName();

        // see if a session is already registered with this name
        PresentsSession session = getClient(authname);

        if (session != null) {
            //log.info("Resuming session", "type", type, "who", authname, "conn", conn);
            session.resumeSession(req, conn);

        } else {
            log.info("Session initiated", "type", type, "who", authname, "conn", conn);
            // figure out our session class
            Class<? extends PresentsSession> sessionClass = null;
            for (SessionFactory factory : _factories) {
                if ((sessionClass = factory.getSessionClass(req)) != null) {
                    break;
                }
            }
            // create a new session and stick'em in the table
            session = _injector.getInstance(sessionClass);
            session.startSession(authname, req, conn, rsp.authdata);

            // map their session instance
            synchronized (_usermap) {
                // we refetch the authname from the session for use in the map in case it decides
                // to do something crazy like rewrite it in startSession()
                _usermap.put(session.getAuthName(), session);
            }
        }

        // map this connection to this session
        _conmap.put(conn, session);
    }
60707
async def prepare_conn(self, conn):
        """"""

        client_id = str(uuid.uuid4())
        monitor = functools.partial(self.send_event, client_id)

        self._logger.info("New client connection: %s", client_id)

        self.service_manager.add_monitor(monitor)

        self.clients[client_id] = dict(connection=conn, monitor=monitor)
        return client_id
19420
def session_preparation(self):
        """"""
        self._test_channel_read()
        self.set_base_prompt()
        self.tmsh_mode()
        self.set_base_prompt()
        self.disable_paging(
            command="modify cli preference pager disabled display-threshold 0"
        )
        self.clear_buffer()
        cmd = 'run /util bash -c "stty cols 255"'
        self.set_terminal_width(command=cmd)
758309
def init(cls, conn_string=None):
        """"""
        if conn_string:
            _update_meta(conn_string)
            # We initialize the engine within the models module because models'
            # schema can depend on which data types are supported by the engine
            Meta.Session = new_sessionmaker()
            Meta.engine = Meta.Session.kw["bind"]
            logger.info(
                f"Connecting user:{Meta.DBUSER} "
                f"to {Meta.DBHOST}:{Meta.DBPORT}/{Meta.DBNAME}"
            )
            Meta._init_db()

        if not Meta.log_path:
            init_logging()

        return cls
679256
synchronized void prepareCommit(Session session) {

        RowActionBase action = this;

        do {
            if (action.session == session && action.commitTimestamp == 0) {
                action.prepared = true;
            }

            action = action.next;
        } while (action != null);
    }
33021
public function init()
    {

        // initialize the prepared statements
        $this->bundleSelectionStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::BUNDLE_SELECTION));
    }
743763
def prepare(self):
        
        # Maybe the Brok is a old daemon one or was already prepared
        # if so, the data is already ok
        if hasattr(self, 'prepared') and not self.prepared:
            self.data = unserialize(self.data)
            if self.instance_id:
                self.data['instance_id'] = self.instance_id
        self.prepared = True
1336948
private function prepare()
    {
        $session = new Session();
        $session->start();

        $request = Request::createFromGlobals();
        $request->setSession($session);

        $this->requestStack->push($request);
        $this->tokenStorage->setToken(
            new AnonymousToken('anonymous', 'anonymous', ['ROLE_ADMINISTRATOR'])
        );
    }
974610
private function initConnection() {
		if($this->isCliMode()) {
			return;
		}

		$this->initServerCookie();
		$this->client = $this->initClient();

		if($this->client) {
			ob_start();
			$this->isActiveClient = true;
			$this->registerFlushOnShutDown();
			$this->setHeadersLimit(isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false
				? 4096 // default headers limit for Nginx
				: 8192 // default headers limit for all other web-servers
			);
			$this->listenGetPostponedResponse();
			$this->postponeResponseId = $this->setPostponeHeader();
		}
	}
224085
def on_connect(self, connection):
        ""
        self._stream = connection._reader
        self._buffer = SocketBuffer(self._stream, self._read_size)
        if connection.decode_responses:
            self.encoding = connection.encoding
1119651
def session_preparation(self):
        """"""
        self._test_channel_read()
        self.set_base_prompt()
        if self.secret:
            self.enable()
        else:
            self.asa_login()
        self.disable_paging(command="terminal pager 0")
        if self.allow_auto_change:
            try:
                self.send_config_set("terminal width 511")
            except ValueError:
                # Don't fail for the terminal width
                pass

        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()
735202
public function init()
    {

        // initialize the prepared statements
        $this->customerIntsStmt =
            $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_INTS));
    }
35600
public function onReady()
    {
        if ($this->pool->config->protologging->value) {
            Daemon::log("New connection\n\n");
        }
        $e = explode('.', $this->protover);
        $packet = pack('nn', $e[0], $e[1]);

        if (strlen($this->user)) {
            $packet .= "user\x00" . $this->user . "\x00";
        }

        if (strlen($this->dbname)) {
            $packet .= "database\x00" . $this->dbname . "\x00";
        }
        elseif (strlen($this->path)) {
            $packet .= "database\x00" . $this->path . "\x00";
        }

        if (strlen($this->options)) {
            $packet .= "options\x00" . $this->options . "\x00";
        }

        $packet .= "\x00";
        $this->sendPacket('', $packet);
    }
1121062
private function startSession()
    {
        if ('' === session_id()) {
            // no session active
            session_set_cookie_params(
                $this->sessionOptions['lifetime'],
                $this->sessionOptions['path'],
                $this->sessionOptions['domain'],
                $this->sessionOptions['secure'],
                $this->sessionOptions['httponly']
            );
            session_start();
        }
    }
1065633
def prepare_model(self, sess, allow_initialize=True):
    """"""
    if self._follower:
      self.wait_for_initialization()
    else:
      self._init_model(sess, allow_initialize)

    if sess is not self._sess:
      if self.threads:
        raise ValueError('You must call stop_queues() before '
                         'starting a new session with QueueRunners.')
      self._sess = sess
    self._start_threads(sess)