in reply to Re: Hang on STDOUT
in thread Hang on STDOUT
Unlikely. However it is possible that two different threads might try to write to STDERR.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Hang on STDOUT
by BrowserUk (Patriarch) on Jul 02, 2015 at 14:09 UTC | |
it is possible that two different threads might try to write to STDERR If you're not using locking on global handles that can be used from multiple threads, you should be. Ie.
Or better:
You might also consider using just one semaphore for both stdout and stderr if the are habitually directed to the same place. Not saying this will fix your (exceptionally vaguely described) problem; but at least it will be one possibility removed from consideration. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
| [reply] [d/l] [select] |
by marioroy (Prior) on Dec 28, 2020 at 22:58 UTC | |
Greetings, I tested BrowserUk's example using a semaphore lock and sometimes fail on macOS; even with auto flush enabled. I thought that this would work but is not consistent on macOS that is. Two of the lines were combined into one super long line. Be sure to direct the output to STDERR when testing; i.e. 2>output.txt on UNIX. The output file is 3.4 GiB.
MCE::Shared was released some time after BrowserUk's response. Using MCE::Shared, auto flush is enabled behind the scene during construction. This example runs consistently without garbled output.
Does your Perl binary lack threads support? If yes, MCE::Shared also works with child processes. Here is the same thing using MCE::Hobo.
md5sum and word count:
Regards, Mario | [reply] [d/l] [select] |
by DanEllison (Scribe) on Jul 02, 2015 at 16:47 UTC | |
True, and easy enough. I'll try to eliminate any possibility of a collision. your (exceptionally vaguely described) problem Yes, I know. During 8 hours of processing, it may hang once or twice, and seemingly different locations. If I could describe it any better, it wouldn't be a problem. | [reply] |
by BrowserUk (Patriarch) on Jul 02, 2015 at 17:25 UTC | |
If I could describe it any better, it wouldn't be a problem. I appreciate that it can be hard to track these sort of things down. One thing I would try is replace the printf with sprintf to a variable, and the print the variable and put another trace between the two. Ie. Try and eliminate whether it is the formatting or the IO that's hanging up. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
| [reply] |