async def test_set_service_race(hass):
    'Test race condition on setting service.'
    exception = False

    def async_loop_exception_handler(_, _2) -> None:
        'Handle all exception inside the core loop.'
        nonlocal exception
        exception = True
    hass.loop.set_exception_handler(async_loop_exception_handler)
    (await async_setup_component(hass, 'group', {}))
    component = EntityComponent(_LOGGER, DOMAIN, hass, group_name='yo')
    for i in range(2):
        hass.async_create_task(component.async_add_entities([MockEntity()]))
    (await hass.async_block_till_done())
    assert (not exception)
Test race condition on setting service.
async def test_set_service_race(hass):
    
    exception = False

    def async_loop_exception_handler(_, _2) -> None:
        'Handle all exception inside the core loop.'
        nonlocal exception
        exception = True
    hass.loop.set_exception_handler(async_loop_exception_handler)
    (await async_setup_component(hass, 'group', {}))
    component = EntityComponent(_LOGGER, DOMAIN, hass, group_name='yo')
    for i in range(2):
        hass.async_create_task(component.async_add_entities([MockEntity()]))
    (await hass.async_block_till_done())
    assert (not exception)