We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4e37b4 commit 3374237Copy full SHA for 3374237
bitly.py
@@ -19,12 +19,15 @@
19
20
import simplejson
21
import urllib, urllib2
22
+import socket
23
from urllib2 import URLError
24
import urlparse
25
import string
26
27
BITLY_API_VERSION = "2.0.1"
28
29
+TIMEOUT = 1 #SECONDS
30
+
31
VERBS_PARAM = {
32
'shorten':'longUrl',
33
'expand':'shortUrl',
@@ -171,9 +174,8 @@ def _fetchUrl(self, url):
171
174
172
175
# Open and return the URL
173
176
try:
- import socket
- timeout = 1
- socket.setdefaulttimeout(timeout);
177
178
+ socket.setdefaulttimeout(TIMEOUT);
179
url_data = self._urllib.urlopen(url=url).read()
180
except URLError, err:
181
# nasty bit of hack, i know but unfortunatly urllib2 has no smart way of telling me
0 commit comments