Skip to content

Commit

Permalink
Call gather correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Dec 14, 2019
1 parent 6685116 commit 125cc79
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions server/gameconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def _handle_lobby_state(self):
if peer != self and peer.player != self.game.host:
self._logger.debug("%s connecting to %s", self.player, peer)
tasks.append(self.connect_to_peer(peer))
await asyncio.gather(tasks)
await asyncio.gather(*tasks)
except Exception as e: # pragma: no cover
self._logger.exception(e)

Expand Down Expand Up @@ -539,7 +539,7 @@ async def disconnect_all_peers(self):
tasks.append(peer.send_DisconnectFromPeer(self.player.id))

try:
await asyncio.gather(tasks)
await asyncio.gather(*tasks)
except Exception: # pragma no cover
self._logger.exception(
"peer_sendDisconnectFromPeer failed for player %i",
Expand Down
3 changes: 1 addition & 2 deletions server/matchmaker/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import time
from typing import List, Optional, Tuple

from server.rating import RatingType
from trueskill import Rating, quality

from .. import config
from ..decorators import with_logger
from ..players import Player
from server.rating import RatingType


@with_logger
Expand Down Expand Up @@ -71,7 +71,6 @@ def has_no_top_player(self) -> bool:
max_rating = max(map(lambda rating_tuple: rating_tuple[0], self.ratings))
return max_rating < config.TOP_PLAYER_MIN_RATING


@property
def ratings(self):
ratings = []
Expand Down
2 changes: 1 addition & 1 deletion server/servercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def broadcast_raw(self, message, validate_fn=lambda a: True):
if validate_fn(conn):
tasks.append(proto.send_raw(message))

await asyncio.gather(tasks)
await asyncio.gather(*tasks)

async def client_connected(self, stream_reader, stream_writer):
self._logger.debug("%s: Client connected", self)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from unittest import mock

import asynctest
import pytest
from asynctest import CoroutineMock
from server import GameStatsService
from server.game_service import GameService
from server.gameconnection import GameConnection, GameConnectionState
from server.games import Game
from server.geoip_service import GeoIpService
from server.ladder_service import LadderService
import asynctest
from asynctest import CoroutineMock


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_ladder.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def test_start_game_called_on_match(ladder_service: LadderService,
await ladder_service.start_search(p1, Search([p1]), 'ladder1v1')
await ladder_service.start_search(p2, Search([p2]), 'ladder1v1')

await asyncio.sleep(1)
await asyncio.sleep(2)

ladder_service.inform_player.assert_called()
ladder_service.start_game.assert_called_once()
Expand Down

0 comments on commit 125cc79

Please sign in to comment.