Files
textual/questions/worker-thread-error.question.md
Will McGugan 879c985296 Rich log (#3046)
* log

* tests

* snapshot tests

* change to richlog

* keep raw lines

* disable highlighting by default

* simplify

* superfluous test

* optimization

* update cell length

* add refresh

* write method

* version bump

* doc fix link

* makes lines private

* docstring

* relax dev dependancy

* remove superfluous code [skip ci]

* added FAQ [skipci]

* fix code in faq [skipci]

* fix typo

* max lines fix
2023-08-03 10:11:17 +01:00

667 B

title, alt_titles
title alt_titles
How do I fix WorkerDeclarationError?
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:

@work(thread=True)
def run_in_background():
    ...

If you don't want a threaded worker, you should make your work function async:

@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.