• 记录一个错误: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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    修改:

    
    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
  • 相关阅读:
    Java笔记(5)
    Flink-提交job
    【AndroidStudio旧版本BUG问题】完美解决运行报错问题Invalid keystore format
    为什么表数据删一半,表文件大小不变?
    计算机网络自学笔记004_Real(数据链路层002)
    达美乐面试(部分)(未完全解析)
    ppocr ERROR: When parsing line KeyError: None
    IP地址c++题解
    Termius for Mac v8.4.0激活版下载
    linux中磁盘满了?一招教你快速清理
  • 原文地址:https://blog.csdn.net/weixin_48306625/article/details/132609931