'Periodically checks whether the engine wrapper can be created.
Notifies when it\'s ready by calling the callback of the deferred being returned.
:return: A deferred that will be called when you can create the engine wrapper.'

def can_create_engine_wrapper(self):

    can_create_deferred = Deferred()
    def do_check():
        with self.dllock:
            if (not self.cew_scheduled):
                self.ltmgr = self.session.lm.ltmgr
                dht_ok = ((not isinstance(self.tdef, TorrentDefNoMetainfo)) or self.ltmgr.is_dht_ready())
                tunnel_community = self.ltmgr.tribler_session.lm.tunnel_community
                tunnels_ready = (tunnel_community.tunnels_ready(self.get_hops()) if tunnel_community else 1)
                if ((not self.ltmgr) or (not dht_ok) or (tunnels_ready < 1)):
                    self._logger.info(u'LTMGR/DHT/session    not    ready,    rescheduling    create_engine_wrapper')
                    if (tunnels_ready < 1):
                        self.dlstate = DLSTATUS_CIRCUITS
                        tunnel_community.build_tunnels(self.get_hops())
                    else:
                        self.dlstate = DLSTATUS_METADATA
                    self.register_task('check_create_wrapper', reactor.callLater(5, do_check))
                else:
                    can_create_deferred.callback(True)
            else:
                self.register_task('check_create_wrapper', reactor.callLater(5, do_check))
    do_check()
    return can_create_deferred
