我正在使用 Django Channels 作为实时进度条。借助此进度条,客户可以获得模拟的实际反馈。此模拟可能需要超过 5 分钟,具体取决于数据大小。现在来说说问题。客户端可以成功启动模拟,但在此期间无法加载其他页面。此外,我收到以下错误消息:
Application instance <Task pending coro=<StaticFilesWrapper.__call__() running at /.../python3.7/site-packages/channels/staticfiles.py:44> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/futures.py:348, <TaskWakeupMethWrapper object at 0x123aa88e8>()]>> for connection <WebRequest at 0x123ab7e10 method=GET uri=/2/ clientproto=HTTP/1.1> took too long to shut down and was killed.
Run Code Online (Sandbox Code Playgroud)
只有在模拟完成后,才能加载更多页面。
已经有关于这个主题的文章,但它们不包含任何适合我的解决方案。例如以下链接中的示例: https: //github.com/django/channels/issues/1119 这里的建议是降级 Channels 版本。但是,我遇到了其他错误,它也必须适用于较新的版本。
消费者、路由和asgi的代码完全按照说明中的要求实现:https://channels.readthedocs.io/en/stable/tutorial/index.html
需求.txt:
Django==3.1.2
channels==3.0.3
channels-redis==3.3.1
asgiref==3.2.10
daphne==3.0.2
Run Code Online (Sandbox Code Playgroud)
我很感激任何提示或提示。
最好的问候,丹尼斯