Example #1
0
    def wrapper(*args):
        while True:
            sleep_amount = loop_function(*args)
            if (sleep_amount == 'break'): break
            elif (not sleep_amount): continue

            fast_sleep(sleep_amount)
Example #2
0
def wait_for_interface(interface, delay=ONE_SEC):
    '''will wait for interface to show powered on and waiting for network. will sleep for delay length after each check.'''

    while True:
        if _is_ready(interface): break

        fast_sleep(delay)
Example #3
0
def wait_for_ip(interface):
    '''will wait for interface ip address configuration then return ip address object
    for corresponding ip.'''

    while True:
        ipa = get_ip_address(interface=interface)
        if (ipa):
            return ipa

        fast_sleep(ONE_SEC)
Example #4
0
    def wait_in_line(self, *, wait_for):
        '''blocking call to wait for all lower number threads to complete before checking in and returning.

            initialize = Initialize(*args, **kwargs)
            initialize.wait_in_line(wait_for=2)

        this call has the potential to deadlock. positions must be sequential work as intended, but are not
        required to be called in order.

        '''
        if (not self._is_initializing): return

        while wait_for < len(self._thread_ready):
            fast_sleep(1)
Example #5
0
    def wait_for_threads(self, *, count, timeout=None):
        '''will block until the checked in thread count has reach the sent in count.'''
        if (not self._is_initializing or self.has_ran):
            raise RuntimeError('run has already been called for this self.')

        self._thread_count = count
        self._timeout = timeout

        self._Log.notice(f'{self._name} setup waiting for threads: {count}.')

        # blocking until all threads check in by individually calling done method
        while not self._initial_load_complete and not self._timeout_reached:
            fast_sleep(1)

        self.has_ran = True
        self._is_initializing = False

        self._Log.notice(f'{self._name} setup complete.')
Example #6
0
        def wrapper(*args):
            if (Log):
                Log.informational(f'{name}/dnx_queue started.')

            while True:
                job_wait()
                # clearing job notification
                job_clear()
                # processing all available jobs
                while queue:
                    job = queue_get()
                    try:
                        func(*args, job)
                    except Exception as E:
                        if (Log):
                            Log.warning(
                                f'error while processing a {name}/dnx_queue started job. | {E}'
                            )

                        fast_sleep(MSEC)
Example #7
0
        def wrapper(*args):
            while True:
                loop_function(*args)

                if (sleep_len):
                    fast_sleep(sleep_len)