def _task_default(self, **kwargs):
"""
The default task that this console manages, which performs
the foregrounds simulations.
Returns
-------
success : bool
Whether the task successfully finished?
error : str
Error message if the task failed
NOTE
----
The task is synchronous and may be computationally intensive
(i.e., CPU-bound rather than IO/event-bound), therefore,
threads (or processes) are required to make it non-blocking
(i.e., asynchronous).
References:
[1] https://stackoverflow.com/a/32164711/4856091
"""
t1_start = time.perf_counter()
t2_start = time.process_time()
logger.info("Console DEFAULT task: START ...")
logger.info("Preparing to start foregrounds simulations ...")
logger.info("Checking the configurations ...")
self.configs.check_all()
#
logger.info("Importing modules + Numba JIT, waiting ...")
from ...foregrounds import Foregrounds
#
fg = Foregrounds(self.configs)
fg.preprocess()
fg.simulate()
fg.postprocess()
logger.info("Foregrounds simulations DONE!")
logger.info("Console DEFAULT task: DONE!")
t1_stop = time.perf_counter()
t2_stop = time.process_time()
logger.info("Elapsed time: {0:.3f} (s)".format(t1_stop - t1_start))
logger.info("CPU process time: {0:.3f} (s)".format(t2_stop - t2_start))
# NOTE: always return a tuple of (success, error)
return (True, None)
评论列表
文章目录