import socket
import time
import ssl
-import tornado.gen
import tornado.httpclient
import tornado.iostream
import tornado.netutil
return iter(mirrors)
- @tornado.gen.coroutine
- def check_all(self):
+ async def check_all(self):
for mirror in self:
with self.db.transaction():
- yield mirror.check()
+ await mirror.check()
def get_for_download(self, filename, country_code=None):
# Try to find a good mirror for this country first
def disabled(self):
return not self.enabled
- @tornado.gen.coroutine
- def check(self):
+ async def check(self):
logging.debug("Running check for mirror %s" % self.hostname)
self.db.execute("UPDATE mirrors SET address = %s WHERE id = %s",
self.address, self.id)
- success = yield self.check_timestamp()
-
+ success = await self.check_timestamp()
if success:
- yield self.check_filelist()
+ await self.check_filelist()
def check_state(self, last_update):
logging.debug("Checking state of mirror %s" % self.id)
self.set_state("UP")
- @tornado.gen.coroutine
- def check_timestamp(self):
+ async def check_timestamp(self):
http = tornado.httpclient.AsyncHTTPClient()
try:
- response = yield http.fetch(self.url + ".timestamp",
+ response = await http.fetch(self.url + ".timestamp",
headers={ "Pragma" : "no-cache" })
except tornado.httpclient.HTTPError as e:
logging.error("Error getting timestamp from %s: %s" % (self.hostname, e))
return True
- @tornado.gen.coroutine
- def check_filelist(self):
+ async def check_filelist(self):
# XXX need to remove data from disabled mirrors
if not self.enabled:
return
http = tornado.httpclient.AsyncHTTPClient()
try:
- response = yield http.fetch(self.url + ".filelist",
+ response = await http.fetch(self.url + ".filelist",
headers={ "Pragma" : "no-cache" })
except tornado.httpclient.HTTPError as e:
logging.error("Error getting filelist from %s: %s" % (self.hostname, e))