|
@@ -569,29 +569,6 @@ class ToTextBotAgent:
|
|
|
return parsed_response
|
|
|
|
|
|
|
|
|
-class RandomIntVal():
|
|
|
- def __init__(self):
|
|
|
- self.value = randint(0, 100000)
|
|
|
-
|
|
|
-class AsyncJob(pj.PendingJob):
|
|
|
- def __init__(self, ep, app):
|
|
|
- super().__init__()
|
|
|
- self.ep = ep
|
|
|
- self.app = app
|
|
|
- self.logger = app.logger
|
|
|
- self.val = RandomIntVal()
|
|
|
- self.logger.warn("Job created id: %s, value: %s", id(self), self.val.value)
|
|
|
-
|
|
|
- def execute(self, is_pending):
|
|
|
- self.logger.warn("Executing job value: %s, %s", self.val.value, is_pending)
|
|
|
-
|
|
|
- time.sleep(1)
|
|
|
- self.ep.utilAddPendingJob(self)
|
|
|
-
|
|
|
- def __del__(self):
|
|
|
- self.logger.warn("Job deleted id:%s, value:%s", id(self), self.val.value)
|
|
|
-
|
|
|
-
|
|
|
@singleton_keys
|
|
|
class BotAgent:
|
|
|
|
|
@@ -618,9 +595,24 @@ class BotAgent:
|
|
|
self.daemon_job_scheduler.add_job(self._main_thread_daemon, 'interval', seconds=1, max_instances=1, name='bot_agent_daemon')
|
|
|
self.daemon_job_scheduler.start()
|
|
|
|
|
|
+ class AsyncJob(pj.PendingJob):
|
|
|
+ def __init__(self, agent):
|
|
|
+ self.agent = agent
|
|
|
+ super().__init__()
|
|
|
+ agent.logger.warn("Job created id: %s", id(self))
|
|
|
+
|
|
|
+ def execute(self, is_pending):
|
|
|
+ self.agent.logger.warn("Executing job value: %s", is_pending)
|
|
|
+
|
|
|
+ time.sleep(1)
|
|
|
+ self.ep.utilAddPendingJob(self)
|
|
|
+
|
|
|
+ def __del__(self):
|
|
|
+ self.agent.logger.warn("Job deleted id:%s", id(self))
|
|
|
+
|
|
|
def _add_new_job(self):
|
|
|
self.logger.warn("Creating job 1")
|
|
|
- job = AsyncJob(self.ep, self.app)
|
|
|
+ job = self.AsyncJob(self)
|
|
|
self.logger.warn("Adding job 1")
|
|
|
self.ep.utilAddPendingJob(job)
|
|
|
|