Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Conversation

@pwoolvett
Copy link
Contributor

@pwoolvett pwoolvett commented May 6, 2022

fixes #22
fixes #42


async def connect(self) -> None:
self._conn = await asyncpg.connect(self._url)
self._event = asyncio.Event()

Choose a reason for hiding this comment

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

Wouldn't it be simpler to use asyncio.Lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simpler, and better.

This fix adds an asyncio.Lock to avoid
`asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress`

fixes encode#22
@skyforeverRivian
Copy link

recently, my project facing some issue

File "*****/python3.9/site-packages/broadcaster/_base.py", line 62, in connect
    await self._backend.connect()
AttributeError: 'Broadcast' object has no attribute '_backend'

seems like this PR doesn't resolve slow backend initialization issue

@logankaser
Copy link

Why didn't this merge? If I fixed its conflicts, would it be accepted?

@alex-oleshkevich
Copy link
Contributor

@logankaser let's have it split into multiple PRs. I believe there is only one issue related to postgres left.

@logankaser
Copy link

I think there are two:

  1. This issue, the connection is not guarded by a lock, so it can be accessed while the connection is active.
    Can be with using a asyncio lock like this PR did, or better something like https://github.com/permitio/broadcaster/blob/master/broadcaster/_backends/postgres.py
  2. Postgres backend: handle connection loss #66 Postgres backend cannot gracefully handle connection loss

@alex-oleshkevich
Copy link
Contributor

#66 looks like a good merge candidate, but I did not test it yet.

@Trinkes
Copy link

Trinkes commented Aug 17, 2024

Any update on this issue?
I'm particularly interested in #22 fix 🙏 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Postgres: Cannot perform operation: another operation is in progress Kafka test hangs on "await subscriber.get()"

6 participants