Skip to content

Commit 3374237

Browse files
author
Claudio
committed
changing TIMEOUT settings to global
1 parent e4e37b4 commit 3374237

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bitly.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
import simplejson
2121
import urllib, urllib2
22+
import socket
2223
from urllib2 import URLError
2324
import urlparse
2425
import string
2526

2627
BITLY_API_VERSION = "2.0.1"
2728

29+
TIMEOUT = 1 #SECONDS
30+
2831
VERBS_PARAM = {
2932
'shorten':'longUrl',
3033
'expand':'shortUrl',
@@ -171,9 +174,8 @@ def _fetchUrl(self, url):
171174

172175
# Open and return the URL
173176
try:
174-
import socket
175-
timeout = 1
176-
socket.setdefaulttimeout(timeout);
177+
178+
socket.setdefaulttimeout(TIMEOUT);
177179
url_data = self._urllib.urlopen(url=url).read()
178180
except URLError, err:
179181
# nasty bit of hack, i know but unfortunatly urllib2 has no smart way of telling me

0 commit comments

Comments
 (0)