def produce(self, topic, doc, payload):
"""
Produce a new event.
:param topic: The topic of the produced event.
:param doc: The document to which the event belongs.
:param payload: The file pointer beloning to the document.
:type topic: ``str``
:type doc: ``gransk.core.Document``
:type payload: ``file``
"""
caller = inspect.currentframe().f_back.f_locals['self'].__module__
listeners = self.listeners.get(topic, [])
filename = os.path.basename(doc.path)
for listener, callback in listeners:
LOGGER.debug('[%s] %s -> %s (%s)', topic, caller, listener, filename)
callback(doc, payload)
if len(listeners) == 0:
LOGGER.debug('[%s] %s -> no listeners (%s)', topic, caller, filename)
评论列表
文章目录