|
|
|
@ -65,9 +65,9 @@ def call_function_try_attempts(try_attempts=3, sleep_time=2, failed_callback=Non |
|
|
|
|
return decorator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_pending_result(func, expect_func, timeout=30, sleep_time=3, *args, **kwargs): |
|
|
|
|
def get_pending_result(func, expect_func, loop_count=10, sleep_time=3, *args, **kwargs): |
|
|
|
|
try: |
|
|
|
|
with cache.lock("%s_%s" % ('get_pending_result', kwargs.get('locker_key')), timeout=timeout + sleep_time): |
|
|
|
|
with cache.lock("%s_%s" % ('get_pending_result', kwargs.get('locker_key')), timeout=loop_count * sleep_time): |
|
|
|
|
count = 1 |
|
|
|
|
del kwargs['locker_key'] |
|
|
|
|
while True: |
|
|
|
@ -75,7 +75,7 @@ def get_pending_result(func, expect_func, timeout=30, sleep_time=3, *args, **kwa |
|
|
|
|
if expect_func(result, *args, **kwargs): |
|
|
|
|
return True, result |
|
|
|
|
time.sleep(sleep_time) |
|
|
|
|
if timeout < count * sleep_time: |
|
|
|
|
if loop_count < count: |
|
|
|
|
return False, result |
|
|
|
|
count += 1 |
|
|
|
|
except Exception as e: |
|
|
|
|