|coro|

        Loads the players game queues
354584
def load_queues(self):
        """"""

        stats = yield from self._fetch_statistics("casualpvp_matchwon", "casualpvp_matchlost", "casualpvp_timeplayed",
                                                  "casualpvp_matchplayed", "casualpvp_kills", "casualpvp_death",
                                                  "rankedpvp_matchwon", "rankedpvp_matchlost", "rankedpvp_timeplayed",
                                                  "rankedpvp_matchplayed", "rankedpvp_kills", "rankedpvp_death")

        self.ranked = GameQueue("ranked")
        self.casual = GameQueue("casual")

        for gq in (self.ranked, self.casual):
            statname = gq.name + "pvp_"

            gq.won = stats.get(statname + "matchwon", 0)
            gq.lost = stats.get(statname + "matchlost", 0)
            gq.time_played = stats.get(statname + "timeplayed", 0)
            gq.played = stats.get(statname + "matchplayed", 0)
            gq.kills = stats.get(statname + "kills", 0)
            gq.deaths = stats.get(statname + "death", 0)
121247
function Game() {

        // un-populated instance of Array2d
        this.map = new RL.Map(this);
        this.entityManager = new RL.ObjectManager(this, RL.Entity);
        this.renderer = new RL.Renderer(this);
        this.console = new RL.Console(this);
        this.lighting = new RL.LightingROT(this);

        // player purposefully not added to entity manager (matter of preference)
        this.player = new RL.Player(this);

        // make sure "this" is this instance of Game when this.onKeyAction is called
        this.onKeyAction = this.onKeyAction.bind(this);
        this.onClick = this.onClick.bind(this);
        this.onHover = this.onHover.bind(this);

        this.input = new RL.Input(this.onKeyAction);
        this.mouse = new RL.Mouse(this.onClick, this.onHover);

        var el = this.renderer.canvas;
        this.mouse.startListening(el);
    }
439675
public void connectAll() {
        for (int i = 0; i < size(); i++) {
            if (i == 0) {
                players[i].connect(true);
            } else if (i >= 1) {
                try {
                    players[i].connect(false);
                } catch (Exception ex) {
                    players[i].handleError(ex.getMessage());
                }
            }
            pause(500);
        }
        if (hasCoach) {
            try {
                coach.connect();
            } catch (Exception ex) {
                coach.handleError(ex.getMessage());
            }
            pause(500);
        }
    }
1055553
function StartQueue() {
  data = callback = originalData = null;       //  clear existing equation, if any
  errors = sErrors; sErrors = [];              //  clear any errors
  if (!queue.length) return;    //  return if nothing to do

  serverState = STATE.BUSY;
  var result = {}, $$ = window.Array;

  //
  //  Get the math data and callback
  // and set the content with the proper script type
  //
  var item = queue.shift();
  data = item[0]; callback = item[1]; originalData = item[2];
  content.innerHTML = "";
  MathJax.HTML.addElement(content,"script",{type: "math/"+TYPES[data.format]},[data.math]);
  html.setAttribute("xmlns:"+data.xmlns,"http://www.w3.org/1998/Math/MathML");

  //
  //  Set the SVG and TeX parameters
  //  according to the requested data
  //
  var CHTML = MathJax.OutputJax.CommonHTML,
      SVG = MathJax.OutputJax.SVG,
      TEX = MathJax.InputJax.TeX,
      HUB = MathJax.Hub;

  SVG.defaultEx = CHTML.defaultEx = data.ex;
  SVG.defaultWidth = CHTMLdefaultWidth = data.width * data.ex;
  SVG.config.linebreaks.automatic = CHTML.config.linebreaks.automatic = data.linebreaks;
  SVG.config.linebreaks.width = CHTML.config.linebreaks.width = data.width * data.ex;
  SVG.config.useFontCache = data.useFontCache;
  SVG.config.useGlobalCache = data.useGlobalCache;
  TEX.config.equationNumbers.autoNumber = data.equationNumbers;

  //
  // Set the state from data.state or clear it
  //
  GetState(data.state);

  //
  // Get the renderer to use
  //
  var renderer = (
      (data.html || data.htmlNode || data.css) ? "CommonHTML" :
          (data.svg || data.svgNode) ? "SVG" : "None"
  );

  //
  //  Set up a timeout timer to restart MathJax if it runs too long,
  //  Then push the Typeset call, the MathML, speech, and SVG calls,
  //  and our TypesetDone routine
  //
  timer = setTimeout(RestartMathJax,data.timeout);
  HUB.Queue(
    $$(SetRenderer,renderer),
    $$("Process",HUB),
    $$(TypesetDone,result),
    $$(GetSpeech,result),
    $$(GetMML,result),
    $$(GetHTML,result),
    $$(RerenderSVG,result),
    $$(GetSVG,result),
    $$(ReturnResult,result)
  );
}
668806
def sync(coro, timeout=None):
    '''
    
    '''
    loop = initloop()
    return asyncio.run_coroutine_threadsafe(coro, loop).result(timeout)
