This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add support for thread function result storage
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: aptshansen, mykhal, r.david.murray, tosi-in
Priority: low Keywords: patch

Created on 2006-01-02 20:23 by tosi-in, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
threading.py.diff tosi-in, 2006-01-02 20:24 threading.py-2.4.2 patch
test.py tosi-in, 2006-01-02 20:26 small script for testing the new feature
Messages (5)
msg49248 - (view) Author: Tobias Simon (tosi-in) Date: 2006-01-02 20:23
Here comes a little add-on for python's threading library:
It provides a way of reading a thread function's result
after the termination.
after a thread, which was created using safe_result =
True as a constructor parameter,
the thread object will gain the function result as a
parameter, called "result".
If the thread function did not return till the result
attribute access, an AttributeError is raised.
msg49249 - (view) Author: Stephen Hansen (aptshansen) Date: 2007-03-16 06:32
I'm not sure this is generally useful. It might be sometimes, but it seems to me that it would often be insufficient for many tasks. There are many different ways that someone could get a result back from a thread; a Queue, a callback, being all sexy with pydispatcher, or many other ways. Since there are so many different approaches to this job, each with strengths and weaknesses in a specific situation, and none that are 'generally' useful over a broad range of activities, I don't think adding this one particular method to the core is a good idea. It's an ASPN Python Cookbook recipe for a threading.Thread subclass.

E.g., I'm recommending this patch be rejected.

P.S. Should that make me feel like a bad person? -.-

msg96212 - (view) Author: Michal Božoň (mykhal) Date: 2009-12-10 18:21
why would we throw the thread function result out of the window?
because there is a another way, to do it? there are always many ways,
how to do it, so why would we want to do it very difficult way?

i think that not having the result stored somewhere is a bug and i'm
voting for fixing it
msg96214 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-12-10 18:59
I agree with Stephen.  You can implement this functionality easily
through the current API (subclassing), so there's no need to complicate
the existing API to handle this one communication method as a special case.

Furthermore, this particular use case is the tip of a small iceberg
usually called "Futures", which provides a much cleaner API for the use
case.  There has been a suggestion to include such a package in core,
though it will probably be some time before the library is mature enough
for a decision to be made.
msg96216 - (view) Author: Michal Božoň (mykhal) Date: 2009-12-10 21:10
i still do not agree, it will always feel somehow incomplete, being able 
to easily "threadize" the function:

>>> t = threading.Thread(target=func)

and then not being able to get the target function result (easily)
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42749
2009-12-10 21:10:51mykhalsetmessages: + msg96216
2009-12-10 18:59:08r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg96214

resolution: rejected
stage: patch review -> resolved
2009-12-10 18:21:04mykhalsetnosy: + mykhal
messages: + msg96212
2009-03-20 23:52:33ajaksu2setpriority: normal -> low
stage: patch review
type: enhancement
versions: + Python 3.1, Python 2.7, - Python 2.4
2006-01-02 20:23:11tosi-increate