• ValueError: signal only works in main thread


    问题:

    Traceback (most recent call last):
      File "/home/python/.virtualenvs/toutiao/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
        raise value
      File "/home/python/toutiao-backend/toutiao/__init__.py", line 6, in <module>
        import socketio
      File "/home/python/.virtualenvs/toutiao/lib/python3.6/site-packages/socketio/__init__.py", line 3, in <module>
        from .client import Client
      File "/home/python/.virtualenvs/toutiao/lib/python3.6/site-packages/socketio/client.py", line 5, in <module>
        import engineio
      File "/home/python/.virtualenvs/toutiao/lib/python3.6/site-packages/engineio/__init__.py", line 3, in <module>
        from .client import Client
      File "/home/python/.virtualenvs/toutiao/lib/python3.6/site-packages/engineio/client.py", line 44, in <module>
        original_signal_handler = signal.signal(signal.SIGINT, signal_handler)
      File "/usr/lib64/python3.6/signal.py", line 47, in signal
        handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
    ValueError: signal only works in main thread

    解决方法:

    推测与项目中socketio有关
    在这里插入图片描述

    1.socketio 插件在使用flask run启动,出现 ValueError: signal only works in main thread 异常的问题。

    如果非要flask run启动,flask run --no-reload 切记一定要带 --no-reload 参数,本人测试已经成功。


    在这里插入图片描述


    2.如果是使用app.run启动,run()指定参数use_reloader=False, 这个方法我还没进行尝试

    app.run(debug=True, use_reloader=False)
  • 相关阅读:
    Markdown基础语法
    Java是什么
    myBatis框架_关于怎么获得多表查询的总记录数
    关于Could not load driverClass ${jdbc.driverClassName}问题解决方案
    java中String与StringBuffer拼接的区别
    部分标签
    基础标签 网页分类
    入坑小开头
    完整版的OpenLDAP搭建全过程
    测试Linux下tcp最大连接数限制
  • 原文地址:https://www.cnblogs.com/sewen-H/p/13615823.html
Copyright © 2020-2023  润新知