/usr/lib/python2.7/dist-packages/cl/agents.py is in python-cl 0.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """cl.agents"""
from __future__ import absolute_import
from kombu.common import uuid
from kombu.log import setup_logging
from kombu.mixins import ConsumerMixin
__all__ = ["Agent"]
class Agent(ConsumerMixin):
actors = []
def __init__(self, connection, id=None, actors=None):
self.connection = connection
self.id = id or uuid()
if actors is not None:
self.actors = actors
self.actors = self.prepare_actors()
def on_run(self):
pass
def run(self):
self.info("Agent on behalf of [%s] starting...",
", ".join(actor.name for actor in self.actors))
self.on_run()
super(Agent, self).run()
def stop(self):
pass
def on_consume_ready(self, *args, **kwargs):
for actor in self.actors:
actor.on_agent_ready()
def run_from_commandline(self, loglevel=None, logfile=None):
setup_logging(loglevel, logfile)
try:
self.run()
except KeyboardInterrupt:
self.info("[Quit requested by user]")
def prepare_actors(self):
return [actor.bind(self.connection, self) for actor in self.actors]
def get_consumers(self, Consumer, channel):
return [actor.Consumer(channel) for actor in self.actors]
def get_default_scatter_limit(self, actor):
return None
|