def METHOD_NAME(self, code, task_id):
    self.logger.info(f"Run code for task {task_id}")
    self.logger.debug(f"Code for execution:\n{code}")
    try:
        self.shell.runcode(code)
    except SystemExit:
        pass
    if self.shell.last_traceback:
        self.on_crash(f'{self.shell.last_traceback}\n\ntask_id: {task_id!r}\ncode:\n{code}\n\n(end of code)')
        return
    self.logger.info("Code execution with task %s finished:", task_id)
    return_value = b64encode(self.shell.locals.get('return_value', '').encode('utf-8'))
    for socket in self.sockets:
        socket.write(b"result %s %s\n" % (return_value, task_id))