__init__.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:statsnba-playbyplay 作者: ethanluoyc 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号