Skip to content

Commit 3f80d90

Browse files
Merge pull request #232 from ezmsg-org/fix/deprecate-ez-thread
Deprecate `@ez.thread`
2 parents 4c7a209 + cd30af9 commit 3f80d90

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

docs/source/reference/API/functiondecorators.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ These function decorators can be added to member functions of an ezmsg ``Unit``
1111

1212
.. autodecorator:: ezmsg.core.thread
1313

14+
.. note::
15+
``@ez.thread`` is deprecated and will be removed in a future release.
16+
Prefer explicit background work via ``loop.run_in_executor(...)``.
17+
1418
.. autodecorator:: ezmsg.core.task
1519

1620
.. autodecorator:: ezmsg.core.process

src/ezmsg/core/unit.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,22 @@ def thread(func: Callable):
274274
Thread functions run concurrently with the main message processing and can be used
275275
for background tasks, monitoring, or other concurrent operations.
276276
277+
.. deprecated::
278+
``@thread`` is deprecated and will be removed in a future release.
279+
Prefer explicit background work using ``loop.run_in_executor(...)`` or
280+
explicit task management in ``initialize()``/``shutdown()``.
281+
277282
:param func: The function to run as a background thread
278283
:type func: collections.abc.Callable
279284
:return: The decorated function
280285
:rtype: collections.abc.Callable
281286
"""
287+
warnings.warn(
288+
"`@ez.thread` is deprecated and will be removed in a future release. "
289+
"Prefer explicit background work via `loop.run_in_executor(...)`.",
290+
DeprecationWarning,
291+
stacklevel=2,
292+
)
282293
setattr(func, THREAD_ATTR, True)
283294
return func
284295

0 commit comments

Comments
 (0)