[issue1626] threading.Thread objects are not reusable after join()

2007-12-14 Thread Sebastien BRACQUEMONT

Sebastien BRACQUEMONT added the comment:

Hi Amaury,

to me,Thread objects are meant to be abstract representation of a processing 
that will occur in a separate execution unit at thread start time.
Indeed, that's what the following text (from the link you provided tries to 
explain)

Once a thread object is created, its activity must be started by calling the 
thread’s start() method. This invokes the run() method in a separate thread of 
control.

So, the 'System Thread' is only created at start() call (which is a good 
implementation choice)
Moreover, the join() method (when completed) will wait for the System Thread to 
be disallocated.

However, the Thread object instance and the processing bound to it are still 
valid.

So in an object oriented point of view, (and syntactically too) , it should be 
valid to reuse the object (and so repeat the processing bound to it) as many 
times as necessary without the need to create a new instance as long as the 
Thread object state is not Alive.

What suprises me , is that the current implementation  of threading.Thread 
(apart from the __started flag behaviour) is compatible with that point of view 
and i see no limitations (apart that bug) preventing such a use of threads.

I think the threading API will provide better 'high-level' view if it didn't 
depend on low level considerations (as the dependency on the existence / 
reusability of the peer System Thread that will be used to effectively host the 
code execution)

Regards,

Sebastien

_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Added file: http://bugs.python.org/file8953/unnamed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1626
__html
head
style
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
/style
/head
body class='hmmessage'Hi Amaury,BR
nbsp;BR
to me,Thread objects are meant to be STRONGabstract/STRONG representation 
of a processing that will occur in a separate execution unit at thread start 
time.BR
Indeed, that's what the following text (from the link you provided tries to 
explain)BR
nbsp;BR
Once a thread object is created, its activity must be started by calling the 
thread’s TT class=xref docutils literalSPAN 
class=prestart()/SPAN/TT method. This invokes the TT class=xref docutils 
literalSPAN class=prerun()/SPAN/TT method in a separate thread of 
control.BR
nbsp;BR
So, the 'System Thread' is only creatednbsp;at start() call (which is a good 
implementation choice)BR
Moreover, the join() method (when completed) will wait for the System Thread to 
be disallocated.BR
nbsp;BR
However,nbsp;the Thread object instance and the processing bound to it are 
still valid.BR
nbsp;BR
So in an object oriented point of view, (and syntactically too)nbsp;, it 
should be valid to reuse the object (and so repeat the processing bound to it) 
as many times as necessary without the need to create a new instance as long as 
the Thread object state is not Alive.BR
nbsp;BR
What suprises me , is that the current implementationnbsp; of threading.Thread 
(apart from the __started flag behaviour) is compatible with that point of view 
and i see no limitations (apart that bug) preventing such a use of threads.BR
nbsp;BR
I think the threading API will provide better 'high-level' view if it didn't 
depend on low level considerations (as the dependency on the existence / 
reusability of the peer System Thread that will be used to effectively host the 
code execution)BR
nbsp;BR
Regards,BR
nbsp;BR
SebastienBRBRBRBR

HR id=stopSpelling
BR
gt; Subject: [issue1626] threading.Thread objects are not reusable after 
join()BRgt; To: [EMAIL PROTECTED]BRgt; From: [EMAIL PROTECTED]BRgt; 
Date: Fri, 14 Dec 2007 13:03:54 +BRgt; BRgt; BRgt; Amaury Forgeot 
d'Arc added the comment:BRgt; BRgt; From the documentation:BRgt; 
http://docs.python.org/dev/library/threading.html#threading.Thread.startBRgt;
 start() must be called at most once per thread object.BRgt; BRgt; I 
think this will not change: when a system thread terminates, youBRgt; cannot 
restart it; you have to create another thread.BRgt; The same argument 
applies to threading.Thread. It would be surprisingBRgt; that this object 
can represent multiple system threads.BRgt; BRgt; You should create and 
start different Threads each time.BRgt; BRgt; --BRgt; nosy: 
+amaury.forgeotdarcBRgt; resolution: -gt; invalidBRgt; status: open 
-gt; closedBRgt; BRgt; __BRgt; 
Tracker lt;[EMAIL PROTECTED]gt;BRgt; 
lt;http://bugs.python.org/issue1626gt;BRgt; 
__BRBRbr /hr /Express yourself 
instantly with MSN Messenger! a 
href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'MSN 
Messenger/a/body
/html

[issue1626] threading.Thread objects are not reusable after join()

2007-12-14 Thread Sebastien BRACQUEMONT

New submission from Sebastien BRACQUEMONT:

After a call to join() method on a Threading.thread object,there is no
way to successfully call start() method on it.

Indeed, the __started flag is not reset in the theading.Thread join()
method. 
Since the start() method checks for __started flag , this flag is always  
true after a first start, despite the thread was effectively stopped by
the join() call

Since it's perfectly legal to store a threading.Thread object in a
variable or an object member, i think the join() behaviour is odd
because it prevents instance reusability.

--
components: Library (Lib)
messages: 58622
nosy: dweeves
severity: normal
status: open
title: threading.Thread objects are not reusable after join()
type: behavior
versions: Python 2.4, Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1626
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1626] threading.Thread objects are not reusable after join()

2007-12-14 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

From the documentation:
http://docs.python.org/dev/library/threading.html#threading.Thread.start
start() must be called at most once per thread object.

I think this will not change: when a system thread terminates, you
cannot restart it; you have to create another thread.
The same argument applies to threading.Thread. It would be surprising
that this object can represent multiple system threads.

You should create and start different Threads each time.

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1626
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1626] threading.Thread objects are not reusable after join()

2007-12-14 Thread Martin v. Löwis

Martin v. Löwis added the comment:

I agree with Amaury. This all works exactly as it should work, and will
not change.

--
nosy: +loewis

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1626
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com