<legend id='5ar9j'><style id='5ar9j'><dir id='5ar9j'><q id='5ar9j'></q></dir></style></legend>
      <bdo id='5ar9j'></bdo><ul id='5ar9j'></ul>

  • <i id='5ar9j'><tr id='5ar9j'><dt id='5ar9j'><q id='5ar9j'><span id='5ar9j'><b id='5ar9j'><form id='5ar9j'><ins id='5ar9j'></ins><ul id='5ar9j'></ul><sub id='5ar9j'></sub></form><legend id='5ar9j'></legend><bdo id='5ar9j'><pre id='5ar9j'><center id='5ar9j'></center></pre></bdo></b><th id='5ar9j'></th></span></q></dt></tr></i><div id='5ar9j'><tfoot id='5ar9j'></tfoot><dl id='5ar9j'><fieldset id='5ar9j'></fieldset></dl></div>

      <small id='5ar9j'></small><noframes id='5ar9j'>

      1. <tfoot id='5ar9j'></tfoot>

      2. Python CGI 队列

        Python CGI queue(Python CGI 队列)

        1. <small id='UvH33'></small><noframes id='UvH33'>

          <tfoot id='UvH33'></tfoot>

            <tbody id='UvH33'></tbody>
              1. <legend id='UvH33'><style id='UvH33'><dir id='UvH33'><q id='UvH33'></q></dir></style></legend>
              2. <i id='UvH33'><tr id='UvH33'><dt id='UvH33'><q id='UvH33'><span id='UvH33'><b id='UvH33'><form id='UvH33'><ins id='UvH33'></ins><ul id='UvH33'></ul><sub id='UvH33'></sub></form><legend id='UvH33'></legend><bdo id='UvH33'><pre id='UvH33'><center id='UvH33'></center></pre></bdo></b><th id='UvH33'></th></span></q></dt></tr></i><div id='UvH33'><tfoot id='UvH33'></tfoot><dl id='UvH33'><fieldset id='UvH33'></fieldset></dl></div>
                  <bdo id='UvH33'></bdo><ul id='UvH33'></ul>
                • 本文介绍了Python CGI 队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Python 开发一个相当简单的 CGI.我即将将它放入 Django 等.整体设置是非常标准的服务器端(计算在服务器上完成):

                  I'm working on a fairly simple CGI with Python. I'm about to put it into Django, etc. The overall setup is pretty standard server side (i.e. computation is done on the server):

                  1. 用户上传数据文件并点击运行"按钮
                  2. 服务器在后台并行分叉作业,使用大量 RAM 和处理器能力.大约 5-10 分钟后(平均用例),程序终止,创建了一个输出文件和一些 .png 图形文件.
                  3. 服务器显示带有数字和一些摘要文本的网页
                  1. User uploads data files and clicks "Run" button
                  2. Server forks jobs in parallel behind the scenes, using lots of RAM and processor power. ~5-10 minutes later (average use case), the program terminates, having created a file of its output and some .png figure files.
                  3. Server displays web page with figures and some summary text

                  我认为不会有成百上千的人同时使用它;但是,因为正在进行的计算需要相当多的 RAM 和处理器能力(每个实例都使用 Python 的 Pool 分叉出 CPU 最密集的任务).

                  I don't think there are going to be hundreds or thousands of people using this at once; however, because the computation going on takes a fair amount of RAM and processor power (each instance forks the most CPU-intensive task using Python's Pool).

                  我想知道您是否知道使用排队系统是否值得麻烦.我遇到了一个名为 beanstalkc 的 Python 模块,但在页面上它说它是一个内存中"排队系统.

                  I wondered if you know whether it would be worth the trouble to use a queueing system. I came across a Python module called beanstalkc, but on the page it said it was an "in-memory" queueing system.

                  在这种情况下,内存中"是什么意思?我担心内存,而不仅仅是 CPU 时间,因此我想确保一次只运行一个作业(或保存在 RAM 中,无论它是否接收 CPU 时间).

                  What does "in-memory" mean in this context? I worry about memory, not just CPU time, and so I want to ensure that only one job runs (or is held in RAM, whether it receives CPU time or not) at a time.

                  另外,我试图决定是否

                  • 结果页面(由 CGI 提供)应该告诉您它在队列中的位置(直到它运行并显示实际结果页面)



                  • 用户应将他们的电子邮件地址提交给 CGI,CGI 将在完成后通过电子邮件将指向结果页面的链接发送给他们.
                  • the result page (served by the CGI) should tell you it's position in the queue (until it runs and then displays the actual results page)

                    OR

                  • the user should submit their email address to the CGI, which will email them the link to the results page when it is complete.

                  对于此类问题,您认为适合轻型交通 CGI 的设计方法是什么?非常感谢您的建议.

                  What do you think is the appropriate design methodology for a light traffic CGI for a problem of this sort? Advice is much appreciated.

                  推荐答案

                  一定要用celery.您可以运行 amqp 服务器,或者我认为您可以将数据库作为消息队列进行起诉.它允许您在后台运行任务,并且可以根据需要使用多台工作机器进行处理.如果您使用 django-celery

                  Definitely use celery. You can run an amqp server or I think you can sue the database as a queue for the messages. It allows you to run tasks in the background and it can use multiple worker machines to do the processing if you want. It can also do cron jobs that are database based if you use django-celery

                  后台运行任务就这么简单:

                  It's as simple as this to run a task in the background:

                  @task
                  def add(x, y):
                      return x + y
                  

                  在一个项目中,我将工作分配到 4 台机器上,而且效果很棒.

                  In a project I have it's distributing the work over 4 machines and it works great.

                  这篇关于Python CGI 队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                        <bdo id='0mfEh'></bdo><ul id='0mfEh'></ul>
                          <tbody id='0mfEh'></tbody>
                        <i id='0mfEh'><tr id='0mfEh'><dt id='0mfEh'><q id='0mfEh'><span id='0mfEh'><b id='0mfEh'><form id='0mfEh'><ins id='0mfEh'></ins><ul id='0mfEh'></ul><sub id='0mfEh'></sub></form><legend id='0mfEh'></legend><bdo id='0mfEh'><pre id='0mfEh'><center id='0mfEh'></center></pre></bdo></b><th id='0mfEh'></th></span></q></dt></tr></i><div id='0mfEh'><tfoot id='0mfEh'></tfoot><dl id='0mfEh'><fieldset id='0mfEh'></fieldset></dl></div>
                        <tfoot id='0mfEh'></tfoot>

                        <small id='0mfEh'></small><noframes id='0mfEh'>

                        • <legend id='0mfEh'><style id='0mfEh'><dir id='0mfEh'><q id='0mfEh'></q></dir></style></legend>