コード例 #1
0
ファイル: threads.py プロジェクト: BakaRei/tachyon
    def wait_for_idle(self, workers, queue):
            """ Wait until fetch queue is empty and handle user interrupt """
            while not self.kill_received and not queue.empty():
                try:
                    sleep(0.1)
                except KeyboardInterrupt:
                    try:
                        stats.output_stats()
                        sleep(1)  
                    except KeyboardInterrupt:
                        textutils.output_info('Keyboard Interrupt Received, cleaning up threads')
                        # Clean reference to sockets
                        database.connection_pool = None

                        self.kill_received = True
                        
                        # Kill remaining workers but don't join the queue (we want to abort:))
                        for worker in workers:
                            worker.kill_received = True
                            if worker is not None and worker.isAlive():
                                worker.join(1)
            
                        # Kill the soft
                        sys.exit()  

            # Make sure everything is done before sending control back to application
            textutils.output_debug("Threads: joining queue of size: " + str(queue.qsize()))
            queue.join()
            textutils.output_debug("Threads: join done")

            for worker in workers:
                worker.kill_received = True
                worker.join()
コード例 #2
0
ファイル: threads.py プロジェクト: h3xstream/tachyon
    def wait_for_idle(self, workers, queue):
        """ Wait until fetch queue is empty and handle user interrupt """
        while not self.kill_received and not queue.empty():
            try:
                sleep(0.1)
            except KeyboardInterrupt:
                try:
                    stats.output_stats()
                    sleep(1)
                except KeyboardInterrupt:
                    textutils.output_info(
                        'Keyboard Interrupt Received, cleaning up threads')
                    self.kill_received = True

                    # Kill remaining workers but don't join the queue (we want to abort:))
                    for worker in workers:
                        worker.kill_received = True
                        if worker is not None and worker.isAlive():
                            worker.join(1)

                    # Kill the soft
                    sys.exit()

        # Make sure everything is done before sending control back to application
        textutils.output_debug("Threads: joining queue of size: " +
                               str(queue.qsize()))
        queue.join()
        textutils.output_debug("Threads: join done")

        for worker in workers:
            worker.kill_received = True
            worker.join()
コード例 #3
0
    def wait_for_idle(self, workers, queue):
        """ Wait until fetch queue is empty and handle user interrupt """
        while not database.kill_received and not queue.empty():
            try:
                sleep(0.1)
            except KeyboardInterrupt:
                try:
                    stats.output_stats()
                    sleep(1)
                except KeyboardInterrupt:
                    textutils.output_info(
                        'Keyboard Interrupt Received, cleaning up threads')
                    # Clean reference to sockets
                    database.connection_pool = None
                    database.kill_received = True

                    # Kill remaining workers but don't join the queue (we want to abort:))
                    for worker in workers:
                        if worker is not None and worker.isAlive():
                            worker.kill_received = True
                            worker.join(0)

                    # Set leftover done in cas of a kill.
                    while not queue.empty():
                        queue.get()
                        queue.task_done()

                    break

        # Make sure everything is done before sending control back to application
        textutils.output_debug("Threads: joining queue of size: " +
                               str(queue.qsize()))
        queue.join()
        textutils.output_debug("Threads: join done")

        # Make sure we get all the worker's results before continuing the next step
        for worker in workers:
            if worker is not None and worker.isAlive():
                worker.kill_received = True
                worker.join()
コード例 #4
0
    def wait_for_idle(self, workers, queue):
            """ Wait until fetch queue is empty and handle user interrupt """
            while not database.kill_received and not queue.empty():
                try:
                    # Make sure everything is done before sending control back to application
                    textutils.output_debug("Threads: joining queue of size: " + str(queue.qsize()))
                    queue.join()
                    textutils.output_debug("Threads: join done")
                except KeyboardInterrupt:
                    try:
                        stats.output_stats(workers)
                        sleep(1)  # The time you have to re-press ctrl+c to kill the app.
                    except KeyboardInterrupt:
                        textutils.output_info('Keyboard Interrupt Received, waiting for blocking threads to exit')
                        # Clean reference to sockets
                        database.connection_pool = None
                        database.kill_received = True
                        self.kill_workers(workers)
                        sys.exit(0)

            # Make sure we get all the worker's results before continuing the next step
            self.kill_workers(workers)
コード例 #5
0
ファイル: threads.py プロジェクト: GoSecure/tachyon
    def wait_for_idle(self, workers, queue):
            """ Wait until fetch queue is empty and handle user interrupt """
            while not database.kill_received and not queue.empty():
                try:
                    sleep(0.1)
                except KeyboardInterrupt:
                    try:
                        stats.output_stats()
                        sleep(1)  
                    except KeyboardInterrupt:
                        textutils.output_info('Keyboard Interrupt Received, cleaning up threads')
                        # Clean reference to sockets
                        database.connection_pool = None
                        database.kill_received = True
                        
                        # Kill remaining workers but don't join the queue (we want to abort:))
                        for worker in workers:
                            if worker is not None and worker.isAlive():
                                worker.kill_received = True
                                worker.join(0)

                        # Set leftover done in cas of a kill.
                        while not queue.empty():
                            queue.get()
                            queue.task_done()

                        break

            # Make sure everything is done before sending control back to application
            textutils.output_debug("Threads: joining queue of size: " + str(queue.qsize()))
            queue.join()
            textutils.output_debug("Threads: join done")

            # Make sure we get all the worker's results before continuing the next step
            for worker in workers:
                if worker is not None and worker.isAlive():
                    worker.kill_received = True
                    worker.join()