Fix race condition in group.set (#18796)
This commit is contained in:
1 parent
fa9a200e3c
commit
7fa5f07218
2 files changed
+29
-1
No files matched your search
@@ -207,6 +207,13 @@ async def async_setup(hass, config):
|
||||
DOMAIN, SERVICE_RELOAD, reload_service_handler,
|
||||
schema=RELOAD_SERVICE_SCHEMA)
|
||||
|
||||
service_lock = asyncio.Lock()
|
||||
|
||||
async def locked_service_handler(service):
|
||||
"""Handle a service with an async lock."""
|
||||
async with service_lock:
|
||||
await groups_service_handler(service)
|
||||
|
||||
async def groups_service_handler(service):
|
||||
"""Handle dynamic group service functions."""
|
||||
object_id = service.data[ATTR_OBJECT_ID]
|
||||
@@ -284,7 +291,7 @@ async def async_setup(hass, config):
|
||||
await component.async_remove_entity(entity_id)
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_SET, groups_service_handler,
|
||||
DOMAIN, SERVICE_SET, locked_service_handler,
|
||||
schema=SET_SERVICE_SCHEMA)
|
||||
|
||||
hass.services.async_register(
|
||||
|
||||
Reference in new issue
Block a user