English 中文(简体)
我怎么能够迫使我们不要忘记。
原标题:How can I force urllib2 to time out?

我想测试一下我在通过圆环2夺走数据时处理时间问题的情况,我想用某种方式迫使延期请求。

缺乏非常缓慢的互联网连接,我可以采用什么方法?

我似乎想起一种令人感兴趣的申请/诉讼,以模拟这些事情。 是否有人知道这种联系?

最佳回答
问题回答

如上文所述,你可以确定缺省时间,但你可以同时使用这两种方法,因为在露天方法中,有预断选择:

import urllib2
import socket

try:
    response = urllib2.urlopen("http://google.com", None, 2.5)
except URLError, e:
    print "Oops, timed out?"
except socket.timeout:
    print "Timed out!"

lli2的缺省时间是无限的,而进口的袖珍确保你能够赶上时间。 时限

为什么没有在所需时间段只睡觉的 b片中写出非常简单的CGI文字?

如果您重新在麦克风上运行,speedlimit非常冷静。

http://info.iet.unipi.it/~luigi/dummynet/“rel=“nofollow”>dummynet。 它的难度要大得多,但也让你做一些更令人感兴趣的事情。 http://code fromthe70s.org/dummynet.aspx” rel=“nofollow”>pre-configured 职称

If you re running on a Linux box already, there s netem.

我认为,我已经听到了一个叫做“Shaper”的基于视窗的工具,但我已经核实了这个工具。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签