mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Limit worker pool to 10 threads (#3560)
* Limit worker pool to 10 threads * Comment evdev in requirements * Allow skipping RFXtrx tests locally * Fix worker pool size tests * lol whut
This commit is contained in:
parent
a084232cf5
commit
4b8bc90d16
@ -118,7 +118,8 @@ def _setup_component(hass: core.HomeAssistant, domain: str, config) -> bool:
|
|||||||
|
|
||||||
# Assumption: if a component does not depend on groups
|
# Assumption: if a component does not depend on groups
|
||||||
# it communicates with devices
|
# it communicates with devices
|
||||||
if 'group' not in getattr(component, 'DEPENDENCIES', []):
|
if 'group' not in getattr(component, 'DEPENDENCIES', []) and \
|
||||||
|
hass.pool.worker_count <= 10:
|
||||||
hass.pool.add_worker()
|
hass.pool.add_worker()
|
||||||
|
|
||||||
hass.bus.fire(
|
hass.bus.fire(
|
||||||
|
@ -6,7 +6,6 @@ https://home-assistant.io/components/switch.rfxtrx/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
import homeassistant.components.rfxtrx as rfxtrx
|
import homeassistant.components.rfxtrx as rfxtrx
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ eliqonline==1.0.12
|
|||||||
enocean==0.31
|
enocean==0.31
|
||||||
|
|
||||||
# homeassistant.components.keyboard_remote
|
# homeassistant.components.keyboard_remote
|
||||||
evdev==0.6.1
|
# evdev==0.6.1
|
||||||
|
|
||||||
# homeassistant.components.climate.honeywell
|
# homeassistant.components.climate.honeywell
|
||||||
# homeassistant.components.thermostat.honeywell
|
# homeassistant.components.thermostat.honeywell
|
||||||
|
@ -16,6 +16,7 @@ COMMENT_REQUIREMENTS = (
|
|||||||
'python-lirc',
|
'python-lirc',
|
||||||
'gattlib',
|
'gattlib',
|
||||||
'pyuserinput',
|
'pyuserinput',
|
||||||
|
'evdev',
|
||||||
)
|
)
|
||||||
|
|
||||||
IGNORE_PACKAGES = (
|
IGNORE_PACKAGES = (
|
||||||
|
@ -38,6 +38,7 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
return {'model': 'UVC'}
|
return {'model': 'UVC'}
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
hass.config.components = ['http']
|
hass.config.components = ['http']
|
||||||
mock_remote.return_value.index.return_value = fake_cameras
|
mock_remote.return_value.index.return_value = fake_cameras
|
||||||
mock_remote.return_value.get_camera.side_effect = fake_get_camera
|
mock_remote.return_value.get_camera.side_effect = fake_get_camera
|
||||||
@ -65,6 +66,7 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
{'uuid': 'two', 'name': 'Back', 'id': 'id2'},
|
{'uuid': 'two', 'name': 'Back', 'id': 'id2'},
|
||||||
]
|
]
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
hass.config.components = ['http']
|
hass.config.components = ['http']
|
||||||
mock_remote.return_value.index.return_value = fake_cameras
|
mock_remote.return_value.index.return_value = fake_cameras
|
||||||
mock_remote.return_value.get_camera.return_value = {'model': 'UVC'}
|
mock_remote.return_value.get_camera.return_value = {'model': 'UVC'}
|
||||||
@ -92,6 +94,7 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
{'uuid': 'two', 'name': 'Back', 'id': 'id2'},
|
{'uuid': 'two', 'name': 'Back', 'id': 'id2'},
|
||||||
]
|
]
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
hass.config.components = ['http']
|
hass.config.components = ['http']
|
||||||
mock_remote.return_value.index.return_value = fake_cameras
|
mock_remote.return_value.index.return_value = fake_cameras
|
||||||
mock_remote.return_value.get_camera.return_value = {'model': 'UVC'}
|
mock_remote.return_value.get_camera.return_value = {'model': 'UVC'}
|
||||||
@ -109,6 +112,7 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
def test_setup_incomplete_config(self, mock_uvc):
|
def test_setup_incomplete_config(self, mock_uvc):
|
||||||
""""Test the setup with incomplete configuration."""
|
""""Test the setup with incomplete configuration."""
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
hass.config.components = ['http']
|
hass.config.components = ['http']
|
||||||
|
|
||||||
assert setup_component(
|
assert setup_component(
|
||||||
@ -133,6 +137,7 @@ class TestUVCSetup(unittest.TestCase):
|
|||||||
'key': 'secret',
|
'key': 'secret',
|
||||||
}
|
}
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
hass.config.components = ['http']
|
hass.config.components = ['http']
|
||||||
|
|
||||||
for error in errors:
|
for error in errors:
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
"""The tests for the Rfxtrx cover platform."""
|
"""The tests for the Rfxtrx cover platform."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'")
|
||||||
class TestCoverRfxtrx(unittest.TestCase):
|
class TestCoverRfxtrx(unittest.TestCase):
|
||||||
"""Test the Rfxtrx cover platform."""
|
"""Test the Rfxtrx cover platform."""
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
"""The tests for the Rfxtrx light platform."""
|
"""The tests for the Rfxtrx light platform."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'")
|
||||||
class TestLightRfxtrx(unittest.TestCase):
|
class TestLightRfxtrx(unittest.TestCase):
|
||||||
"""Test the Rfxtrx light platform."""
|
"""Test the Rfxtrx light platform."""
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
"""The tests for the Rfxtrx roller shutter platform."""
|
"""The tests for the Rfxtrx roller shutter platform."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'")
|
||||||
class TestRollershutterRfxtrx(unittest.TestCase):
|
class TestRollershutterRfxtrx(unittest.TestCase):
|
||||||
"""Test the Rfxtrx roller shutter platform."""
|
"""Test the Rfxtrx roller shutter platform."""
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""The tests for the Rfxtrx sensor platform."""
|
"""The tests for the Rfxtrx sensor platform."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
@ -8,6 +10,7 @@ from homeassistant.const import TEMP_CELSIUS
|
|||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'")
|
||||||
class TestSensorRfxtrx(unittest.TestCase):
|
class TestSensorRfxtrx(unittest.TestCase):
|
||||||
"""Test the Rfxtrx sensor platform."""
|
"""Test the Rfxtrx sensor platform."""
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
"""The tests for the Rfxtrx switch platform."""
|
"""The tests for the Rfxtrx switch platform."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'")
|
||||||
class TestSwitchRfxtrx(unittest.TestCase):
|
class TestSwitchRfxtrx(unittest.TestCase):
|
||||||
"""Test the Rfxtrx switch platform."""
|
"""Test the Rfxtrx switch platform."""
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class TestInfluxDB(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Setup things to be run when tests are started."""
|
"""Setup things to be run when tests are started."""
|
||||||
self.hass = mock.MagicMock()
|
self.hass = mock.MagicMock()
|
||||||
|
self.hass.pool.worker_count = 2
|
||||||
self.handler_method = None
|
self.handler_method = None
|
||||||
|
|
||||||
def test_setup_config_full(self, mock_client):
|
def test_setup_config_full(self, mock_client):
|
||||||
|
@ -19,6 +19,7 @@ class TestLogentries(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, logentries.DOMAIN, config))
|
self.assertTrue(setup_component(hass, logentries.DOMAIN, config))
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
@ -32,6 +33,7 @@ class TestLogentries(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, logentries.DOMAIN, config))
|
self.assertTrue(setup_component(hass, logentries.DOMAIN, config))
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
@ -48,6 +50,7 @@ class TestLogentries(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.hass = mock.MagicMock()
|
self.hass = mock.MagicMock()
|
||||||
|
self.hass.pool.worker_count = 2
|
||||||
setup_component(self.hass, logentries.DOMAIN, config)
|
setup_component(self.hass, logentries.DOMAIN, config)
|
||||||
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
|
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ class TestUpdater(unittest.TestCase):
|
|||||||
|
|
||||||
def test_logger_setup(self):
|
def test_logger_setup(self):
|
||||||
"""Use logger to create a logging filter."""
|
"""Use logger to create a logging filter."""
|
||||||
setup_component(MagicMock(), logger.DOMAIN, self.log_config)
|
hass = MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
|
setup_component(hass, logger.DOMAIN, self.log_config)
|
||||||
|
|
||||||
self.assertTrue(len(logging.root.handlers) > 0)
|
self.assertTrue(len(logging.root.handlers) > 0)
|
||||||
handler = logging.root.handlers[-1]
|
handler = logging.root.handlers[-1]
|
||||||
@ -37,7 +39,9 @@ class TestUpdater(unittest.TestCase):
|
|||||||
|
|
||||||
def test_logger_test_filters(self):
|
def test_logger_test_filters(self):
|
||||||
"""Test resulting filter operation."""
|
"""Test resulting filter operation."""
|
||||||
setup_component(MagicMock(), logger.DOMAIN, self.log_config)
|
hass = MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
|
setup_component(hass, logger.DOMAIN, self.log_config)
|
||||||
|
|
||||||
log_filter = logging.root.handlers[-1].filters[0]
|
log_filter = logging.root.handlers[-1].filters[0]
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class TestSplunk(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, splunk.DOMAIN, config))
|
self.assertTrue(setup_component(hass, splunk.DOMAIN, config))
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
@ -37,6 +38,7 @@ class TestSplunk(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, splunk.DOMAIN, config))
|
self.assertTrue(setup_component(hass, splunk.DOMAIN, config))
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
@ -56,6 +58,7 @@ class TestSplunk(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.hass = mock.MagicMock()
|
self.hass = mock.MagicMock()
|
||||||
|
self.hass.pool.worker_count = 2
|
||||||
setup_component(self.hass, splunk.DOMAIN, config)
|
setup_component(self.hass, splunk.DOMAIN, config)
|
||||||
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
|
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ class TestStatsd(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, statsd.DOMAIN, config))
|
self.assertTrue(setup_component(hass, statsd.DOMAIN, config))
|
||||||
mock_connection.assert_called_once_with(
|
mock_connection.assert_called_once_with(
|
||||||
host='host',
|
host='host',
|
||||||
@ -61,6 +62,7 @@ class TestStatsd(unittest.TestCase):
|
|||||||
config['statsd'][statsd.CONF_PREFIX] = statsd.DEFAULT_PREFIX
|
config['statsd'][statsd.CONF_PREFIX] = statsd.DEFAULT_PREFIX
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
self.assertTrue(setup_component(hass, statsd.DOMAIN, config))
|
self.assertTrue(setup_component(hass, statsd.DOMAIN, config))
|
||||||
mock_connection.assert_called_once_with(
|
mock_connection.assert_called_once_with(
|
||||||
host='host',
|
host='host',
|
||||||
@ -80,6 +82,7 @@ class TestStatsd(unittest.TestCase):
|
|||||||
config['statsd'][statsd.CONF_RATE] = statsd.DEFAULT_RATE
|
config['statsd'][statsd.CONF_RATE] = statsd.DEFAULT_RATE
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
setup_component(hass, statsd.DOMAIN, config)
|
setup_component(hass, statsd.DOMAIN, config)
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
handler_method = hass.bus.listen.call_args_list[0][0][1]
|
handler_method = hass.bus.listen.call_args_list[0][0][1]
|
||||||
@ -121,6 +124,7 @@ class TestStatsd(unittest.TestCase):
|
|||||||
config['statsd'][statsd.CONF_RATE] = statsd.DEFAULT_RATE
|
config['statsd'][statsd.CONF_RATE] = statsd.DEFAULT_RATE
|
||||||
|
|
||||||
hass = mock.MagicMock()
|
hass = mock.MagicMock()
|
||||||
|
hass.pool.worker_count = 2
|
||||||
setup_component(hass, statsd.DOMAIN, config)
|
setup_component(hass, statsd.DOMAIN, config)
|
||||||
self.assertTrue(hass.bus.listen.called)
|
self.assertTrue(hass.bus.listen.called)
|
||||||
handler_method = hass.bus.listen.call_args_list[0][0][1]
|
handler_method = hass.bus.listen.call_args_list[0][0][1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user