python - WebSocket 聊天异步示例崩溃

标签 python macos websocket uwsgi asyncsocket

我一直在尝试在 Apple Mac 上运行此处提供的 websocket 聊天示例。 https://github.com/unbit/uwsgi/blob/master/tests/websockets_chat_async.py

但运行此示例会导致 uwsgi 出现段错误。

我已将此示例复制粘贴到 websocket.py 中 并使用以下命令运行服务器

uwsgi --http :8080 --http-websockets --wsgi-file websocket.py --venv ../../python2-wow

当我访问 URL 时,我得到了建立连接的正确消息。但是随后服务器因这个段错误而崩溃

!!! uWSGI process 29129 got Segmentation Fault !!!
*** backtrace of 29129 ***
0   uwsgi                               0x00000001078b5ec0 uwsgi_backtrace + 48
1   uwsgi                               0x00000001078b6371 uwsgi_segfault + 49
2   libsystem_platform.dylib            0x00007fff96b2c5aa _sigtramp + 26
3   ???                                 0x0000000000000000 0x0 + 0
4   uwsgi                               0x0000000107897b4e async_add_fd_read + 206
5   uwsgi                               0x00000001078c8979 py_eventfd_read + 89
6   Python                              0x00000001079d214d PyEval_EvalFrameEx + 8080
7   Python                              0x00000001079d0093 PyEval_EvalCodeEx + 1641
8   Python                              0x0000000107977796 PyFunction_SetClosure + 809
9   Python                              0x0000000107959f72 PyObject_Call + 101
10  Python                              0x00000001079d601f PyEval_CallObjectWithKeywords + 93
11  uwsgi                               0x00000001078c6dc7 python_call + 23
12  uwsgi                               0x00000001078c8df9 uwsgi_request_wsgi + 889
13  uwsgi                               0x000000010787b7e3 wsgi_req_recv + 291
14  uwsgi                               0x00000001078b38a5 simple_loop_run + 229
15  uwsgi                               0x00000001078ba6e2 uwsgi_ignition + 226
16  uwsgi                               0x00000001078ba5ae uwsgi_worker_run + 670
17  uwsgi                               0x00000001078b9d26 uwsgi_start + 5078
18  uwsgi                               0x00000001078b81a3 main + 7331
19  libdyld.dylib                       0x00007fff8c6ce5fd start + 1
*** end of backtrace ***

显然崩溃发生在这条线上

uwsgi.wait_fd_read(websocket_fd, 3)

卡在这里。需要帮助。

最佳答案

我让它与 --async=100--ugreen 选项一起工作。

请注意,您可以使用更新的 API:native WebSocket support和通用 gevent-based async support .

关于python - WebSocket 聊天异步示例崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21257465/

相关文章:

swift - 如何在 osx 上使用 swift 创建一个透明背景的窗口?

objective-c - 如何调整 NSImage 的大小?

ruby - 32 位 Ruby 编译在 Lion 上失败

java - Tomcat 8.0.x Websockets、SSL 和 Windows --> 最后一帧延迟

Python 在 for 循环期间卡住

python - 无法使用 python pykitti 包在目录中找到文件

utf-8 - WebSocket - Safari 9 - header 值中的 UTF-8 序列无效

javascript - 实时应用程序 : Socket. io 与 Pusherapp

python - 将嵌套的 .h5 组读入 numpy 数组

python - 比较这两个短代码的计算速度