zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    腾讯2014 笔试
    iOS 并发编程之 Operation Queues
    iOS 架构
    loadView and viewDidLoad?
    Referring to weak self inside a nested block
    Weakify和strongify探究
    iOS开发的最佳实践
    iOS 书籍
    Object-C非正式协议与正式协议的区别
    解决element-ui中el-menu组件作为vue-router模式在刷新页面后default-active属性与当前路由页面不一致问题的方法
  • 原文地址:https://www.cnblogs.com/sewen-H/p/13615823.html
Copyright © 2011-2022 走看看