PrefectHQ
prefect
BlogDocsChangelog

Introduces a `Service` base class to cover loop and other services

#16898Merged
Comparing
base-services
(
c82b615
) with
main
(
02ee434
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.7 s1.7 s
bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
488.7 µs489.3 µs

Ignored

bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
2.8 ms2.8 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+33%
10.6 ms8 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-6%
5.2 ms5.5 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-2%
160.2 ms163.5 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+37%
157.5 ms114.8 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
110.8 ms110.9 ms

Commits

Click on a commit to change the comparison range
Base
main
02ee434
+0.18%
Introduces a `Service` base class to cover loop and other services We have two kinds of background services in the Prefect server: loop services that run a task periodically, and consumer services that react to messages on a message bus. I'd like to unify their treatment in a series of PRs with a few goals: - That we can run the consumer-style services along with the loop services in the background service process we start with `prefect server services` - That we can either opt-in or opt-out of running services in either the API or the background services process - That we can take the next step in refactoring services following the really cool discovery logic that @zzstoatzz added to the CLI: - A service knows which setting enables itself - There is one routine for finding the relevant services to start or stop for a given process - The starting and graceful stopping logic is consolidated to one place This will open our options when scaling out Prefect, like running multiple Prefect server replicas with either the in-process or out-of-process message brokers, and running multiple services replicas with different subsets of services. This PR is just the first step along that path, to introduce a base class and also to make sure that we're correctly running all the consumers in web-only processes (this is important for correctness with the in-memory broker--every process that could emit events will need to run these consumers when using the in-memory broker).
05daac8
8 months ago
by chrisguidry
+0.15%
Update loop_service.py
f2047b0
8 months ago
by chrisguidry
-0.35%
Merge branch 'main' into base-services
c82b615
8 months ago
by chrisguidry
© 2025 CodSpeed Technology
Home Terms Privacy Docs