python - 使用 while 循环运行 django 微服务?

标签 python django while-loop microservices

我有一个 Django 应用程序作为微服务运行。它有一个执行以下操作的函数:

  1. 检查目录中是否有与 *.json 匹配的文件名。
  2. 对于每个文件:
    • 处理 json 数据并转换为 xml。
    • 将 xml 保存在目标目录中。
  3. 退出函数。

有什么理由我不应该这样做以使其保持循环运行:

While True:
    main_function()

以前的开发人员使用线程,我认为这使事情变得过于复杂,因为不需要优化性能。

最佳答案

您可能正在寻找这个: http://www.celeryproject.org/

Celery 很容易理解和实现,并且不会花费很多时间。 如果对您有帮助,请告诉我。

关于python - 使用 while 循环运行 django 微服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53240057/

相关文章:

python - scipy csr_matrix : understand indptr

python - TooManyRequests 越界错误

python - 实时面部识别:PermissionError:[Errno 13]权限被拒绝:

python - django 1.7 makemigrations 需要我尝试删除的依赖项

python - MySQL 连接器不工作 | Django 1.10 | window | Python 3.5

c - While 循环中表达式的双括号

python - Pandas 无法对数据框求和

python - 为什么空闲 Python 线程消耗高达 90% 的 CPU?

python - 从头到尾循环

c - 如何在 while 循环中找到最大值和最小值 - c