<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def main_loop(self):
 """The main loop a worker runs to receive and execute tasks."""


        def exit(signum, frame):
            shutdown()
            sys.exit(0)

        signal.signal(signal.SIGTERM, exit)

        while True:
            task = self._get_next_task_from_raylet()
            self._wait_for_and_process_task(task)