-
1 votesanswersviews
在请求中运行后台异步任务而不关闭pytest-sanic中的事件循环
我想在pytest-sanic中并行运行2个测试但是当我尝试该事件循环被关闭时,并抛出跟随错误 . RuntimeError('Event loop is closed') 这是代码的简化版本的样子 import pytest import json from main import make_app @pytest.yield_fixture def app(): app = mak... -
0 votesanswersviews
夹具'loop'未找到
我使用PyTest在Sanic中运行以下测试,但我得到了 夹具'循环'未找到 错误,我按照link中的教程在make app中返回Sanic app . import pytest import json from main import make_app @pytest.yield_fixture def app(): app = make_app() yield app ... -
0 votesanswersviews
sanic.exceptions.RequestTimeout:请求Sanic中的超时
我运行sanic应用程序,即使没有任何请求,它也会每几秒钟引发一次异常 . sanic.exceptions.RequestTimeout: Request Timeout 如何解决这个问题? -
0 votesanswersviews
尝试在Python 3.5中运行Sanic应用程序的未定义符号
当我尝试使用Python 3.5运行Sanic应用程序时,我收到以下错误: Traceback (most recent call last): File "api.py", line 1, in <module> from sanic import Sanic File "/home/shiro/dev/unassociated/user... -
0 votesanswersviews
使用Python开发REST API(Sanic)
from sanic import Sanic from sanic import response app = Sanic(__name__) @app.route('/v1/ok', methods=['GET']) async def post_handler(request): return response.text("hey all good") i... -
1 votesanswersviews
Sanic和Motor使用不同的事件循环
我是Sanic的新手,我正试图让它与Motor合作 . 我确实设法让所有东西都在一个文件中工作,但是,当我在我的项目结构中尝试时,我遇到了以下问题 . [2018-02-28 17:26:58 +0530] [3720] [ERROR] Traceback (most recent call last): File "/usr/local/lib/python3.6/site-pack... -
2 votesanswersviews
如何在Sanic中使用aiohttp ClientSession?
我试图了解在Sanic中使用aiohttp的正确方法是什么 . 从aiohttp documentation,我发现以下内容: 不要为每个请求创建会话 . 最有可能的是,每个应用程序都需要一个会话来完成所有请求 . 更复杂的情况可能需要每个站点的会话,例如,一个用于Github,另一个用于Facebook API . 无论如何,为每个请求进行会话是一个非常糟糕的主意 . 会话内部包含连接池 . ... -
1 votesanswersviews
Sanic:无法连接Aerospike
我有连接aerospike的问题 . 我将docker镜像推送到部署系统然后在系统启动时遇到错误: ERROR:sanic:Experienced exception while trying to serve Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/sanic/app.py&... -
1 votesanswersviews
我可以使用Python3.6 Sanic检测websockets中的'connection lost'吗?
当我的Python3.6 Sanic Web服务器与客户端应用程序失去联系时(例如:用户关闭Web浏览器或网络失败等等),我可以检测到(如果是的话?) from sanic import Sanic import sanic.response as response app = Sanic() @app.route('/') async def index(request): ret...