• 记录一个错误: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
  • 相关阅读:
    模仿抖音直播商城带货打赏功能做一个app系统
    C语言是否快被时代所淘汰?
    大数据必学Java基础(七):扩展环境变量
    unigui添加ssl(https)访问的方法
    独立站SaaS建站工具:电商领域的革命性利器
    Spring Boot RestController接口如何输出到终端
    机器学习笔记09---PCA主成分分析
    LPRNet, 车牌识别网络
    【无标题】chapter6卷积
    yolov8 c++进行部署
  • 原文地址:https://blog.csdn.net/weixin_48306625/article/details/132609931