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>
<BR>
to me,Thread objects are meant to be <STRONG>abstract</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>
<BR>
"Once a thread object is created, its activity must be started by calling the
threadâs <TT class="xref docutils literal"><SPAN
class=pre>start()</SPAN></TT> method. This invokes the <TT class="xref docutils
literal"><SPAN class=pre>run()</SPAN></TT> method in a separate thread of
control."<BR>
<BR>
So, the 'System Thread' is only created 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>
<BR>
However, the Thread object instance and the processing bound to it are
still valid.<BR>
<BR>
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.<BR>
<BR>
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.<BR>
<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>
<BR>
Regards,<BR>
<BR>
Sebastien<BR><BR><BR><BR>
<HR id=stopSpelling>
<BR>
> Subject: [issue1626] threading.Thread objects are not reusable after
join()<BR>> To: [EMAIL PROTECTED]<BR>> From: [EMAIL PROTECTED]<BR>>
Date: Fri, 14 Dec 2007 13:03:54 +0000<BR>> <BR>> <BR>> Amaury Forgeot
d'Arc added the comment:<BR>> <BR>> From the documentation:<BR>>
http://docs.python.org/dev/library/threading.html#threading.Thread.start<BR>>
start() must be called at most once per thread object.<BR>> <BR>> I
think this will not change: when a system thread terminates, you<BR>> cannot
restart it; you have to create another thread.<BR>> The same argument
applies to threading.Thread. It would be surprising<BR>> that this object
can represent multiple system threads.<BR>> <BR>> You should create and
start different Threads each time.<BR>> <BR>> ----------<BR>> nosy:
+amaury.forgeotdarc<BR>> resolution: -> invalid<BR>> status: open
-> closed<BR>> <BR>> __________________________________<BR>>
Tracker <[EMAIL PROTECTED]><BR>>
<http://bugs.python.org/issue1626><BR>>
__________________________________<BR><BR><br /><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>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com