Skip to content

Guard against improper use-after-release of connection resources #190

Closed
@elprans

Description

@elprans

The below seems to be a common (incorrect) pattern of use:

async with pool.acquire() as conn:
    # await conn.add_listener
    # await conn.prepare
    # etc

# Incorrect assumption that the listeners and prepared statements would continue to 
# work beyond the `conn` acquisition context

See #189 for an example issue.

To give a better hint that this is not a valid thing to do, we should check if conn has unclosed resources on it before releasing it. Possibly, behind a debug flag (either ASYNCPGDEBUG, or PYTHONASYNCIODEBUG, or both).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions