Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

attempt to reload My_module.pm aborted

by prashanttekriwal (Novice)
on Apr 18, 2013 at 12:44 UTC ( #1029344=perlquestion: print w/replies, xml ) Need Help??
prashanttekriwal has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

First of all let me give you a little background of what we are doing and then I will explain the issue and the solution I need.

----Background----

Our team owns a test automation framework that enables users to develop and execute their tests.

Till now the whole system and the users are using perl 5.8.8 and hence we decided to migrate to perl 5.14.0.

----Issue----

Now, one of the user is getting an error when running his scripts using perl 5.14 which is working fine with perl5.8.8.

The error coming is 'Attempt to reload <module> aborted', where <module> is an internal module of our company.

I know the background of the error but we don't know where previous load of this module is failing since the test script has a long list of module reference.

----What I need----

To me the issue is not where the previous load is failing since it was failing earlier as well (with perl 5.8.8) but the test script was still going through.

I need to know, is there a way to tell perl5.14.0 not to treat this as an error (like perl5.8.8 does).

We can't put the code block where its failing under 'eval' as its doing 'use <module>' right at the beginning of the file.

Any help, solution, workaround for this issue will be highly appreciated.

Thanks in Advance,
Prashant

Replies are listed 'Best First'.
Re: attempt to reload My_module.pm aborted
by Anonymous Monk on Apr 18, 2013 at 12:52 UTC
    fatal errors are fatal
    Attempt to reload %s aborted. (F) You tried to load a file with "use" or "require" that failed t +o compile once already. Perl will not try to compile this file again unless you delete its entry from %INC. See "require" in perlfunc a +nd

    You can trap fatal errors with a $SIG{__DIE__} handler

Re: attempt to reload My_module.pm aborted
by kcott (Chancellor) on Apr 18, 2013 at 13:42 UTC

    G'day prashanttekriwal,

    This seems like a very strange scenario to me. Have you provided all the details? If <module> is failing to compile, then the obvious solution would be to fix it.

    Until it's been fixed, you presumably won't be able to use any of the features provided by this module. Given that, surely just commenting out the use statement would provide an interim solution.

    # use <module>; # FIX PENDING!

    Another alternative might be to use the if pragma. Here's an example usage:

    $ NOT_A_MODULE_FIXED=0 perl -Mstrict -Mwarnings -e ' use Data::Dumper; use if $ENV{NOT_A_MODULE_FIXED} => "Not::A::Module"; print Dumper {test => 1}; ' $VAR1 = { 'test' => 1 };

    [The use of Data::Dumper is just an example — your "long list of modules" would go here.]

    You might gain some additional information by searching for "Attempt to reload %s aborted." in perldiag.

    -- Ken

Re: attempt to reload My_module.pm aborted
by prashanttekriwal (Novice) on Apr 18, 2013 at 18:36 UTC
    Hi all,

    Thanks for the replies.

    Actually I don't know how the users are using their script even though the module is failing to load.
    Since it has been working earlier with perl5.8.8, I had to make it work for perl 5.14 as it is really difficult to figure out where the first attempt is failing.

    I was able to get around the issue by doing this:
    eval { require Module; }; my $error = $@; if ($error && $error =~ /attempt to reload/i){ delete $INC{'Module'}; require Module; } else{ die $error; }
    and its working fine as it was earlier.

    I know this seems to be a very tedious hack but then there is no other way I could think of since I can't comment the 'use' statement.

    I appreciate all the replies I got.

    Thanks again,
    Prashant

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1029344]
Approved by Corion
help
Chatterbox?
marto should develop the 'anti-social network'
[marto]: sign up to make it impossible to be contacted online :P
[Discipulus]: karl: configuring the network is like: nmcli conn add con-name "name name" ifname eth0 type eterneth.... not so different from powersehell longness

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-12-14 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?