我想创建一个“CGI 脚本”在Python中,它驻留在内存中并服务多个请求

发布于 2024-08-08 06:54:01 字数 308 浏览 1 评论 0原文

我现在有一个网站,通过从每晚运行的 cron 作业创建静态 html 页面来运行。

我想使用 CGI 类型脚本添加一些搜索和过滤功能,但我的脚本将有足够的启动时间(可能几秒钟?),我希望它保持驻留并服务多个请求。

这是我为了好玩而做的一个副项目,它不会太复杂。我不介意使用像 Pylons 这样的东西,但我不觉得我需要或想要 ORM 层。

这里什么是合理的方法?

编辑:我想指出,对于我期望的负载和我需要根据请求执行的处理,我相信单个进程中的单个 python 脚本可以处理所有请求而不会出现任何减速,特别是因为我的数据集将是内存驻留的。

I have a website that right now, runs by creating static html pages from a cron job that runs nightly.

I'd like to add some search and filtering features using a CGI type script, but my script will have enough of a startup time (maybe a few seconds?) that I'd like it to stay resident and serve multiple requests.

This is a side-project I'm doing for fun, and it's not going to be super complex. I don't mind using something like Pylons, but I don't feel like I need or want an ORM layer.

What would be a reasonable approach here?

EDIT: I wanted to point out that for the load I'm expecting and processing I need to do on a request, I'm confident that a single python script in a single process could handle all requests without any slowdowns, especially since my dataset would be memory-resident.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

捂风挽笑 2024-08-15 06:54:01

这正是 WSGI 的用途;)

我不知道最简单的方法是什么不过,将 CGI 脚本转换为 WSGI 应用程序是(我一直由框架管理它)。不过,这应该不会太棘手。

也就是说,Python Web 服务器网关接口 (WSGI) 简介) 似乎是一个合理的介绍,您还需要查看 mod_wsgi (假设您使用的是 Apache...)

That's exactly what WSGI is for ;)

I don't know off hand what the simplest way to turn a CGI script into a WSGI application is, though (I've always had that managed by a framework). It shouldn't be too tricky, though.

That said, An Introduction to the Python Web Server Gateway Interface (WSGI) seems to be a reasonable introduction, and you'll also want to take a look at mod_wsgi (assuming you're using Apache…)

不交电费瞎发啥光 2024-08-15 06:54:01

也许您应该将搜索定向到进程间通信,并创建一个将结果返回到 Web 服务器的搜索进程。假设您有自己的服务器,此搜索过程将一直运行。

maybe you should direct your search towards inter process commmunication and make a search process that returns the results to the web server. This search process will be running all the time assuming you have your own server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文