[issue36717] Allow retrieval of return value from the target of a threading.Thread

2021-09-26 Thread STINNER Victor


STINNER Victor  added the comment:

Storing the result of Thread.run() can keep Python objects alive longer than 
expected and it may require a lock on it. I don't think that the additional 
complexity is worth it. I suggest to reorganize your code to pass the result 
differently to the caller thread. You can use a queue, a variable, whatever 
works.

--
nosy: +vstinner
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36717] Allow retrieval of return value from the target of a threading.Thread

2019-05-06 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +remi.lapeyre

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36717] Allow retrieval of return value from the target of a threading.Thread

2019-04-24 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36717] Allow retrieval of return value from the target of a threading.Thread

2019-04-24 Thread Joel Croteau


New submission from Joel Croteau :

It would be nice if, after a threading.Thread has completed its run, it were 
possible to retrieve the return value of the target function. You can do this 
currently by setting a variable from your target or by subclassing Thread, but 
this should really be built in. My suggested changes:
* Add an attribute to Thread, retval, initially set to None, that contains the 
return value of the target after a successful completion.
* Thread.run() should set self.retval to the return value of the target upon 
completion, and also return this value.
* Thread.join() should return self.retval after a successful completion.

If you're not using Thread.join(), you can directly access Thread.retval to get 
the return result after a successful run. Thread.run() and Thread.join() both 
return None in all cases now, so I think a change in their return value would 
have minimal if any effect on existing code.

--
components: Library (Lib)
messages: 340815
nosy: Joel Croteau2
priority: normal
severity: normal
status: open
title: Allow retrieval of return value from the target of a threading.Thread
type: enhancement
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com