Re: Program unexpectedly terminates by ColonelPanic (Friar) on Nov 19, 2012 at 08:31 UTC |
The code you have shown has a problem. You are assigning an array (1..100) as the value in a hash. You need an array reference for that (use brackets instead of parentheses). However, I doubt that is the real problem with your code--it was probably just a mistake when you created the simplified example.
Also, I tried your CORE::GLOBAL::exit override, and it didn't do anything--it only got worked if I explicitly called the exit() command, which your code does not.
I think your problem must be in the processing that you are not showing. It could be failing on the same one each time. Because you are processing in a random order, it would take varying amounts of time for that condition to be reached.
I suggest some good, old-fashioned debug print statements within your processing loop. Log the id of each record you are looking at, and record the success of each significant operation. That should help you to know where it fails.
When's the last time you used duct tape on a duct? --Larry Wall
| [reply] |
|
The code you have shown has a problem. You are assigning an array (1..100) as the value in a hash. You need an array reference
Yeah, yeah. That's obviously not working code and I was trimming down my real program to just show the basic structure.
Also, I tried your CORE::GLOBAL::exit override, and it didn't do anything--it only got worked if I explicitly called the exit() command, which your code does not.
I said in my OP I never directly call exit. But my unstated assumption is that one of the many CPAN modules I am using might be calling it.
I think your problem must be in the processing that you are not showing. It could be failing on the same one each time. Because you are processing in a random order, it would take varying amounts of time for that condition to be reached.
I'm intentionally not wrapping anything in eval, so if something in my code does fail, it should bomb out loudly. It never does.
I suggest some good, old-fashioned debug print statements within your processing loop. Log the id of each record you are looking at, and record the success of each significant operation. That should help you to know where it fails.
The print statement I have in the example already prints before the processing starts, so I see which record it stops at. It's never the same one. Plus, as I mentioned above, any error in my code would die loudly. But I'm not sure why the program can terminate with exit value of 0, yet the END block is never called.
So my assumption is that one of the CPAN modules is at fault, but whatever is the cause, I was hoping there was some module that would perform the necessary overrides and tell me what's calling exit.
| [reply] |
|
Thanks for the additional information. I didn't understand that you were trying to trap explicit calls to exit(). That makes sense, then.
Playing around more with the BEGIN block, I found that an exit() statement within another package was only overridden if the BEGIN block came before the package definition. Do you have this block before you include all of your modules?
Also, would Test::Trap be helpful?
When's the last time you used duct tape on a duct? --Larry Wall
| [reply] |
|
|
|
Re: Program unexpectedly terminates by tobyink (Prior) on Nov 19, 2012 at 09:29 UTC |
It would be helpful if the sample code you provided actually compiled (undefined $class, %args and &shuffle prevents compilation with strict subs/vars). Fixing those issues...
... the code seems to execute correctly here.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
| [reply] [d/l] [select] |
|
Thanks for the helpful contribution Mr. Pedantic :-P
| [reply] |
|
| [reply] |
Re: Program unexpectedly terminates by Anonymous Monk on Nov 19, 2012 at 12:40 UTC |
Anonymously speaking, the place to start is by adding print STDERR I am here now messages throughout the code. Watch for the last one. | [reply] |
Re: Program unexpectedly terminates by aitap (Chaplain) on Nov 19, 2012 at 14:37 UTC |
| [reply] |
Re: Program unexpectedly terminates by Anonymous Monk on Nov 19, 2012 at 19:03 UTC |
As a shot in the dark, I added $SIG{PIPE} = 'IGNORE'; and haven't seen the problem reoccur in 7 hours, so it's looking like that solved the problem. Now I have to figure out if the culprit is LWP::UserAgent (and it's many dependencies) or Net::Proxy::Type, or IO::Socket::Socks. Then produce a repeatable test case and properly report it as a bug. | [reply] |