Utility classes and functions¶
-
gemstone.
as_completed
(*async_result_wrappers)[source]¶ Yields results as they become available from asynchronous method calls.
Example usage
async_calls = [service.call_method_async("do_stuff", (x,)) for x in range(25)] for async_call in gemstone.as_completed(*async_calls): print("just finished with result ", async_call.result())
Parameters: async_result_wrappers – gemstone.client.structs.AsyncMethodCall
instances.Returns: a generator that yields items as soon they results become available. New in version 0.5.0.
-
gemstone.
first_completed
(*async_result_wrappers)[source]¶ Just like
gemstone.as_completed()
, but returns only the first item and discards the rest.Parameters: async_result_wrappers – Returns: New in version 0.5.0.
-
gemstone.
make_callbacks
(async_result_wrappers, on_result, on_error, run_in_threads=False)[source]¶ Monitors the
gemstone.client.remote_service.AsyncMethodCall
instances from async_result_wrappers and apply callbacks depending on their outcome.Parameters: - async_result_wrappers – An iterable of
gemstone.client.remote_service.AsyncMethodCall
- on_result – a callable that takes a single positional argument (the result)
- on_error – a callabke that takes a single positional argument (the error)
- run_in_threads – flag tha specifies if the callbacks should be called in the current thread or in background threads
New in version 0.5.0.
- async_result_wrappers – An iterable of