The original multicall interface is less than optimal:
It is modal. Once session.multicall is set, the session cannot be used normally
Confusing to have both session.multicall and session.multiCall()
Processing the return value is tedious
These changes create a new implementation outside of ClientSession. The old way will still work.
With this new implementation:
a multicall is tracked as an instance of MultiCallSession
the original session is unaffected
multiple multicalls can be managed in parallel, if desired
MultiCallSession behaves more or less like a session in multicall mode
method calls return a VirtualCall instance that can later be used to access the result
MultiCallSession can be used as a context manager, ensuring that the calls are executed
Here is one example of possible use:
with session.multicall(strict=True) as m:
for package in to_add:
m.packageListAdd(tag, package, options.owner, **opts)
Here is an example that make use of the VirtualCall values:
tinfos = {}
with session.multicall(strict=True) as m:
for task_id in task_ids:
tinfos[task_id] = m.getTaskInfo(task_id)
for task_id, tinfo in tinfos.items():
tinfo = tinfo.result
The original multicall interface is less than optimal:
These changes create a new implementation outside of ClientSession. The old way will still work.
With this new implementation:
MultiCallSession
MultiCallSession
behaves more or less like a session in multicall modeVirtualCall
instance that can later be used to access the resultMultiCallSession
can be used as a context manager, ensuring that the calls are executedHere is one example of possible use:
Here is an example that make use of the VirtualCall values: