简体   繁体   English

您如何从mod_python通知后台进程?

[英]How can you message a background process from mod_python?

We're running a Linux server running Apache2 with mod_python. 我们正在运行一台运行带有mod_python的Apache2的Linux服务器。 One mod_python script inserts an entry in a database logging table. 一个mod_python脚本在数据库日志记录表中插入一个条目。 The logging table is large can be a point of disk-write contention, or it can be temporarily unavailable during database maintenance. 日志表很大,可能是磁盘写入争用的原因,或者在数据库维护期间可能暂时不可用。 We would like to spin off the logging as an asynchronous background task, so that the user request can complete before the logging is done. 我们希望将日志记录作为异步后台任务剥离,以便用户请求可以在日志记录完成之前完成。

Ideally there would be a single background process. 理想情况下,将只有一个后台过程。 The web handler would pass its log request to the background process. Web处理程序会将其日志请求传递给后台进程。 The background process would write log entries to the database. 后台进程会将日志条目写入数据库。 The background process would queue up to a hundred requests and drop requests when its queue is full. 后台进程将排队多达一百个请求,并在其队列已满时丢弃请求。

Which techniques are available in Python to facilitate communicating with a background process? Python提供了哪些技术来促进与后台进程的通信?

您可以使用celery / redis任务队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM