[Pharo-project] NonInteractiveTranscript holds reference to closed files
Select the three statements at once and evaluate them: NonInteractiveTranscript stdout install. Smalltalk snapshot: true andQuit: true. Transcript show: 'hello'. Then reopen your image... Bump! stdout is closed. Of course, It got closed when the image quitted, but the NonInteractiveTranscript kept the reference to an invalid fileStream... What should be a good solution for this? - catch the error on the transcript and if closed reopen the file? - subscribe to the shutdown list to void the reference? - adding a SystemShutdown announcement and subscribe to it? The third one seems... cleaner. But I'm not sure. Guille
Hi Guillermomo, On 27 Jun 2012, at 14:50, Guillermo Polito wrote:
Select the three statements at once and evaluate them:
NonInteractiveTranscript stdout install. Smalltalk snapshot: true andQuit: true. Transcript show: 'hello'.
Then reopen your image... Bump! stdout is closed.
Of course, It got closed when the image quitted, but the NonInteractiveTranscript kept the reference to an invalid fileStream...
What should be a good solution for this? - catch the error on the transcript and if closed reopen the file? - subscribe to the shutdown list to void the reference? - adding a SystemShutdown announcement and subscribe to it?
The third one seems... cleaner. But I'm not sure.
Guille
Yes, the stream inside NonInteractiveTranscript should be set to nil whenever an image save closes stdout, so either option 2 or 3. Mind you that the current close/open/reopen logic is not good enough: stream is never set to nil . I think that open and reopen should be removed, and that close should become close self critical: [ stream ifNotNil: [ self isStdout ifTrue: [ stream flush ] ifFalse: [ stream close ]. stream := nil ] ] And then you should add some shutdown hook. Sven
I am hitting this too now ;-) So what will we do ? The simplest solution seems option 2 with the improved #close behavior. I will make a slice tomorrow. On 27 Jun 2012, at 15:14, Sven Van Caekenberghe wrote:
Hi Guillermomo,
On 27 Jun 2012, at 14:50, Guillermo Polito wrote:
Select the three statements at once and evaluate them:
NonInteractiveTranscript stdout install. Smalltalk snapshot: true andQuit: true. Transcript show: 'hello'.
Then reopen your image... Bump! stdout is closed.
Of course, It got closed when the image quitted, but the NonInteractiveTranscript kept the reference to an invalid fileStream...
What should be a good solution for this? - catch the error on the transcript and if closed reopen the file? - subscribe to the shutdown list to void the reference? - adding a SystemShutdown announcement and subscribe to it?
The third one seems... cleaner. But I'm not sure.
Guille
Yes, the stream inside NonInteractiveTranscript should be set to nil whenever an image save closes stdout, so either option 2 or 3.
Mind you that the current close/open/reopen logic is not good enough: stream is never set to nil .
I think that open and reopen should be removed, and that close should become
close self critical: [ stream ifNotNil: [ self isStdout ifTrue: [ stream flush ] ifFalse: [ stream close ]. stream := nil ] ]
And then you should add some shutdown hook.
Sven
participants (2)
-
Guillermo Polito -
Sven Van Caekenberghe