lower timeout, add to library

This commit is contained in:
j 2014-05-18 01:14:29 +02:00
parent fe65cd39bf
commit 255bb6ce5c
3 changed files with 16 additions and 6 deletions

View file

@ -31,6 +31,7 @@ class Node(object):
_cert = None
online = False
download_speed = 0
TIMEOUT = 3
def __init__(self, nodes, user):
self._nodes = nodes
@ -97,7 +98,7 @@ class Node(object):
}
self._opener.addheaders = zip(headers.keys(), headers.values())
try:
r = self._opener.open(url, data=content)
r = self._opener.open(url, data=content, timeout=self.TIMEOUT)
except urllib2.HTTPError as e:
if e.code == 403:
logger.debug('REMOTE ENDED PEERING')
@ -235,7 +236,7 @@ class Node(object):
content = r.content
'''
self._opener.addheaders = zip(headers.keys(), headers.values())
r = self._opener.open(url)
r = self._opener.open(url, timeout=self.TIMEOUT)
if r.getcode() == 200:
content = r.read()
t2 = datetime.now()

View file

@ -136,10 +136,18 @@ actions.register(editList, cache=False)
@returns_json
def addListItems(request):
data = json.loads(request.form['data']) if 'data' in request.form else {}
l = models.List.get_or_create(data['list'])
if l:
l.add_items(data['items'])
return l.json()
if data['list'] == ':':
from item.models import Item
user = state.user()
for item_id in data['items']:
i = Item.get(item_id)
if user not in i.users:
i.queue_download()
elif data['list']:
l = models.List.get_or_create(data['list'])
if l:
l.add_items(data['items'])
return l.json()
return {}
actions.register(addListItems, cache=False)

View file

@ -208,6 +208,7 @@ oml.clearFilters = function() {
items: addedItems,
list: target
}, function(result) {
Ox.Request.clearCache();
callback(result, addedItems);
});
} else {