Discuss / Python / 求教,既然是单线程,为什么接口报500服务器却没挂,还能接收其它请求?

求教,既然是单线程,为什么接口报500服务器却没挂,还能接收其它请求?

Topic source

比如这里

async def hello(request):
     sth = request['sth']
    await asyncio.sleep(0.5)
    text = '<h1>hello, %s!</h1>' % request.match_info['name']
    return web.Response(body=text.encode('utf-8'))

我加了一句 sth = request['sth'],当访问这个接口的时候会报错,但服务器却没有挂,访问 index 接口还能收到响应?

天哪,这个问题太蠢了,为什么不能删掉。。。


  • 1

Reply