我有一个简单的SQL脚本,我从Visual Studio手动执行.它是一个数据生成脚本,所以我希望它需要几分钟才能运行.但是我收到以下错误.
超时已过期.操作完成之前经过的超时时间或服务器没有响应.
我不想改变任何全局服务器设置,以便能够运行这一个文件.是否有任何命令可以放在文件的顶部以增加该脚本/事务的超时?
我正在使用NSMutableURLRequest连接到网站以获取JSON响应.我这样做是通过生成请求,然后使用NSURLConnection与self的委托来处理异步连接.我已经实现了所有正常的委托方法:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
Run Code Online (Sandbox Code Playgroud)
所有这些都可以完美地恢复数据,处理发生的任何错误等.但是,如果将NSURLRequest上的超时设置为10秒,我似乎不会在这些方法中调用(我希望调用didFailWithError).它只是永远坐在那里,我没有通知它超时.
阅读iPhone API文档我没有看到什么任何提及应在发生超时时发生的,只是你可以设置超时值.应该怎么办?我没有在API中看到任何其他有用的委托方法.我不必手动检查超时,不是吗?超时仅适用于同步请求吗?
我有这段代码:
begin
complete_results = Timeout.timeout(4) do
results = platform.search(artist, album_name)
end
rescue Timeout::Error
puts 'Print me something please'
end
Run Code Online (Sandbox Code Playgroud)
然后我启动包含此代码的方法,以及这里是堆栈跟踪的开始:
Exception message : execution expired Exception backtrace : /***/****/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/timeout.rb:64:i
所以我天真地认为我的通话时间已经过去了.但是,"打印我喜欢的东西"永远不会被打印出来,并且complete_results假设是超时状态返回值(无论是真还是假,如文档中所提到的),最终都不是布尔值.
难道我做错了什么?
是否可以在Android中的BluetoothSocket中实现inputstream.read()函数的超时?
我尝试过使用Thread.sleep(),但这只会暂停我的活动.
---更新---
我有一个想法,在这里编写2个线程代码(t1和t2),其中每个线程中断其他,其中一个(t1)进行休眠(5000)然后中断另一个线程(t2),从另一个线程中断另一个线程( t2)如果在读取时输入流检测到某个字符为0x0D中断另一个线程(t1),但这是我的问题,有人可以帮助我吗?因为我没有使用thread()方法的线程,希望有人能帮助我,谢谢...
---更新---
public void run(){
while(true){
try {
char r;
String respuesta = "";
while (true) {
r = (char) mmInStream.read();
respuesta += r;
if (r == 0x3e) {
break;
}
}
respuesta = respuesta.replaceAll(" ", "");
Log.d("respuesta", respuesta);
rHandler.obtainMessage(MESSAGE_READ, -1, -1, respuesta).sendToTarget();
} catch (IOException readException) {
Log.e("ServicioGeneral", "Error de lectura", readException);
this.interrupt();
connectionLost();
// posibly break();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的实现,当某些东西进入不同的线程时,问题是如果我没有从de mmInStream获取0x3e字符,将达到超时.
我想在第二个例子中我必须使用notifyAll(),但是,什么时候我必须启动readThread()?
谢谢,@ weeman
我编写了一个程序,通过随机代理打开httpurlconnection到网站.我的httpurlconnection叫做conn.现在我知道,这其中的一些代理的可能太慢,所以我已经设置与连接至40000毫秒的超时conn.setConnectTimeout(40000)和conn.setReadTimeout(40000).
这样做后,我得到了这段代码:
long diff = 0;
long starttime = 0;
long endtime = 0;
try
{
starttime = System.currentTimeMillis();
conn.connect();
endtime = System.currentTimeMillis();
diff = endtime - starttime;
if (endtime <= starttime + conn.getConnectTimeout())
{
//Trying to read sourecode
InputStreamReader isrConn = new InputStreamReader(conn.getInputStream());
BufferedReader brConn = new BufferedReader(isrConn);
line = brConn.readLine();
while (line != null)
{
response += line + "\t";
try
{
line = brConn.readLine();
} catch (IOException e)
{
printError("Reading sourcecode …Run Code Online (Sandbox Code Playgroud) 我用jquery创建了spring web应用程序.对于每个使用$ .get或$ .post(非$ .ajax)的ajax调用.
但我没有处理任何ajax超时或ajax错误.现在我的应用程序部署在服务器上,我无法进行任何重大更改.
请帮助我如何处理整个Web应用程序的AJAX超时,我应该全局警告("Ajax超时").另外,无论ajax错误,我都应该向用户发出错误消息警告.
我听说过$ .ajaxSetup和$ .ajaxError
但是如何在我的Web应用程序中使用它们,我是否需要在document.ready中添加它?
我遇到过一种情况,我想跟踪一些goroutine以在特定点上同步,例如当获取所有URL时.然后,我们可以将它们全部放入并按特定顺序显示它们.
我认为这是障碍.它go与之相伴sync.WaitGroup.但是,在实际情况下,我们无法确保所有获取操作都能在短时间内成功.所以,我想wait在获取操作时引入超时.
我是新手Golang,所以有人可以给我一些建议吗?
我要找的是这样的:
wg := &sync.WaigGroup{}
select {
case <-wg.Wait():
// All done!
case <-time.After(500 * time.Millisecond):
// Hit timeout.
}
Run Code Online (Sandbox Code Playgroud)
我知道Wait不支持Channel.
我有一个连接到Oracle数据库的Mule应用程序.该应用程序是一个SOAP api,它允许执行SQL存储过程.我的连接器设置为使用连接池,我一直在监视连接.我的最大池大小为20,当调用数据库时,我可以看到它们打开(netstat -ntl | grep PORTNUMBER).
tcp4 0 0 IP HERE OTHER IP HERE SYN_SENT
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 0 IP HERE OTHER IP HERE ESTABLISHED
tcp4 0 …Run Code Online (Sandbox Code Playgroud) 我试图让 Gitlab 与 SSH 一起工作,但它不会。
我已经完成了以下步骤:
1) 生成 ssh 密钥
ssh-keygen -t rsa -C "myemail@myhoster.com" -b 4096
Run Code Online (Sandbox Code Playgroud)
2 ) 在文件夹 /Users/myUserName/.ssh/ 中将密钥命名为“id_rsa”
3)通过复制密钥
pbcopy < ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
4)将密钥插入gitlab
当我现在尝试克隆存储库时,我收到以下错误:
$ git clone git@gitlab.com:myName/repositoryName/ repoName
Cloning into 'repoName'...
ssh: connect to host gitlab.com port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
出了什么问题?
C++20std::atomic有wait和notify_*成员函数,但没有wait_for/ wait_until。
std::atomic使用Microsoft STL 实现WaitOnAddress(当操作系统足够新时)。这个API有一个dwMilliseconds参数,就像超时值一样。因此,从标准库编写者的角度来看,我认为缺少的功能很容易实现(至少在 Windows 8 或更高版本上)。我只是想知道为什么它不在 C++20 中。
但作为(便携式)用户代码编写者,我必须使用标准信号量和原子计数器来模拟行为。所以这是代码:
#include <concepts>
#include <atomic>
#include <type_traits>
#include <cstring>
#include <semaphore>
namespace detail
{
template <size_t N>
struct bytes
{
unsigned char space[N];
auto operator<=>(bytes const &) const = default;
};
//Compare by value representation, as requested by C++20.
//The implementation is a bit awkward.
//Hypothetically `std::atomic<T>::compare(T, T)` would be helpful. :)
template <std::integral T>
bool …Run Code Online (Sandbox Code Playgroud) timeout ×10
ajax ×1
android ×1
atomic ×1
bluetooth ×1
c++ ×1
c++20 ×1
connection ×1
database ×1
gitlab ×1
global ×1
go ×1
inputstream ×1
iphone ×1
java ×1
jquery ×1
mule ×1
nsurlrequest ×1
repository ×1
rescue ×1
ruby ×1
semaphore ×1
sql-server ×1
ssh ×1