'Called by any thread'

def remove(self, d, removecontent=False, removestate=True, hidden=False):

    with self.session_lock:
        d.stop_remove(removestate=removestate, removecontent=removecontent)
        infohash = d.get_def().get_infohash()
        if (infohash in self.downloads):
            del self.downloads[infohash]
    if (not hidden):
        self.remove_id(infohash)
    if self.tunnel_community:
        self.tunnel_community.on_download_removed(d)
