首页 \ 问答 \ 如何在Pylons中启动后台进程?(How can I launch a background process in Pylons?)

如何在Pylons中启动后台进程?(How can I launch a background process in Pylons?)

我正在尝试编写一个应用程序,允许用户启动相当长时间的运行过程(5-30秒)。 然后,它应该允许用户在生成过程时检查过程的输出。 输出将仅用于用户当前的会话,因此不需要长期存储任何内容。 我有两个关于如何在利用Pylons框架的情况下完成此任务的问题:

  1. 用Pylons控制器启动后台进程的最佳方式是什么?

  2. 将后台进程的输出返回给用户的最佳方式是什么? (我应该将输出存储在数据库,会话数据等中?)

编辑:问题是如果我使用控制器中的子进程启动命令,则控制器会在继续之前等待子进程完成,向用户显示一个刚刚加载的空白页面,直到该进程完成。 我希望能够在启动子进程后立即将用户重定向到状态页面,允许它自己完成。


I am trying to write an application that will allow a user to launch a fairly long-running process (5-30 seconds). It should then allow the user to check the output of the process as it is generated. The output will only be needed for the user's current session so nothing needs to be stored long-term. I have two questions regarding how to accomplish this while taking advantage of the Pylons framework:

  1. What is the best way to launch a background process such as this with a Pylons controller?

  2. What is the best way to get the output of the background process back to the user? (Should I store the output in a database, in session data, etc.?)

Edit: The problem is if I launch a command using subprocess in a controller, the controller waits for the subprocess to finish before continuing, showing the user a blank page that is just loading until the process is complete. I want to be able to redirect the user to a status page immediately after starting the subprocess, allowing it to complete on its own.


原文:https://stackoverflow.com/questions/1182587
更新时间:2023-06-06 21:06

最满意答案

尝试这种方法:

在当前日期添加四个月

截断这个日期到第一年

再减去四个月

Add_Months(Trunc(Add_Months(SYSDATE, 4), 'year'), -4)

Try this approach:

add four months to the current date

truncate this date to the first of year

subtract four months again

Add_Months(Trunc(Add_Months(SYSDATE, 4), 'year'), -4)

相关问答

更多
  • 您需要具有动态列定义的PIVOT函数。 最简单的方法是pivot xml: create table tst_data (id int primary key, source varchar2(255)); insert into tst_data values (1, 'INTERNET'); insert into tst_data values (2, 'DEMO'); insert into tst_data values (3, 'INTERNET'); insert into tst_data ...
  • 你需要加入特殊费率。 如果我记得oracle的语法是这样的: AND contract.contract_id = special_rate.contract_id (+) 但现在special_rate。*可以为null,所以: + special_rate.s_rate_amnt 将需要是: + coalesce(special_rate.s_rate_amnt,0) you need to left join in the special rate. If I recall the oracl ...
  • 你的解决方法是我过去使用的。 还有很好的旧DBMS_Sql ,它允许绑定变量,就像你可以通过OCI一样。 (这基本上是DBMS_Sql似乎正在做的事情;-)) Your workaround is what I have used in the past. There's also good old DBMS_Sql, which allows binding variables like you would be able to via OCI. (Which is basically what DBMS ...
  • 我假设您知道如何使用浏览器的Inspect element功能获取attribute5列下文本框的name属性。 它类似于“f01”,“f02”或更高,只是检查一下。 另一个假设(基于您的给定数据)是第5行包含第1行到第4行的总数,第7行包含第5行和第6行的总和。 获得名称后,将此功能粘贴到页面的“功能和全局变量声明”属性中: function setTotals(itemname){ var v_subtotal=0; var v_total=0; ...
  • 你不能这样做:变量:new和:old超出了动态SQL的范围。 你不能把它作为rowtype / Oracle类型 - 我尝试了很多次不同的事情。 您所能做的就是 - 动态生成完整的触发器代码。 我是为触发器做的,它将所有的东西重新加载到表数据更改的历史表中。 并且只要您的触发器的大小非常大(如果它的长度超过32767字节),您应该使用dbms_sql包而不是执行立即执行 you cannot do that: the variables :new and :old are out of scope in d ...
  • 我认为%ROWTYPE在这里是一个死胡同。 据我所知,有办法提取有关PL / SQL变量的有用元数据。 但是,如果您可以使用抽象数据类型(ADT或“对象”),则情况会有所不同。 它更强大,类似于%ROWTYPE 。 但它不太方便,并且会使您的初始代码更复杂一些。 您必须预先定义对象,并在SQL中使用它们。 例如,替换如下代码: declare v_test tbl%rowtype; begin select * into v_test from tbl; end; / 有了这个: decl ...
  • 不知道我的理解是否正确,但是在这里,我想你正在寻找像下面这样的查询: ;with cte1 as ( select startdate, t1, t2 = case when row_number() over (order by startdate) > 4 then (t1*(z1param1+z1param2)/convert(float, z1param3+z1param4)) else t2 end, ...
  • Oracle也有一个缓存执行工具。 查询被哈希并匹配到计划,如果它击中散列表。 您还可以使用此机制强制执行特定查询的计划。 与SQL Server一样,您需要使用参数化查询来执行此操作,而不是将值替换为字符串 - 因为后者会生成不同的哈希值。 Oracle also has a cached execution facility. The Query is hashed and matched to a plan if it hits on the hash table. You can also use ...
  • 尝试这种方法: 在当前日期添加四个月 截断这个日期到第一年 再减去四个月 Add_Months(Trunc(Add_Months(SYSDATE, 4), 'year'), -4) Try this approach: add four months to the current date truncate this date to the first of year subtract four months again Add_Months(Trunc(Add_Months(SYSDATE, 4), ' ...
  • 其实我不明白你的动态查询。 但根据我的理解,这个查询是多行结果集。 所以你需要使用BULK收集并通过输出迭代才能显示。 有两种方法 1)只是为了显示输出。 SET serveroutput ON; DECLARE plsql_block VARCHAR2(500); lv_col1 VARCHAR2(10):='1'; lv_col2 VARCHAR2(10):='2'; type tab_var IS TABL ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。