gpt4 book ai didi

python - 使用不同的 request_queue_size 和超时启动 CherryPy

转载 作者:太空宇宙 更新时间:2023-11-04 01:20:42 29 4
gpt4 key购买 nike

我有一个 CherryPy 应用程序,我从它开始:

cherrypy.tree.mount(None, "/", config=conf) 
cherrypy.quickstart(None, config=conf)

我最近向应用程序引入了一个页面,该页面需要相当长的时间才能加载(在某些情况下需要 10 到 15 秒),并且在中等负载下生产服务器上开始出现随机故障。我怀疑这可能是由于当多个用户请求这些长时间运行的页面时有太多请求排队。

我想尝试允许更多请求排队。我发现内置服务器有一个 request_queue_size 设置可以控制我想要的。但是,我不知道如何使用 cherrypy.quickstart 更改此设置。

最佳答案

你可以在你的conf字典中设置它:

conf = {'server.socket_queue_size': 10, ...}

或者您可以通过编程方式更改它:

cherrypy.server.socket_queue_size = 10

使用字典是更好的方法。

In CherryPy 3, you use configuration (files or dicts) to set attributes directly on the engine, server, request, response, and log objects. So the best way to know the full range of what’s available in the config file is to simply import those objects and see what help(obj) tells you.

来自 CherryPy v3.2.0 documentation » Tutorial and Concepts » Configuration

关于python - 使用不同的 request_queue_size 和超时启动 CherryPy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21447383/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com