如何在Pylons中启动后台进程?(How can I launch a background process in Pylons?)
我正在尝试编写一个应用程序,允许用户启动相当长时间的运行过程(5-30秒)。 然后,它应该允许用户在生成过程时检查过程的输出。 输出将仅用于用户当前的会话,因此不需要长期存储任何内容。 我有两个关于如何在利用Pylons框架的情况下完成此任务的问题:
用Pylons控制器启动后台进程的最佳方式是什么?
将后台进程的输出返回给用户的最佳方式是什么? (我应该将输出存储在数据库,会话数据等中?)
编辑:问题是如果我使用控制器中的子进程启动命令,则控制器会在继续之前等待子进程完成,向用户显示一个刚刚加载的空白页面,直到该进程完成。 我希望能够在启动子进程后立即将用户重定向到状态页面,允许它自己完成。
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:
What is the best way to launch a background process such as this with a Pylons controller?
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
最满意答案
尝试这种方法:
在当前日期添加四个月
截断这个日期到第一年
再减去四个月
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; ...
-
使用Trigger的Oracle动态sql使用:new和:old变量(Oracle dynamic sql with Trigger using :new and :old variables)[2023-04-17]
你不能这样做:变量: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 ...
-
SQL中的动态计算(Dynamic calculation in SQL)[2023-10-25]
不知道我的理解是否正确,但是在这里,我想你正在寻找像下面这样的查询: ;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 ...