Skip to content

Commit

Permalink
[CHIA-1359] Fix action scope callbacks across multiple .use calls (#…
Browse files Browse the repository at this point in the history
…18572)

Fix action scope callbacks across multiple `.use` calls
  • Loading branch information
Quexington authored Sep 12, 2024
1 parent 810f0bf commit ab21776
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions chia/_tests/util/test_action_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ async def callback(interface: StateInterface[TestSideEffects]) -> None:

interface.set_callback(callback)

async with action_scope.use():
pass # Testing that callback stays put even through another .use()

assert action_scope.side_effects.buf == b"bar"


Expand Down
2 changes: 1 addition & 1 deletion chia/util/action_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def new_scope(
async def use(self, _callbacks_allowed: bool = True) -> AsyncIterator[StateInterface[_T_SideEffects]]:
async with self._resource_manager.use():
side_effects = await self._resource_manager.get_resource(self._side_effects_format)
interface = StateInterface(side_effects, _callbacks_allowed)
interface = StateInterface(side_effects, _callbacks_allowed, self._callback)

yield interface

Expand Down

0 comments on commit ab21776

Please sign in to comment.