More Optim.
This commit is contained in:
@ -20,6 +20,7 @@ from ums.utils import AgentMessage, AgentResponse, logger
|
||||
class MessageProcessor():
|
||||
|
||||
SOLUTION_MAX_TRIALS = int(os.environ.get('SOLUTION_MAX_TRIALS', 5))
|
||||
MESSAGE_MAX_CONTACTS = int(os.environ.get('MESSAGE_MAX_CONTACTS', 100))
|
||||
|
||||
MANAGEMENT_URL = os.environ.get('MANAGEMENT_URL', 'http://127.0.0.1:80').strip().strip('/')
|
||||
|
||||
@ -78,6 +79,12 @@ class MessageProcessor():
|
||||
# do not process processed messages again
|
||||
return
|
||||
|
||||
# increment contacts counter
|
||||
db_message.message.contacts += 1
|
||||
if db_message.message.contacts > self.MESSAGE_MAX_CONTACTS:
|
||||
logger.warning(f"Message reached max number of contacts! {db_message.message.id}, {count}")
|
||||
return
|
||||
|
||||
# check which step/ state the message requires the management to do
|
||||
if db_message.message.status.extract.required and not db_message.message.status.extract.finished:
|
||||
# send to extract agents
|
||||
@ -136,6 +143,9 @@ class MessageProcessor():
|
||||
# add the riddle as new to management
|
||||
self._send_message(self.MANAGEMENT_URL, message)
|
||||
|
||||
else:
|
||||
logger.info(f"Unsolved riddle after max number of trials: {message.id}")
|
||||
|
||||
def _send_messages(self, recipients:List[str], message:AgentMessage) -> bool:
|
||||
ok = True
|
||||
for r in recipients:
|
||||
|
Reference in New Issue
Block a user