Exemplo n.º 1
0
    def simulate_activity(self, orgs, num_runs):
        self._log("Starting simulation. Ctrl+C to cancel...\n")
        start = time.time()

        runs = 0
        while runs < num_runs:
            try:
                with transaction.atomic():
                    # make sure every org has an active flow
                    for org in orgs:
                        if not org.cache["activity"]:
                            self.start_flow_activity(org)

                with transaction.atomic():
                    org = self.random_org(orgs)

                    if self.probability(0.1):
                        self.create_unsolicited_incoming(org)
                    else:
                        self.create_flow_run(org)
                        runs += 1

            except KeyboardInterrupt:
                self._log("Shutting down...\n")
                break

        self._log("Simulation ran for %d seconds\n" % int(time.time() - start))

        squash_channelcounts()
        squash_flowpathcounts()
        squash_flowruncounts()
        squash_topupcredits()
        squash_msgcounts()
Exemplo n.º 2
0
    def simulate_activity(self, orgs, num_runs):
        self._log("Starting simulation. Ctrl+C to cancel...\n")

        runs = 0
        while runs < num_runs:
            try:
                with transaction.atomic():
                    # make sure every org has an active flow
                    for org in orgs:
                        if not org.cache['activity']:
                            self.start_flow_activity(org)

                with transaction.atomic():
                    org = self.random_org(orgs)

                    if self.probability(0.1):
                        self.create_unsolicited_incoming(org)
                    else:
                        self.create_flow_run(org)
                        runs += 1

            except KeyboardInterrupt:
                self._log("Shutting down...\n")
                break

        squash_channelcounts()
        squash_flowpathcounts()
        squash_flowruncounts()
        prune_recentmessages()
        squash_topupcredits()
        squash_labelcounts()
Exemplo n.º 3
0
    def simulate_activity(self, orgs, num_runs):
        self._log("Starting simulation. Ctrl+C to cancel...\n")
        start = time.time()

        runs = 0
        while runs < num_runs:
            try:
                with transaction.atomic():
                    # make sure every org has an active flow
                    for org in orgs:
                        if not org.cache["activity"]:
                            self.start_flow_activity(org)

                with transaction.atomic():
                    org = self.random_org(orgs)

                    if self.probability(0.1):
                        self.create_unsolicited_incoming(org)
                    else:
                        self.create_flow_run(org)
                        runs += 1

            except KeyboardInterrupt:
                self._log("Shutting down...\n")
                break

        self._log("Simulation ran for %d seconds\n" % int(time.time() - start))

        squash_channelcounts()
        squash_flowpathcounts()
        squash_flowruncounts()
        squash_topupcredits()
        squash_msgcounts()