i3-companion: simplify workspace duplicate renames

It seems we can initialize a lock without having a loop.
This commit is contained in:
Vincent Bernat 2021-08-01 18:02:34 +02:00
parent ce60feac8d
commit af3ba1dd57

View file

@ -347,12 +347,10 @@ async def new_workspace(i3, event):
@on(I3Event.WORKSPACE_INIT) @on(I3Event.WORKSPACE_INIT)
@static(lock=None) @static(lock=asyncio.Lock())
async def workspace_rename_duplicate(i3, event): async def workspace_rename_duplicate(i3, event):
"""Rename a workspace when initialized empty with a duplicate number.""" """Rename a workspace when initialized empty with a duplicate number."""
# This will not be needed once https://github.com/i3/i3/pull/4252 is released. # This will not be needed once https://github.com/i3/i3/pull/4252 is released.
if workspace_rename_duplicate.lock is None:
workspace_rename_duplicate.lock = asyncio.Lock()
async with workspace_rename_duplicate.lock: async with workspace_rename_duplicate.lock:
workspace = event.current workspace = event.current
workspaces = await i3.get_workspaces() workspaces = await i3.get_workspaces()