GrpcCallBatcher#
- class ansys.stk.core.utilities.grpcutilities.GrpcCallBatcher#
object
A class used to batch together API calls to optimize performance.
Activating batching will cause the normal API exception behavior to be altered. Exceptions from one command may appear asynchronously. Therefore it is not recommended to use call batching while building and debugging, but rather as a performance optimization.
Only calls that do not return a value may be batched together, such as set-property requests and methods without a return value. Any method that has a return value (including get-property requests) will automatically execute any previously batched commands before the method with a return value is executed.
Therefore, to reduce the number of remote API requests and improve performance, code must be organized to group together commands that do not have a return value. Call chaining will interrupt a batch request because of the get-property command within the chain. E.g.:
root.CurrentScenario.ShortDescription = short_description root.CurrentScenario.LongDescription = long_description
will not be batched together because the call to CurrentScenario will get the scenario via an API call. These commands may be batched by factoring out the call chaining:
scen = root.CurrentScenario scen.ShortDescription = short_description scen.LongDescription = long_description
This class may be used via the explicit commands or by using the βwithβ statement to batch together the commands within the statement block. e.g.
call_batcher = stk.NewGrpcCallBatcher() with call_batcher: facility1.LocalTimeOffset = 1.0 facility1.HeightAboveGround = 10.0 facility1.UseLocalTimeOffset = True facility1.ResetAzElMask()
Overview#
Explicitly start batching until stop_batching() is called. |
|
Explicitly execute any queued batch commands. |
|
Explicitly stop batching. |
|
Create an object of type future_type that supports batching operations. source_obj is an STK Object Model type, e.g. STKObjectRoot. future_provider is a member method or property of source_obj, e.g. STKObjectRoot.CurrentScenario. future_type is the STK Object Model type that is returned from future_provider, e.g. Scenario. args are the arguments passed to future_provider if applicable. |
Import detail#
from ansys.stk.core.utilities.grpcutilities import GrpcCallBatcher
Method detail#
- GrpcCallBatcher.start_batching(self) None #
Explicitly start batching until stop_batching() is called.
- Returns:
- GrpcCallBatcher.create_future(self, source_obj, future_provider, future_type)#
Create an object of type future_type that supports batching operations.
source_obj is an STK Object Model type, e.g. STKObjectRoot. future_provider is a member method or property of source_obj, e.g. STKObjectRoot.CurrentScenario. future_type is the STK Object Model type that is returned from future_provider, e.g. Scenario. args are the arguments passed to future_provider if applicable.