<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def link(self, pid, to):
 """Link a local process to a possibly remote process. Note: It is more idiomatic to call ``link`` directly on the bound Process object instead. When ``pid`` is linked to ``to``, the termination of the ``to`` process (or the severing of its connection from the Process ``pid``) will result in the local process' ``exited`` method to be called with ``to``. This method returns immediately. :param pid: The pid of the linking process. :type pid: :class:`PID` :param to: The pid of the linked process. :type to: :class:`PID` :returns: Nothing """


    self._assert_started()

    def really_link():
      self._links[pid].add(to)
      log.info('Added link from %s to %s' % (pid, to))

    def on_connect(stream):
      really_link()

    if self._is_local(pid):
      really_link()
    else:
      self.__loop.add_callback(self._maybe_connect, to, on_connect)