Skip to content

Commit

Permalink
fix: resource does not properly close context managers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sune Debel authored Feb 3, 2021
1 parent 1623ff7 commit c3809fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pfun/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async def __aenter__(self):
async def __aexit__(self, *args, **kwargs):
resource = self.resource
object.__setattr__(self, 'resource', None)
if isinstance(self.resource, Right):
if isinstance(resource, Right):
return await resource.get.__aexit__(*args, **kwargs)


Expand Down
1 change: 1 addition & 0 deletions tests/test_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def test_get(self):
effect = resource.get()
assert effect.run(None) == mock_resource
mock_resource.__aenter__.assert_called_once()
mock_resource.__aexit__.assert_called_once()
assert resource.resource is None

def test_resources_are_unique(self):
Expand Down

0 comments on commit c3809fb

Please sign in to comment.