69514
public function ingameCoop()
    {
        foreach ($this->owner->players as $player) {
            if ($player->isCooping) {
                return true;
            }
        }
        return false;
    }
376175
def _on_connect(self, participant):
        
        lock = get_redis_lock()
        if not lock:
            lock = fake_lock()

        with lock:
            self.refresh_from_db()
            if self.ran_ready_function:
                return
            for player in self.get_players():
                if Connection.objects.filter(participant__code=player.participant.code).count() == 0:
                    return
                    
            self.when_all_players_ready()
            self.ran_ready_function = timezone.now()
            self.save()

            self.send('state', 'period_start')

            if self.period_length():
                # TODO: Should replace this with something like Huey/Celery so it'll survive a server restart.
                self._timer = threading.Timer(
                    self.period_length(),
                    lambda: self.send('state', 'period_end'))
                self._timer.start()
1307303
function main()
{
	aqParseOptions();

	aq_queuename = 'amqpsnoop.' + Math.random() * 10000000;
	aq_amqp = mod_amqp.createConnection(aq_broker);
	aq_amqp.on('ready', function () {
		aq_queue = aq_amqp.queue(aq_queuename,
		    { exclusive: true }, function () {
			aq_queue.bind(aq_exchange, aq_routekey);
			aq_queue.subscribe(aqReceiveMessage);
		    });
	});
}
725886
private void loadQueuedFlows() throws ExecutorManagerException {
    final List<Pair<ExecutionReference, ExecutableFlow>> retrievedExecutions =
        this.executorLoader.fetchQueuedFlows();
    if (retrievedExecutions != null) {
      for (final Pair<ExecutionReference, ExecutableFlow> pair : retrievedExecutions) {
        this.queuedFlows.enqueue(pair.getSecond(), pair.getFirst());
      }
    }
  }
1230469
def parallel_fill(self, games, threads=8):
        
        games.sort(key=os.path.basename)
        # A couple extra in case parsing fails
        max_games = int(self.max_size / self.sampling_frac / 200) + 480
        if len(games) > max_games:
            games = games[-max_games:]

        with mp.Pool(threads) as pool:
            res = tqdm(pool.imap(self.func, games), total=len(games))
            self.examples.extend(itertools.chain.from_iterable(res))
        print("Got", len(self.examples), "examples")
280846
def participants(self):
        """"""
        ret = []
        for p in self.players:
            try:
                if     p.isComputer: ret.append(p)
                if not p.isObserver: ret.append(p) # could cause an exception if player isn't a PlayerPreGame
            except AttributeError: pass
        return ret
