def do_alto_post(self, endpoint, data, callback):
"""ALTO post to the given endpoint with given data"""
# Make HTTP POST to ALTO
url = self._alto_url + endpoint
try:
alto_resp_future = self._loop.run_in_executor(None, functools.partial(
requests.post, url, json=data))
alto_resp = yield from alto_resp_future
except OSError as exc:
logging.info('Consumed OSError while connecting to ALTO server')
return
# Process peers
ranked_peers = self._process_alto_response(alto_resp)
# Return results to swarm
callback(ranked_peers)
评论列表
文章目录