559 karma · joined January 27, 2011
> decorators are functions that take a callable argument and return a new callable
there's nothing forcing a decorator to return a callable. A decorator _could_ return anything it wants. I don't know why you would want that, but Python won't stop you.
Or worse, the developers get stuck in App Review Hell for over a week and are unable to release their fix to their users.
This happened to me when the reviewer took umbrage with our screenshots (which have passed numerous previous reviews) and kept rejecting our update. Meanwhile the app was bricked in some configurations with nothing anyone could do about it.
Tokyo-Osaka in an hour vs the current 2.5h, that's far from marginal, especially if you do a round-trip.
Having done that trip a couple of times recently for business, I can't wait for the Chuo Shinkansen to open.
That's presumably why people would want to do this. And bragging rights.
Maybe "the market" is not a good tool to solve inequality.
import multiprocessing
import time
NULL = object()
def call_webservice(fail=False):
if fail:
time.sleep(10)
return False
else:
return True
def wait_until_timeout(timeout, *async_results):
results = [NULL] * len(async_results)
end = time.time() + timeout
while time.time() < end:
for index, result in enumerate(async_results):
if results[index] is NULL and result.ready():
results[index] = result.get()
if not results.count(NULL): break
return tuple(None if result is NULL else result for result in results)
def handler():
with multiprocessing.Pool() as pool:
handle1 = pool.apply_async(call_webservice, (True,))
handle2 = pool.apply_async(call_webservice, (False,))
start = time.time()
realres1, realres2 = wait_until_timeout(0.5, handle1, handle2)
duration = time.time() - start
print(f'Took {duration:.3f} seconds')
print(realres1, realres2)
if __name__ == '__main__':
handler() def very_long_function_name(arg_one, arg_two, arg_three, arg_four):
...