Thread vs Task
Hey 👋 ,
I would like to implement chat using CrewAI and I am wondering what is the difference between use_thread and use_task.
I haven't found a clear comparison in the documentation, so I'm asking if anyone would be able to explain to me the differences or give me some example use cases?
For any answer I will be grateful 🫂
4 Replies
What do you think of adding this to the docs on use_thread, would this clarify it for you, or do you still miss something:
Future deprecation
Note that
use_task
is an alternative to use_thread
that will most likely
replace use_thread
in the future. Compared to use_thread
, use_task
has no intrusive cancel, which turned out to be a too large of
a performance overhead to be useful. Also, use_task
can run async functions, which is not possible with use_thread
.I think it would help. From the perspective of a person who doesn't necessarily come from a python background (I'm guessing there are quite a few such users):
I see two functions that look quite similar at first glance +
use_task
has the ability to set a prefer_threaded
parameter, which further adds to the misunderstanding.
In this case, I would most appreciate a comparison of the two functions with an example that would illustrate a use case where use_task
would work better instead of use_thread
and vice versa. Additionally, information about potential substitution would suggest to me to use use_task
.maartenbreddels
<:pull_open:882464248721182842> [widgetti/solara] docs: clarify the role between use_task and use_thread
No description provided.
Created