Download:
child 178:290623d1275c
parent 176:545d03db7218
177:c62bd675b409
Anton Shestakov <av6@dwimlabs.net>, Fri, 22 Jul 2016 22:03:25 +0800
queue: poller is not a regular Tornado application, no need to listen

1 файлов изменено, 2 вставок(+), 16 удалений(-) [+]
poll-hgweb-queue.py file | annotate | diff | comparison | revisions
--- a/poll-hgweb-queue.py Fri Jul 22 20:34:44 2016 +0800
+++ b/poll-hgweb-queue.py Fri Jul 22 22:03:25 2016 +0800
@@ -8,18 +8,11 @@
from tornado.gen import coroutine
from tornado.httpclient import AsyncHTTPClient
from tornado.ioloop import IOLoop, PeriodicCallback
-from tornado.options import define, options
from tornado.web import Application
from candolint.utils import lookup_option, timestamp
-define('listen', metavar='IP', default='127.0.0.1')
-define('port', metavar='PORT', default=8035, type=int)
-define('xheaders', metavar='True|False', default=False, type=bool)
-options.logging = None
-
-
class CandolintPoller(Application):
def __init__(self, rconn, targets, interval, debug):
handlers = []
@@ -84,11 +77,6 @@
self.rconn.rpush('candolint:queue:changes', data)
logging.info('Pushed a change for %s', item['repo'])
- def listen(self, port, address='', **kwargs):
- name = self.__class__.__name__
- logging.info('%s is serving on %s:%d', name, address, port)
- super(CandolintPoller, self).listen(port, address, **kwargs)
-
def main():
parser = ArgumentParser(argument_default=SUPPRESS)
@@ -107,8 +95,7 @@
group.add_argument('--redis-password')
group.add_argument('--interval', type=int, help='(default: 8 hours)')
- args, extra = parser.parse_known_args()
- options.parse_command_line([None] + extra) # 1st argument is ignored
+ args = parser.parse_args()
config = yaml.safe_load(args.config) if hasattr(args, 'config') else {}
rhost = lookup_option('redis-host', args, config, default='127.0.0.1')
@@ -130,8 +117,7 @@
rconn = redis.StrictRedis(host=rhost, port=rport, password=rpass, db=0)
logging.info('Connected to Redis server')
- application = CandolintPoller(rconn, targets, interval, args.debug)
- application.listen(options.port, options.listen, xheaders=options.xheaders)
+ CandolintPoller(rconn, targets, interval, args.debug)
IOLoop.instance().start()