def __init__(self, game_id, boxscore=None, playbyplays=None):
self.game_id = game_id
self._boxscore = boxscore
self._playbyplay = playbyplays
global _async_fetch
if not self._boxscore or not self._playbyplay:
api = Api()
if not _async_fetch:
self._boxscore = api.GetBoxscore(game_id)
self._playbyplay = api.GetPlayByPlay(game_id)
self._boxscore_summary = api.GetBoxscoreSummary(game_id)
else:
box_job = gevent.spawn(api.GetBoxscore, game_id)
pbp_job = gevent.spawn(api.GetPlayByPlay, game_id)
bs_job = gevent.spawn(api.GetBoxscoreSummary, game_id)
gevent.joinall([box_job, pbp_job, bs_job])
self._boxscore = box_job.value
self._playbyplay = pbp_job.value
self._boxscore_summary = bs_job.value
self._matchups = None
评论列表
文章目录