我需要在OpenWRT中执行带超时的命令,但似乎默认情况下没有安装命令超时,也不能使用opkg安装.我知道我可以做一个工作(使用命令&; sleep $ DELAY; kill $!),但我希望更好地做到这一点,而不会在超时之前命令完成时尝试杀死进程的冒险.
PHP作为Apache模块运行.
该脚本以: ini_set('max_execution_time', 300);
它的作用基本上是连接数据库,进行大SELECT查询并循环结果,将它们写入文件并在每次写入后用显式回显"结果正常"flush();
没有sleep()电话.
这是一个由我的同事制作的"测试"脚本,用于备份目的,目的是运行几个小时!我以为我知道脚本执行时间限制,并认为他的脚本会在300秒后超时......但事实并非如此!
它是从Web浏览器调用的.页面保持打开状态,我们可以看到实时回显的结果.
为什么不超时?更奇怪的是,其中一项测试发出了" 超过300秒的最大执行时间 "但这至少在执行2小时后出现了!
这里发生了什么?在max_execution_time和flush()之间是否有一些需要理解的东西或者保持打开的浏览器窗口?
我有一个按钮(锚标签),如果你按下它会发送确认信息.问题是,例如,如果您非常快速地按5次它将发送5条确认消息,如果您按2次它将发送2条消息.
当用户连接速度较慢且页面刷新时再次按下按钮时,可能会发生这种情况.
我该如何处理这种情况?我虽然禁用了按钮,但由于其他原因,这是不可能的.
<a class="msg" href="/manage/conversations.cfm?destination=#destination#">
#ucase(request.l('Send'))#
</a>
Run Code Online (Sandbox Code Playgroud)
感谢您的时间
我正在研究OpenShift Origin 1.1(正在使用kubernetes作为其docker容器的编排工具)。我正在创建Pod,但是看不到构建日志。
[user@ip master]# oc get pods
NAME READY STATUS RESTARTS AGE
test-1-build 0/1 Completed 0 14m
test-1-iok8n 1/1 Running 0 12m
[user@ip master]# oc logs test-1-iok8n
Error from server: Get https://ip-10-0-x-x.compute.internal:10250/containerLogs/test/test-1-iok8n/test: dial tcp 10.0.x.x:10250: i/o timeout
Run Code Online (Sandbox Code Playgroud)
我的/var/logs/messages节目:
Dec 4 13:28:24 ip-10-0-x-x origin-master: E1204 13:28:24.579794 32518 apiserver.go:440] apiserver was unable to write a JSON response: Get https://ip-10-0-x-x.compute.internal:10250/containerLogs/test/test-1-iok8n/test: dial tcp 10.0.x.x:10250: i/o timeout
Dec 4 13:28:24 ip-10-0-x-x origin-master: E1204 13:28:24.579822 32518 errors.go:62] apiserver received an error that is …Run Code Online (Sandbox Code Playgroud) 我在服务器端有两个方法,如下所示:
var Future = require("fibers/future");
Meteor.methods({
foo: function () {
this.unblock();
var f = new Future();
setTimeout(function () {
f.return(42);
}, 10000);
return f.wait();
},
bar: function () {
return 43;
}
});
Run Code Online (Sandbox Code Playgroud)
从客户端(使用浏览器控制台)调用这些方法时,它们工作正常(foo等待10秒,然后bar立即工作):
Meteor.call("foo", function (err, data) {
console.log(err || data);
// After 10 seconds: 42
});
Meteor.call("bar", function (err, data) {
console.log(err || data);
// Very quick (*instantly*): 43
});
Run Code Online (Sandbox Code Playgroud)
但是,当有一个会话并且我们调用时Meteor.logout(fn),callback(fn)将在foo完成之后等待.
我不希望这样.我希望这个logout方法能够像bar(不等待完成foo,但立即工作)一样工作. …
我正在尝试使用requestAnimationFrame创建具有滚动编号的javascript动画
In order to see the see the animation rolling, I need to use a $apply to refresh the view. The problem here is when I start the animation, the digest cycle is already running so my $apply return an error "$apply already in progress".
Looking for a solution I use $timeout of 0 which work perfectly but I was wondering if there was other solution to avoid using a timeout that is not really good in terms of performance? …
给出初始值(x),函数(f),谓词(p)和时间界限(t).我想在x上重复应用'f'直到它满足'p'.但同时要确保它不超过时间限制.如果时间超过't',它应该返回部分结果,即一对数'n'和'''对'x'应用'f'n次的值,对于它实际执行计算的最大n.
如果放宽部分结果条件,可以轻松编程为 -
import System.Timeout
iter :: a -> (a -> a) -> (a -> Bool) -> Int -> IO (Maybe (Int, a))
iter x f p t = do
let fs = x:(map f fs)
timeout t $ return $! head $ filter (\x -> p $ snd x) $ zip [1..] fs
Run Code Online (Sandbox Code Playgroud)
我希望它的签名类似于 -
iter :: a -> (a -> a) -> (a -> Bool) -> Int -> IO (Either (Int, a) (Int, a))
Run Code Online (Sandbox Code Playgroud)
左侧为部分结果,右侧为完整结果.
使用上述功能的一个愚蠢而微不足道的例子是 -
*Main> …Run Code Online (Sandbox Code Playgroud) 我有一个Node应用程序做了一些异步的事情,我不能冒险让很多模块中的一个做坏事而陷入困境,所以app永远不会退出.(它只是在向服务发送日志消息时发生的.)
我无法process.exit直接使用,因为无论有多少异步操作挂起,它都会终止.我还是想尽早退出,所以这不会做:
function exit() {
setTimeout(function() {
process.exit(1);
}, 10000);
}
Run Code Online (Sandbox Code Playgroud)
因为这将等待10秒,即使一切正常,所有异步事件在1秒后完成.
我正在考虑检查事件循环是否为空,除了这个计时器,然后退出.这可能是通过一些未记录的过程方法来完成的,但我更喜欢避免那种阴暗的东西.关于更好的解决方法的任何想法?
我正在使用Node JS,我正在尝试连接到mysql数据库.它因超时而不断断开连接,因此我写了一个函数来重新连接,如果它超时.虽然我需要它是一个连续的连接或我的代码中的引用将无法正常工作.这是我的相关代码:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : '.........', // MySQL Host
user : '.........', // MySQL User
password : '.........', // MySQL Password
database : '.........' // MySQL Databse
});
// MYSQL INFO
//connection.connect();
function replaceClientOnDisconnect(connection) {
connection.on("error", function (err) {
if (!err.fatal) {
console.log('Databse Error, error not fatal');
return;
}
if (err.code !== "PROTOCOL_CONNECTION_LOST") {
throw err;
console.log('PROTOCOL_CONNECTION_LOST Error: Reconnecting to database...');
}
setTimeout(function () {
connection.destroy();
connection = mysql.createConnection(connection.config);
replaceClientOnDisconnect(connection);
connection.connect(function (error) { …Run Code Online (Sandbox Code Playgroud) 代码:
try {
$documentsFind = $client->$db->$collection->find([
// query
]);
if ($documentsFind) {
foreach ($documentsFind as $product) {
// code...
}
}
catch (MongoCursorException $e) {
echo "error message: ".$e->getMessage()."\n";
echo "error code: ".$e->getCode()."\n";
}
Run Code Online (Sandbox Code Playgroud)
错误:
致命错误:未捕获的MongoDB \ Driver \ Exception \ RuntimeException:未找到游标,游标ID:31837896248 ...
似乎光标确实存在但超时了?如何防止这种情况发生?
编辑添加:我尝试做:
if ($documentsFind) {
$documentsFind->immortal(true); // keep alive
foreach ($documentsFind as $product) {
// code...
}
}
Run Code Online (Sandbox Code Playgroud)
但这导致了Call to undefined method MongoDB\Driver\Cursor::immortal()。
timeout ×10
javascript ×3
node.js ×2
php ×2
angularjs ×1
asynchronous ×1
cfml ×1
coldfusion ×1
coldfusion-9 ×1
cursor ×1
exception ×1
fiber ×1
haskell ×1
kubernetes ×1
meteor ×1
mongodb ×1
mysql ×1
openwrt ×1