the_oracle.py 文件源码

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

项目:piwheels 作者: bennuttall 项目源码 文件源码
def handle_db_request(self, queue):
        """
        Handle incoming requests from :class:`DbClient` instances.
        """
        address, empty, msg = queue.recv_multipart()
        msg, *args = pickle.loads(msg)
        try:
            handler = {
                'ALLPKGS': self.do_allpkgs,
                'ALLVERS': self.do_allvers,
                'NEWPKG': self.do_newpkg,
                'NEWVER': self.do_newver,
                'LOGBUILD': self.do_logbuild,
                'PKGFILES': self.do_pkgfiles,
                'PKGEXISTS': self.do_pkgexists,
                'GETABIS': self.do_getabis,
                'GETPYPI': self.do_getpypi,
                'SETPYPI': self.do_setpypi,
                'GETSTATS': self.do_getstats,
            }[msg]
            result = handler(*args)
        except Exception as exc:
            self.logger.error('Error handling db request: %s', msg)
            # REP *must* send a reply even when stuff goes wrong
            # otherwise the send/recv cycle that REQ/REP depends
            # upon breaks
            queue.send_multipart([address, empty,
                                  pickle.dumps(['ERR', str(exc)])])
        else:
            queue.send_multipart([address, empty,
                                  pickle.dumps(['OK', result])])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号