'load source if and only if the overall system is ready.
This is useful so we don\'t burden the application during the startup'

def _load_if_ready(self, source):

    def check_system(defer_param=None):
        "\n                                                function    that    check    the    system    whether    it's    ready    or    not\n\n                                                it    depends    on    #connection    and    #channel\n                                                "
        if (defer_param is None):
            defer_param = defer.Deferred()
        nr_channels = self.channelcast_db.getNrChannels()
        nr_connections = 0
        for community in self.session.lm.dispersy.get_communities():
            from Tribler.community.search.community import SearchCommunity
            if isinstance(community, SearchCommunity):
                nr_connections = community.get_nr_connections()
        if ((nr_channels > self.min_channels) and (nr_connections > self.min_connection)):
            defer_param.callback(source)
        else:
            self.register_task((str(self.source) + '_check_sys'), reactor.callLater(10, check_system, defer_param))
        return defer_param
    defer_check = check_system()
    defer_check.addCallbacks(self._load, self._on_err)
    return defer_check
