def __init__(self, ioloop, channel):
"""
Initialize the Worker in the main thread.
:param ioloop: The main tornado ioloop.
:param channel: The channel being listened.
"""
self.jobs = []
self.ioloop = ioloop # Main tornado ioloop
self.channel = channel # Channel to listen and send messages to
self.results = []
self.tasks = 0
self.running_jobs = []
self.jobs_futures = []
self.executor = ThreadPoolExecutor(
max_workers=self.MAX_BATCH_OPERATIONS)
self.init_cache()
self.execute_evaluation_loop()
# Receive a kick in the nuts when somebody talks
io_loop.add_handler(conn.fileno(), self.receive(), io_loop.READ)
# Always listen before talking
print("Attached database listener")
self.listen()
self.talk("work!")
评论列表
文章目录