Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
be5714e3
Unverified
Commit
be5714e3
authored
1 year ago
by
J. Nick Koston
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Use slots for recorder tasks to reduce memory (#90387)
parent
6fbdcac3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/recorder/tasks.py
+30
-29
30 additions, 29 deletions
homeassistant/components/recorder/tasks.py
with
30 additions
and
29 deletions
homeassistant/components/recorder/tasks.py
+
30
−
29
View file @
be5714e3
...
...
@@ -26,7 +26,8 @@ if TYPE_CHECKING:
from
.core
import
Recorder
class
RecorderTask
(
abc
.
ABC
):
@dataclass
(
slots
=
True
)
class
RecorderTask
:
"""
ABC for recorder tasks.
"""
commit_before
=
True
...
...
@@ -36,7 +37,7 @@ class RecorderTask(abc.ABC):
"""
Handle the task.
"""
@dataclass
@dataclass
(
slots
=
True
)
class
ChangeStatisticsUnitTask
(
RecorderTask
):
"""
Object to store statistics_id and unit to convert unit of statistics.
"""
...
...
@@ -54,7 +55,7 @@ class ChangeStatisticsUnitTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
ClearStatisticsTask
(
RecorderTask
):
"""
Object to store statistics_ids which for which to remove statistics.
"""
...
...
@@ -65,7 +66,7 @@ class ClearStatisticsTask(RecorderTask):
statistics
.
clear_statistics
(
instance
,
self
.
statistic_ids
)
@dataclass
@dataclass
(
slots
=
True
)
class
UpdateStatisticsMetadataTask
(
RecorderTask
):
"""
Object to store statistics_id and unit for update of statistics metadata.
"""
...
...
@@ -83,7 +84,7 @@ class UpdateStatisticsMetadataTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
UpdateStatesMetadataTask
(
RecorderTask
):
"""
Task to update states metadata.
"""
...
...
@@ -99,7 +100,7 @@ class UpdateStatesMetadataTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
PurgeTask
(
RecorderTask
):
"""
Object to store information about purge task.
"""
...
...
@@ -125,7 +126,7 @@ class PurgeTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
PurgeEntitiesTask
(
RecorderTask
):
"""
Object to store entity information about purge task.
"""
...
...
@@ -140,7 +141,7 @@ class PurgeEntitiesTask(RecorderTask):
instance
.
queue_task
(
PurgeEntitiesTask
(
self
.
entity_filter
,
self
.
purge_before
))
@dataclass
@dataclass
(
slots
=
True
)
class
PerodicCleanupTask
(
RecorderTask
):
"""
An object to insert into the recorder to trigger cleanup tasks.
...
...
@@ -152,7 +153,7 @@ class PerodicCleanupTask(RecorderTask):
periodic_db_cleanups
(
instance
)
@dataclass
@dataclass
(
slots
=
True
)
class
StatisticsTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to run a statistics task.
"""
...
...
@@ -167,7 +168,7 @@ class StatisticsTask(RecorderTask):
instance
.
queue_task
(
StatisticsTask
(
self
.
start
,
self
.
fire_events
))
@dataclass
@dataclass
(
slots
=
True
)
class
CompileMissingStatisticsTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to run a compile missing statistics.
"""
...
...
@@ -179,7 +180,7 @@ class CompileMissingStatisticsTask(RecorderTask):
instance
.
queue_task
(
CompileMissingStatisticsTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
ImportStatisticsTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to run an import statistics task.
"""
...
...
@@ -199,7 +200,7 @@ class ImportStatisticsTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
AdjustStatisticsTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to run an adjust statistics task.
"""
...
...
@@ -229,7 +230,7 @@ class AdjustStatisticsTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
WaitTask
(
RecorderTask
):
"""
An object to insert into the recorder queue.
...
...
@@ -243,7 +244,7 @@ class WaitTask(RecorderTask):
instance
.
_queue_watch
.
set
()
# pylint: disable=[protected-access]
@dataclass
@dataclass
(
slots
=
True
)
class
DatabaseLockTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to prevent writes to the database.
"""
...
...
@@ -256,7 +257,7 @@ class DatabaseLockTask(RecorderTask):
instance
.
_lock_database
(
self
)
# pylint: disable=[protected-access]
@dataclass
@dataclass
(
slots
=
True
)
class
StopTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to stop the event handler.
"""
...
...
@@ -267,7 +268,7 @@ class StopTask(RecorderTask):
instance
.
stop_requested
=
True
@dataclass
@dataclass
(
slots
=
True
)
class
EventTask
(
RecorderTask
):
"""
An event to be processed.
"""
...
...
@@ -280,7 +281,7 @@ class EventTask(RecorderTask):
instance
.
_process_one_event
(
self
.
event
)
@dataclass
@dataclass
(
slots
=
True
)
class
KeepAliveTask
(
RecorderTask
):
"""
A keep alive to be sent.
"""
...
...
@@ -292,7 +293,7 @@ class KeepAliveTask(RecorderTask):
instance
.
_send_keep_alive
()
@dataclass
@dataclass
(
slots
=
True
)
class
CommitTask
(
RecorderTask
):
"""
Commit the event session.
"""
...
...
@@ -304,7 +305,7 @@ class CommitTask(RecorderTask):
instance
.
_commit_event_session_or_retry
()
@dataclass
@dataclass
(
slots
=
True
)
class
AddRecorderPlatformTask
(
RecorderTask
):
"""
Add a recorder platform.
"""
...
...
@@ -321,7 +322,7 @@ class AddRecorderPlatformTask(RecorderTask):
platforms
[
domain
]
=
platform
@dataclass
@dataclass
(
slots
=
True
)
class
SynchronizeTask
(
RecorderTask
):
"""
Ensure all pending data has been committed.
"""
...
...
@@ -335,7 +336,7 @@ class SynchronizeTask(RecorderTask):
instance
.
hass
.
loop
.
call_soon_threadsafe
(
self
.
event
.
set
)
@dataclass
@dataclass
(
slots
=
True
)
class
PostSchemaMigrationTask
(
RecorderTask
):
"""
Post migration task to update schema.
"""
...
...
@@ -349,7 +350,7 @@ class PostSchemaMigrationTask(RecorderTask):
)
@dataclass
@dataclass
(
slots
=
True
)
class
StatisticsTimestampMigrationCleanupTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to run a statistics migration cleanup task.
"""
...
...
@@ -360,7 +361,7 @@ class StatisticsTimestampMigrationCleanupTask(RecorderTask):
instance
.
queue_task
(
StatisticsTimestampMigrationCleanupTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
AdjustLRUSizeTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to adjust the LRU size.
"""
...
...
@@ -371,7 +372,7 @@ class AdjustLRUSizeTask(RecorderTask):
instance
.
_adjust_lru_size
()
# pylint: disable=[protected-access]
@dataclass
@dataclass
(
slots
=
True
)
class
StatesContextIDMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to migrate states context ids.
"""
...
...
@@ -386,7 +387,7 @@ class StatesContextIDMigrationTask(RecorderTask):
instance
.
queue_task
(
StatesContextIDMigrationTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
EventsContextIDMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to migrate events context ids.
"""
...
...
@@ -401,7 +402,7 @@ class EventsContextIDMigrationTask(RecorderTask):
instance
.
queue_task
(
EventsContextIDMigrationTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
EventTypeIDMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to migrate event type ids.
"""
...
...
@@ -417,7 +418,7 @@ class EventTypeIDMigrationTask(RecorderTask):
instance
.
queue_task
(
EventTypeIDMigrationTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
EntityIDMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to migrate entity_ids to StatesMeta.
"""
...
...
@@ -440,7 +441,7 @@ class EntityIDMigrationTask(RecorderTask):
instance
.
queue_task
(
EntityIDPostMigrationTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
EntityIDPostMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to cleanup after entity_ids migration.
"""
...
...
@@ -453,7 +454,7 @@ class EntityIDPostMigrationTask(RecorderTask):
instance
.
queue_task
(
EntityIDPostMigrationTask
())
@dataclass
@dataclass
(
slots
=
True
)
class
EventIdMigrationTask
(
RecorderTask
):
"""
An object to insert into the recorder queue to cleanup legacy event_ids in the states table.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment