简体   繁体   English

AppEngine中长时间运行的受I / O约束的进程:任务还是线程?

[英]Long-running I/O-bound processes in AppEngine: tasks or threads?

My Python AppEngine app interacts with slow external systems (think receiving data from narrow-band connections). 我的Python AppEngine应用程序与速度较慢的外部系统交互(请考虑从窄带连接接收数据)。 Half-hour-long interactions are a norm. 半小时的互动是正常现象。 I need to run 10-15 of such interactions in parallel. 我需要并行运行10-15个这样的交互。

My options are background tasks and "background threads" ( not plain Python threads). 我的选择是后台任务和“后台线程”( 不是普通的Python线程)。 Theoretically they look about the same. 从理论上讲,它们看起来相同。 I'd stick with tasks since background threads don't run on the local development server. 我会坚持执行任务,因为后台线程不在本地开发服务器上运行。

Are there any significant advantages of one approach over the other? 一种方法相对于另一种方法有何重大优势?

It depends on how long the "interaction" takes. 这取决于“交互”需要多长时间。 Appengine has a limit of 60 seconds per HTTP Requests. Appengine每个HTTP请求的时限为60秒。 If your external systems send data periodically then I would advice to grab the data in small chunks to respect the 60 seconds limit. 如果您的外部系统定期发送数据,那么我建议您以小块的形式获取数据,以遵守60秒的限制。 Aggregate those into blobs and then process the data periodically using tasks. 将这些数据聚集到Blob中,然后使用任务定期处理数据。

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

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