Skip to content

Commit

Permalink
Use longer timeout with threaded uploads
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Easterbrook <jim@jim-easterbrook.me.uk>
  • Loading branch information
jim-easterbrook committed Feb 23, 2016
1 parent 6d4c346 commit 30464ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/pywws/ToTwitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def post(self, status, media):
self.api.update_status(status[:140], **self.kwargs)

class PythonTwitterHandler(object):
def __init__(self, key, secret, latitude, longitude):
def __init__(self, key, secret, latitude, longitude, timeout):
self.logger = logging.getLogger('pywws.ToTwitter')
self.logger.info('Using python-twitter library')
self.api = twitter.Api(
consumer_key=pct.consumer_key,
consumer_secret=pct.consumer_secret,
access_token_key=key, access_token_secret=secret,
timeout=30)
timeout=timeout)
if latitude is not None and longitude is not None:
self.kwargs = {'latitude' : latitude, 'longitude' : longitude,
'display_coordinates' : True}
Expand Down Expand Up @@ -123,7 +123,12 @@ def __init__(self, params):
longitude = params.get('twitter', 'longitude')
# open API
if twitter:
self.api = PythonTwitterHandler(key, secret, latitude, longitude)
if eval(params.get('config', 'asynchronous', 'False')):
timeout = 60
else:
timeout = 20
self.api = PythonTwitterHandler(
key, secret, latitude, longitude, timeout)
else:
self.api = TweepyHandler(key, secret, latitude, longitude)

Expand Down
6 changes: 3 additions & 3 deletions src/pywws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '16.02.0.dev1343'
_release = '1343'
_commit = '7e4ae90'
__version__ = '16.02.0.dev1344'
_release = '1344'
_commit = '6d4c346'
5 changes: 4 additions & 1 deletion src/pywws/toservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def __init__(self, params, status, calib_data, service_name):
self.old_response = None
self.old_ex = None
# set default socket timeout, so urlopen calls don't hang forever
socket.setdefaulttimeout(30)
if eval(self.params.get('config', 'asynchronous', 'False')):
socket.setdefaulttimeout(60)
else:
socket.setdefaulttimeout(20)
# open params file
service_params = SafeConfigParser()
service_params.optionxform = str
Expand Down

0 comments on commit 30464ba

Please sign in to comment.