记录一个错误:cannot schedule the futures after interprete shutdown

今天运行代码时出现一个错误。在python3.8及以下版本的环境中没有问题,在python3.9中出错,报:runtimeerror:cannot schedule the futures after interprete shutdown。由于对通讯一块不熟,查了好久,才发现是版本的问题,python3.9中协程的实现不用这种。

原代码:


class GetCurrentCheckBoxRequest(BaseRequest):
    """获取当前的检测框"""
    @gen.coroutine
    def get(self):
        print("GetCurrentCheckBoxRequest")
        func = RequestHHandler.get_current_check_box_handler
        response = yield self.async_handler(func)
        self.write(response)


class SetCurrentCheckBoxRequest(BaseRequest):
    """获取当前的检测框"""
    @gen.coroutine
    def post(self):
        print("SetCurrentCheckBoxRequest")
        func = RequestHHandler.set_current_check_box_handler
        args = json.loads(self.request.body)
        response = yield self.async_handler(func, args)
        self.write(response)

修改:


class GetCurrentCheckBoxRequest(BaseRequest):
    """获取当前的检测框"""
    def get(self):
        print("GetCurrentCheckBoxRequest")
        
        response =RequestHHandler.get_current_check_box_handler
        self.write(response)


class SetCurrentCheckBoxRequest(BaseRequest):
    """获取当前的检测框"""
    #@gen.coroutine
    def post(self):
        print("SetCurrentCheckBoxRequest")
        #func = RequestHHandler.set_current_check_box_handler
        #args = json.loads(self.request.body)
        #response = yield self.async_handler(func, args)
        args = json.loads(self.request.body)
        response = RequestHHandler.set_current_check_box_handler
        self.write(response)

你可能感兴趣的:(随手记,python,开发语言)