lower timeout, add to library
This commit is contained in:
parent
fe65cd39bf
commit
255bb6ce5c
3 changed files with 16 additions and 6 deletions
|
@ -31,6 +31,7 @@ class Node(object):
|
||||||
_cert = None
|
_cert = None
|
||||||
online = False
|
online = False
|
||||||
download_speed = 0
|
download_speed = 0
|
||||||
|
TIMEOUT = 3
|
||||||
|
|
||||||
def __init__(self, nodes, user):
|
def __init__(self, nodes, user):
|
||||||
self._nodes = nodes
|
self._nodes = nodes
|
||||||
|
@ -97,7 +98,7 @@ class Node(object):
|
||||||
}
|
}
|
||||||
self._opener.addheaders = zip(headers.keys(), headers.values())
|
self._opener.addheaders = zip(headers.keys(), headers.values())
|
||||||
try:
|
try:
|
||||||
r = self._opener.open(url, data=content)
|
r = self._opener.open(url, data=content, timeout=self.TIMEOUT)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
if e.code == 403:
|
if e.code == 403:
|
||||||
logger.debug('REMOTE ENDED PEERING')
|
logger.debug('REMOTE ENDED PEERING')
|
||||||
|
@ -235,7 +236,7 @@ class Node(object):
|
||||||
content = r.content
|
content = r.content
|
||||||
'''
|
'''
|
||||||
self._opener.addheaders = zip(headers.keys(), headers.values())
|
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:
|
if r.getcode() == 200:
|
||||||
content = r.read()
|
content = r.read()
|
||||||
t2 = datetime.now()
|
t2 = datetime.now()
|
||||||
|
|
|
@ -136,10 +136,18 @@ actions.register(editList, cache=False)
|
||||||
@returns_json
|
@returns_json
|
||||||
def addListItems(request):
|
def addListItems(request):
|
||||||
data = json.loads(request.form['data']) if 'data' in request.form else {}
|
data = json.loads(request.form['data']) if 'data' in request.form else {}
|
||||||
l = models.List.get_or_create(data['list'])
|
if data['list'] == ':':
|
||||||
if l:
|
from item.models import Item
|
||||||
l.add_items(data['items'])
|
user = state.user()
|
||||||
return l.json()
|
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 {}
|
return {}
|
||||||
actions.register(addListItems, cache=False)
|
actions.register(addListItems, cache=False)
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ oml.clearFilters = function() {
|
||||||
items: addedItems,
|
items: addedItems,
|
||||||
list: target
|
list: target
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
Ox.Request.clearCache();
|
||||||
callback(result, addedItems);
|
callback(result, addedItems);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue