remove explicite ioloop argument, supporting tornado >= 5

This also makes it no longer support tornado < 3.1, which was at least
five years old.

Fixes #4.
This commit is contained in:
lilydjwg 2018-08-10 15:39:20 +08:00
parent 763d1ec110
commit 05c6a7b233
2 changed files with 9 additions and 13 deletions

View file

@ -13,7 +13,7 @@ DEPENDENCIES
- Python, >= 3.3, with sqlite support - Python, >= 3.3, with sqlite support
- setuptools - setuptools
- tornado, > 2.4.1 - tornado, > 3.1
- pyinotify, tested with 0.9.4 - pyinotify, tested with 0.9.4
NOTE NOTE

View file

@ -50,9 +50,9 @@ class RepoMan:
_cmd_queue = queue.Queue() _cmd_queue = queue.Queue()
_cmd_running = False _cmd_running = False
def __init__(self, config, base, ioloop=None): def __init__(self, config, base):
self.action = [] self.action = []
self._ioloop = ioloop or IOLoop.current() self._ioloop = IOLoop.current()
self._base = base self._base = base
self._repo_dir = config.get('path') self._repo_dir = config.get('path')
@ -90,10 +90,10 @@ class RepoMan:
return return
logger.info('Running cmd: %r', cmd) logger.info('Running cmd: %r', cmd)
# have to specify io_loop or we'll get error tracebacks in some versions # no longer have to specify io_loop in Tornado > 3.1. Let's drop them for
# of Tornado # Tornado >= 5
try: try:
p = tornado.process.Subprocess(cmd, io_loop=self._ioloop) p = tornado.process.Subprocess(cmd)
except OSError: except OSError:
logger.error('failed to run command.', exc_info=True) logger.error('failed to run command.', exc_info=True)
self.run_command() self.run_command()
@ -218,13 +218,13 @@ class RepoMan:
self._do_remove(toremove) self._do_remove(toremove)
class EventHandler(pyinotify.ProcessEvent): class EventHandler(pyinotify.ProcessEvent):
def my_init(self, filter_pkg, supported_archs, config, wm, ioloop=None): def my_init(self, filter_pkg, supported_archs, config, wm):
self.filter_pkg = filter_pkg self.filter_pkg = filter_pkg
self.moved_away = {} self.moved_away = {}
self.repomans = {} self.repomans = {}
# TODO: use an expiring dict # TODO: use an expiring dict
self.our_links = set() self.our_links = set()
self._ioloop = ioloop or IOLoop.current() self._ioloop = IOLoop.current()
base = config.get('path') base = config.get('path')
dbname = config.get('info-db', os.path.join(base, 'pkginfo.db')) dbname = config.get('info-db', os.path.join(base, 'pkginfo.db'))
@ -466,7 +466,6 @@ def pkgsortkey(path):
def repomon(config): def repomon(config):
wm = pyinotify.WatchManager() wm = pyinotify.WatchManager()
ioloop = IOLoop.current()
supported_archs = config.get('supported-archs', 'i686 x86_64').split() supported_archs = config.get('supported-archs', 'i686 x86_64').split()
if 'any' not in supported_archs: if 'any' not in supported_archs:
@ -481,11 +480,9 @@ def repomon(config):
supported_archs = supported_archs, supported_archs = supported_archs,
config = config, config = config,
wm = wm, wm = wm,
ioloop = ioloop,
) )
ret = [pyinotify.TornadoAsyncNotifier( ret = [pyinotify.TornadoAsyncNotifier(
wm, wm,
ioloop,
default_proc_fun=handler, default_proc_fun=handler,
)] )]
@ -499,8 +496,7 @@ def repomon(config):
wm = wm, wm = wm,
) )
ret.append(pyinotify.TornadoAsyncNotifier( ret.append(pyinotify.TornadoAsyncNotifier(
wm, ioloop, wm, default_proc_fun=handler,
default_proc_fun=handler,
)) ))
return ret return ret