# Buggy code
def pre_destroy(self):
    self._heartbeat_ref.destroy()
    super().pre_destroy()


# Traceback (mars.actors.errors.ActorNotExist)
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "mars/actors/pool/gevent_pool.pyx", line 70, in mars.actors.pool.gevent_pool.MessageContext.result
cpdef result(self):
File "mars/actors/pool/gevent_pool.pyx", line 71, in mars.actors.pool.gevent_pool.MessageContext.result
return self.async_result.result()
File "src/gevent/event.py", line 383, in gevent._gevent_cevent.AsyncResult.result
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/opt/conda/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "mars/actors/pool/gevent_pool.pyx", line 94, in mars.actors.pool.gevent_pool.ActorExecutionContext.fire_run
res = actor.on_receive(message_ctx.message)
File "mars/actors/core.pyx", line 112, in mars.actors.core._FunctionActor.on_receive
File "mars/actors/core.pyx", line 114, in mars.actors.core._FunctionActor.on_receive
File "/home/admin/work/_public-mars-0.4.5.zip/mars/cluster_info.py", line 147, in set_schedulers
getattr(observer_ref, fun_name)(schedulers, _tell=True)
File "mars/actors/core.pyx", line 63, in mars.actors.core.ActorRef.__getattr__._mt_call
File "mars/actors/core.pyx", line 41, in mars.actors.core.ActorRef.tell
File "mars/actors/pool/gevent_pool.pyx", line 204, in mars.actors.pool.gevent_pool.ActorContext.tell
return self._comm.tell(actor_ref, message, delay=delay,
File "mars/actors/pool/gevent_pool.pyx", line 775, in mars.actors.pool.gevent_pool.Communicator.tell
cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
File "mars/actors/pool/gevent_pool.pyx", line 781, in mars.actors.pool.gevent_pool.Communicator.tell
return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
File "mars/actors/pool/gevent_pool.pyx", line 768, in mars.actors.pool.gevent_pool.Communicator._send
return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
File "mars/actors/pool/gevent_pool.pyx", line 677, in mars.actors.pool.gevent_pool.Communicator._dispatch
return redirect_func(send_to_index, *args, **kwargs)
File "mars/actors/pool/gevent_pool.pyx", line 748, in mars.actors.pool.gevent_pool.Communicator._send_process
return self.submit(message_id)
File "mars/actors/pool/gevent_pool.pyx", line 311, in mars.actors.pool.gevent_pool.AsyncHandler.submit
return ar.result()
File "src/gevent/event.py", line 383, in gevent._gevent_cevent.AsyncResult.result
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/opt/conda/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "mars/actors/pool/gevent_pool.pyx", line 977, in mars.actors.pool.gevent_pool.Communicator._on_receive_tell
actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
File "mars/actors/pool/gevent_pool.pyx", line 259, in mars.actors.pool.gevent_pool.LocalActorPool.get_actor_execution_ctx
cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
File "mars/actors/pool/gevent_pool.pyx", line 263, in mars.actors.pool.gevent_pool.LocalActorPool.get_actor_execution_ctx
raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
mars.actors.errors.ActorNotExist: Actor w:8:mars-cpu-calc-backup-241-268bbd7e0aab350b99e6354b286f52ab-1492 does not exist
2020-08-25T07:08:35Z <Greenlet at 0x7fceb54cd830: <built-in method result of mars.actors.pool.gevent_pool.MessageContext object at 0x7fceb5b88730>> failed with ActorNotExist

# Fixed code
def pre_destroy(self):
    self._heartbeat_ref.destroy()
    self.unset_cluster_info_ref()
    super().pre_destroy()