dank_mids.helpers package
Submodules
dank_mids.helpers.future module
- class dank_mids.helpers.future.DebuggableFuture
Bases:
Future
- __init__(owner, loop)
- Parameters:
owner (_RequestBase)
loop (AbstractEventLoop)
- Return type:
None
- __iter__()
Implement iter(self).
- add_done_callback()
Add a callback to be run when the future becomes done.
The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon.
- cancel(msg=None)
Cancel the future and schedule callbacks.
If the future is already done or cancelled, return False. Otherwise, change the future’s state to cancelled, schedule the callbacks and return True.
- cancelled()
Return True if the future was cancelled.
- done()
Return True if the future is done.
Done means either that a result / exception are available, or that the future was cancelled.
- exception()
Return the exception that was set on this future.
The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn’t done yet, raises InvalidStateError.
- get_loop()
Return the event loop the Future is bound to.
- remove_done_callback(fn, /)
Remove all instances of a callback from the “call when done” list.
Returns the number of callbacks removed.
- result()
Return the result this future represents.
If the future has been cancelled, raises CancelledError. If the future’s result isn’t yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised.
- set_exception(exc)
Mark the future done and set an exception.
If the future is already done when this method is called, raises InvalidStateError.
- Parameters:
exc (type | BaseException)
- Return type:
None
- set_result(value)
Mark the future done and set its result.
If the future is already done when this method is called, raises InvalidStateError.
- Parameters:
value (RPCResponse)
- Return type:
None
dank_mids.helpers.lru_cache module
- dank_mids.helpers.lru_cache.lru_cache_lite()
- dank_mids.helpers.lru_cache.lru_cache_lite_nonull()
Module contents
- class dank_mids.helpers.DebuggableFuture
Bases:
Future
- __init__(owner, loop)
- Parameters:
owner (_RequestBase)
loop (AbstractEventLoop)
- Return type:
None
- __iter__()
Implement iter(self).
- add_done_callback()
Add a callback to be run when the future becomes done.
The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon.
- cancel(msg=None)
Cancel the future and schedule callbacks.
If the future is already done or cancelled, return False. Otherwise, change the future’s state to cancelled, schedule the callbacks and return True.
- cancelled()
Return True if the future was cancelled.
- done()
Return True if the future is done.
Done means either that a result / exception are available, or that the future was cancelled.
- exception()
Return the exception that was set on this future.
The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn’t done yet, raises InvalidStateError.
- get_loop()
Return the event loop the Future is bound to.
- remove_done_callback(fn, /)
Remove all instances of a callback from the “call when done” list.
Returns the number of callbacks removed.
- result()
Return the result this future represents.
If the future has been cancelled, raises CancelledError. If the future’s result isn’t yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised.
- set_exception(exc)
Mark the future done and set an exception.
If the future is already done when this method is called, raises InvalidStateError.
- Parameters:
exc (type | BaseException)
- Return type:
None
- set_result(value)
Mark the future done and set its result.
If the future is already done when this method is called, raises InvalidStateError.
- Parameters:
value (RPCResponse)
- Return type:
None
- dank_mids.helpers.gatherish()
- dank_mids.helpers.lru_cache_lite()
- dank_mids.helpers.lru_cache_lite_nonull()
- dank_mids.helpers.setup_dank_w3(async_w3)
Sets up a DankWeb3 instance from a given Web3 instance.
- Parameters:
async_w3 (Web3) – The Web3 instance to be wrapped.
- Returns:
A new DankWeb3 instance with Dank Middleware injected.
- Return type:
DankWeb3
- dank_mids.helpers.setup_dank_w3_from_sync(sync_w3)
Sets up a DankWeb3 instance from a given synchronous Web3 instance.
- Parameters:
sync_w3 (Web3) – The synchronous Web3 instance to be wrapped.
- Returns:
A new DankWeb3 instance with Dank Middleware injected, supporting batched asynchronous operations.
- Return type:
DankWeb3