1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
---
title: "How do I fix WorkerDeclarationError?"
alt_titles:
- "Thread=True on Worker"
- "Problem with threaded workers"
---
Textual version 0.31.0 requires that you set `thread=True` on the `@work` decorator if you want to run a threaded worker.
If you want a threaded worker, you would declare it in the following way:
```python
@work(thread=True)
def run_in_background():
...
```
If you *don't* want a threaded worker, you should make your work function `async`:
```python
@work()
async def run_in_background():
...
```
This change was made because it was too easy to accidentally create a threaded worker, which may produce unexpected results.
|