Tk Library Source Code

View Ticket
Login
Ticket UUID: 1844111
Title: snitfaq: $self destroy restrictions?
Type: RFE Version: None
Submitter: lars_h Created on: 2007-12-04 14:50:41
Subsystem: snit Assigned To: duquette
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-12-04 22:36:26
Resolution: Closed By: duquette
    Closed on: 2007-12-04 15:36:26
Description:
I've encountered a situation where it seems reasonable that 
a snit object initiates its own destruction: The object manages 
a channel and has an internal queue of messages to transmit. 
A soft shutdown of the communication would then means that 
the object owner stops calling it, but the object itself should 
hang around for as long as it takes to work through the queue, 
and only then destroy itself.

The catch is, I find nothing in the documentation about 
whether an object method is allowed to call $self destroy, 
although my gut feeling is that this might be asking for trouble. 

For now, I'll probably do is as
  after 0 [mymethod destroy]
instead, as I'm anyway running an event loop for the I/O, but 
if there is some more elementary solution, then it would be 
nice to learn about it.
User Comments: duquette added on 2007-12-04 22:36:26:
Logged In: YES 
user_id=372859
Originator: NO

Surprisingly, I don't have a test case for this--but in fact it's perfectly OK for an object to destroy itself.

Of course, it shouldn't try to do anything else after calling "$self destroy"....