493785
function WaitingRoom(config) {
    // Supercall
    HostRoom.call(this, 'Waiting', config);
    if (!this.logicPath) this.logicPath = ngt.resolve('waitroom/waitroom.js');

    /**
     * ### WaitingRoom.roomOpen
     *
     * Flag indicating whether the room is open
     */
    this.roomOpen = config.roomOpen || true;

    /**
     * ### WaitingRoom.dispatching
     *
     * Numeric flag indicating whether the room is dispatching a new game
     *
     *
     */
    this.dispatching = 0;

    /**
     * ### WaitingRoom.timeOuts
     *
     * Array of setTimeout return values indexed by playerIDs
     */
    this.timeOuts = {};

    /**
     * ### WaitingRoom.notifyTimeout
     *
     * A timeout to notify players about updates in the number of players
     *
     * @see WaitingRoom.notifyPlayers
     */
    this.notifyTimeout = null;

    /**
     * ### WaitingRoom.numberOfDispatches
     *
     * Non-negative integer indicating the number of game dispatches
     */
    this.numberOfDispatches = config.numberOfDispatches || 0;

    /**
     * ### WaitingRoom.lastGameRoom
     *
     * Reference to the last created game room
     */
    this.lastGameRoom = null;

    /**
     * ### WaitingRoom.GROUP_SIZE
     *
     * Positive non-zero integer indicating the size of each group
     */
    this.GROUP_SIZE = null;

    /**
     * ### WaitingRoom.POOL_SIZE
     *
     * Positive non-zero integer indicating number of clients for group forming
     */
    this.POOL_SIZE = null;

    /**
     * ### WaitingRoom.DISCONNECT_IF_NOT_SELECTED
     *
     * Boolean or null, indicating whether unselected players are disconnected
     */
    this.DISCONNECT_IF_NOT_SELECTED = null;

    /**
     * ### WaitingRoom.timeOuts
     *
     * Array of setTimeout return values indexed by playerIDs
     */
    this.N_GAMES = null;

    /**
     * ### WaitingRoom.START_DATE
     *
     * Time and date of game start
     *
     * Must be valid input for `Date` constructor
     */
    this.START_DATE = null;

    /**
     * ### WaitingRoom.EXECUTION_MODE
     *
     * String indicating execution mode
     *
     * In the execution mode `'TIMEOUT`, one waits until the time is up, then
     * it will be checked whether enough players are there to start the game.
     * In the execution mode `WAIT_FOR_N_PLAYERS`, the game starts right away
     * if there are the desired number of players. Otherwise, when the time is
     * up, it will be checked if there are at least a certain minimum number of
     * players to start the game. If the execution mode is `WAIT_FOR_DISPATCH`,
     * it simply waits for a dispatch command from monitor, the number of
     * connected players is not taken into account.
     */
    this.EXECUTION_MODE = null;

    /**
     * ### WaitingRoom.MAX_WAIT_TIME
     *
     * Positive non-zero integer indicating max number of milliseconds to start
     *
     * Cannot be defined at the same time as `WaitingRoom.START_DATE`
     */
    this.MAX_WAIT_TIME = null;

    /**
     * ### WaitingRoom.ON_TIMEOUT
     *
     * Callback to be executed client-side after waiting time has elapsed
     */
    this.ON_TIMEOUT = null;

    /**
     * ### WaitingRoom.ON_TIMEOUT_SERVER
     *
     * Callback to be executed after a timeout has expired
     */
    this.ON_TIMEOUT_SERVER = null;

    /**
     * ### WaitingRoom.ON_OPEN
     *
     * Callback to be executed when the waiting room becomes open
     */
    this.ON_OPEN = null;

    /**
     * ### WaitingRoom.ON_CLOSE
     *
     * Callback to be executed when the waiting room becomes close
     */
    this.ON_CLOSE = null;

    /**
     * ### WaitingRoom.ON_CONNECT
     *
     * Callback to be executed when a player connects
     */
    this.ON_CONNECT = null;

    /**
     * ### WaitingRoom.ON_DISCONNECT
     *
     * Callback to be executed when a player disconnects
     */
    this.ON_DISCONNECT = null;

    /**
     * ### WaitingRoom.ON_INIT
     *
     * Callback to be executed after the settings have been parsed
     */
    this.ON_INIT = null;

    /**
     * ### WaitingRoom.ON_DISPATCH
     *
     * Callback to be executed just before starting dispatching
     *
     * Receives the options of the dispatch call as second param
     */
    this.ON_DISPATCH = null;

    /**
     * ### WaitingRoom.ON_DISPATCHED
     *
     * Callback to be executed at the end of a dispatch call
     */
    this.ON_DISPATCHED = null;

    /**
     * ### WaitingRoom.ON_FAILED_DISPATCH
     *
     * Callback to be executed if a dispatch attempt failed
     */
    this.ON_FAILED_DISPATCH = null;

    /**
     * ### WaitingRoom.CHOSEN_TREATMENT
     *
     * String or undefined indicating chosen treatment
     */
    this.CHOSEN_TREATMENT = null;

    /**
     * ### WaitingRoom.OVERWRITE_CHOSEN_TREATMENT
     *
     * If set, it overwrites chosen treatment for the next dispatch only
     *
     * When dispatch is invoked remotely, users may specify a treatment.
     *
     * It is set to null at every dispatch.
     *
     * @see WaitingRoom.ALLOW_SELECT_TREATMENT
     */
    this.OVERWRITE_CHOSEN_TREATMENT = null;

    /**
     * ### WaitingRoom.PLAYER_SORTING
     *
     * Callback to sort the list of players before dispatching
     *
     * If NULL, random sorting takes place. Default: 'timesNotSelected'
     */
    this.PLAYER_SORTING = WaitingRoom.sortingCallbacks.timesNotSelected;

    /**
     * ### WaitingRoom.PING_BEFORE_DISPATCH
     *
     * If TRUE, all players are pinged before a dispatch (Default: TRUE)
     *
     * Non-responding clients are disconnected.
     *
     * If only one player is needed and mode is 'WAIT_FOR_N_PLAYERS',
     * pinging is skipped.
     *
     * @see PING_MAX_REPLY_TIME
     */
    this.PING_BEFORE_DISPATCH = true;

    /**
     * ### WaitingRoom.PING_MAX_REPLY_TIME
     *
     * The time to wait to receive a ping back
     *
     * Clients will be disconnected if they do not reply in time.
     *
     * @see PING_BEFORE_DISPATCH
     */
    this.PING_MAX_REPLY_TIME = 3000;

    /**
     * ### WaitingRoom.PING_DISPATCH_ANYWAY
     *
     * If TRUE, dispatch continues even if disconnections occur during PING
     *
     * @see PING_BEFORE_DISPATCH
     * @see PING_MAX_REPLY_TIME
     */
    this.PING_DISPATCH_ANYWAY = false;

    /**
     * ### WaitingRoom.TEXTS
     *
     * List of texts replacing default ones in WaitingRoom widget
     *
     * @see WaitingRoom.texts (widget)
     */
    this.TEXTS = {};

    /**
     * ### WaitingRoom.SOUNDS
     *
     * List of paths to sounds replacing default ones in WaitingRoom widget
     *
     * @see WaitingRoom.sounds (widget)
     */
    this.SOUNDS = {};

    /**
     * ### WaitingRoom.PAGE_TITLE
     *
     * Sets the page title, optionally adds to page
     *
     */
    this.PAGE_TITLE =  { title: 'Welcome!', addToBody: true };

    /**
     * ### WaitingRoom.isPingInProgress
     *
     * Flag to indicate whether currently pinging for unresponsive players
     */
    this.isPingInProgress = false;

    /**
     * ### WaitingRoom.suspendedPings
     *
     * Flag to indicate whether currently pinging for unresponsive players
     */
    this.suspendedPings = [];

    /**
     * ### WaitingRoom.closeAfterDispatch
     *
     * Flag that the waiting room will close after next dispatch
     *
     * Note: waiting room can dispatch multiple groups, and then will close.
     */
    this.closeAfterDispatch = false;

    /**
     * ### WaitingRoom.makeClientTimeouts
     *
     * TRUE, if it makes timeouts for connecting clients
     *
     * Makes timeout if START_DATE or MAX_WAIT_TIME is set.
     *
     * @see WaitingRoom.makeTimeOut
     * @see WaitingRoom.clearTimeOut
     * @see WaitingRoom.START_DATE
     * @see WaitingRoom.MAX_WAIT_TIME
     */
    this.makeClientTimeOuts = false;

    /**
     * ### WaitingRoom.NOTIFY_INTERVAL
     *
     * The number of milliseconds to wait before sending a player-update message
     *
     * @see WaitingRoom.notifyPlayerUpdate
     */
    this.NOTIFY_INTERVAL = 200;

    /**
     * ### WaitingRoom.availableTreatments
     *
     * List of available treatments including treatment callbacks
     *
     * Maps names to descriptions.
     */
    this.availableTreatments = (function(that) {
        var o, t, key;
        if (that.gameLevel) {
            // Treatments are not yet parsed.
            t = that.game.levels[that.gameLevel].settings.treatments;
        }
        else {
            // Treatments are already parsed at this point.
            t = that.game.settings;
        }
        // Hard-cloned, check names in treatmentCallbacks.
        o = {
            treatment_random:
            WaitingRoom.treatmentCallbacks['treatment_random'],
            treatment_rotate:
            WaitingRoom.treatmentCallbacks['treatment_rotate']
        };
        for (key in t) {
            if (t.hasOwnProperty(key)) {
                o[key] = t[key].description || 'no description';
            }
        }
        return o;
    })(this);
}
586364
public function load()
    {
        $request = new request(self::STEAM_MATCH_URL, array('match_id' => $this->getMatchId()));
        $matchInfo = $request->send();
        if (null === $matchInfo) {
            return null;
        }
        $match = new Match();
        $players = array();
        foreach ($matchInfo->players->player as $key => $player) {
            $players[] = $player;
        }
        $data = (array)$matchInfo;
        unset($data['players']);
        $data['start_time'] = date('Y-m-d H:i:s', $data['start_time']);
        $data['radiant_win'] = ($data['radiant_win'] === 'true') ? '1' : '0';
        $match->setArray($data);
        // slots info
        foreach ($players as $player) {
            $data = (array)$player;
            $data['match_id'] = $this->getMatchId();
            $slot = new Slot();
            $slot->setArray($data);
            // additional_units
            if (array_key_exists('additional_units', $data)) {
                $slot->setAdditionalUnitItems((array)($data['additional_units']->unit));
            }
            // abilities
            if (array_key_exists('ability_upgrades', $data)) {
                $d = (array)$data['ability_upgrades'];
                $abilitiesUpgrade = $d['ability'];
                if (!is_array($abilitiesUpgrade)) {
                    $abilitiesUpgrade = array($abilitiesUpgrade);
                }
                foreach ($abilitiesUpgrade as $k => $v) {
                    $abilitiesUpgrade[$k] = (array)$abilitiesUpgrade[$k];
                }
                $slot->setAbilitiesUpgrade($abilitiesUpgrade);
            }
            $match->addSlot($slot);
        }
        if (isset($matchInfo->picks_bans)) {
            $picksBans = (array)$matchInfo->picks_bans;
            foreach ($picksBans['pick_ban'] as $k => $v) {
                $picksBans['pick_ban'][$k] = (array)$v;
                $picksBans['pick_ban'][$k]['is_pick'] = filter_var($picksBans['pick_ban'][$k]['is_pick'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
            }
            $match->setAllPickBans($picksBans['pick_ban']);
        }
        return $match;
    }
789169
def run(self, *coros):
        
        tasks = [
            asyncio.ensure_future(coro()) for coro in coros
        ]
        done, _ = self.loop.run_until_complete(asyncio.wait(tasks))
        return [t.result() for t in done]
920351
function loadUsers (startId, orgId, teamId, callback) {
  // insert users
  console.log('inserting users ' + startId + ' to ' + (startId + NUM_USERS_PER_TEAM - 1) + ' into team: ' + teamId)

  var userSql = 'INSERT INTO users (id, name, org_id, metadata)\nVALUES\n'
  var userTeamSql = 'INSERT INTO team_members (user_id, team_id)\nVALUES\n'
  for (var id = startId; id < (startId + NUM_USERS_PER_TEAM); id++) {
    userSql += "('" + id + "', 'USER_" + id + "', '" + orgId + "'," + getMetaData(id, orgId) + ')'
    userTeamSql += "('" + id + "', '" + teamId + "')"

    if (id === startId + NUM_USERS_PER_TEAM - 1) {
      userSql += ';'
      userTeamSql += ';'
    } else {
      userSql += ',\n'
      userTeamSql += ',\n'
    }
  }

  var fixturesSQL = 'BEGIN;\n'
  fixturesSQL += userSql + '\n'
  fixturesSQL += userTeamSql + '\n'
  fixturesSQL += 'COMMIT;\n'

  client.query(fixturesSQL, function (err, result) {
    if (err) {
      callback(err)
    } else {
      console.log(chalk.green('success inserting users ' + startId +
        ' to ' + (startId + NUM_USERS_PER_TEAM - 1)))
      if (teamId < NUM_TEAMS + TEAM_START_ID - 1) {
        loadUsers(id, orgId, teamId + 1, callback)
      } else {
        loadVolumeDataEnd(callback)
      }
    }
  })
}
1105278
def load_agents(self, config_file=None):
        
        if config_file is not None:
            self.overall_config = config_file
        self.agents.clear()
        num_participants = get_num_players(self.overall_config)
        try:
            for i in range(num_participants):
                self.load_agent(i)
        except BaseException as e:
            raise ValueError(f"{str(e)}\nPlease check your config files! {self.overall_config_path}")
525051
def requestCreateDetails(self):
        """"""
        createReq = sc_pb.RequestCreateGame( # used to advance to Status.initGame state, when hosting
            realtime    = self.realtime,
            disable_fog = self.fogDisabled,
            random_seed = int(time.time()), # a game is created using the current second timestamp as the seed
            local_map   = sc_pb.LocalMap(map_path=self.mapLocalPath,
                                         map_data=self.mapData))
        for player in self.players:
            reqPlayer = createReq.player_setup.add() # add new player; get link to settings
            playerObj = PlayerPreGame(player)
            if playerObj.isComputer:
                reqPlayer.difficulty    = playerObj.difficulty.gameValue()
            reqPlayer.type              = c.types.PlayerControls(playerObj.control).gameValue()
            reqPlayer.race              = playerObj.selectedRace.gameValue()
        return createReq # SC2APIProtocol.RequestCreateGame