-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Postgres: Cannot perform operation: another operation is in progress #22
Comments
@kellen did you find a solution for this? |
@AntonOfTheWoods no, I added redis as the backend instead. |
pwoolvett
added a commit
to pwoolvett/broadcaster
that referenced
this issue
May 6, 2022
This fix adds a lock (asyncio.Event based) to avoid `asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress` fixes encode#22
Open
pwoolvett
added a commit
to pwoolvett/broadcaster
that referenced
this issue
May 13, 2022
This fix adds an asyncio.Lock to avoid `asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress` fixes encode#22
pwoolvett
added a commit
to pwoolvett/broadcaster
that referenced
this issue
May 13, 2022
This fix adds an asyncio.Lock to avoid `asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress` fixes encode#22
@AntonOfTheWoods @app.websocket("/viewers", name="viewers_ws")
async def events_ws(websocket: WebSocket):
await websocket.accept()
await run_until_first_complete(
(viewers_ws_receiver, {"websocket": websocket}),
(viewers_ws_sender, {"websocket": websocket}),
)
my_lock = threading.Lock()
async def viewers_ws_receiver(websocket: WebSocket):
await asyncio.sleep(0.01) # <-- pass error
async for message in websocket.iter_text():
await broadcast.publish(channel="viewers", message=message)
async def viewers_ws_sender(websocket: WebSocket):
async with broadcast.subscribe(channel="viewers") as subscriber:
async for event in subscriber:
counter = 0
with my_lock:
# do something with event.message
counter = ...
await websocket.send_json({"viewers": counter}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using broadcaster w/ fastapi and seeing an exception when using broadcaster via websockets.
Relevant parts:
Full trace:
Doing this via code that looks something like this, where I think the lock is just slowing things down and exposing the contention.
Update: Refactored down to a single websocket and not using a lock for anything and saw this exception again. 🤷
The text was updated successfully, but these errors were encountered: