def attach_endpoint(self, endpoint_):
        peer_id = endpoint_.peer_id
        # Check if this is a reconnect after migration
        match = [e for e in self.endpoints if e.peer_id == peer_id]
        if not match:
            old_endpoint = None
        else:
            old_endpoint = match[0]
            self.detach_endpoint(old_endpoint)

        self.fifo.add_reader(endpoint_.peer_id)
        self.endpoints.append(endpoint_)
        self.owner.did_connect(self)
        return old_endpoint
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/actor/actorport.py/OutPort.attach_endpoint/original