Skip to content
Advertisement

Return value in a python thread

I am new in Python and I want to get the value from a thread. I call the function logica in a thread and that function returns a value I want to know how can I get the value songs because I will use it later in an iter. Comand is a string. I am using the library threading

JavaScript

Advertisement

Answer

In your setup that is a little difficult because you have no reference to the thread. So

  1. After starting it when is the thread ready?
  2. Where to are the results returned?

1 can be fixed by assigning the thread to a variable. 2 in your case you can provide an external list for the results and pass it as argument.

JavaScript

Result

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement