Skip to content

Guard transaction methods against underlying connection release #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2017

Conversation

elprans
Copy link
Member

@elprans elprans commented Dec 3, 2017

Similarly to other connection-dependent objects, transaction methods
should not be called once the underlying connection has been released to
the pool.

Also, add a special handling for the case of asynchronous generator
finalization, in which case it's OK for Transaction.__aexit__() to be
called after Pool.release(), since we cannot control when the
finalization task would execute.

Fixes: #232.

@elprans elprans requested a review from 1st1 December 3, 2017 19:17
async with con.transaction():
for record in await con.fetch("SELECT 1"):
yield record
'''), globals(), locals_)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put iterate = locals_['iterate']here for readability

Similarly to other connection-dependent objects, transaction methods
should not be called once the underlying connection has been released to
the pool.

Also, add a special handling for the case of asynchronous generator
finalization, in which case it's OK for `Transaction.__aexit__()` to be
called _after_ `Pool.release()`, since we cannot control when the
finalization task would execute.

Fixes: #232.
@elprans elprans merged commit 59e2878 into master Dec 4, 2017
@elprans elprans deleted the bug-232 branch December 4, 2017 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants