You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Angus Lees <gu...@inodes.org> on 2005/08/04 13:24:16 UTC

Embperl::Object doesn't cache app object correctly?

Gerald, I think the app object logic in Embperl::Object::Execute() is
wrong.  It seems to always recreate the application object, where it
should only do it once.  Looking at the code, it never seems to check
if $packages{"$fn::$appfn"} already exists before creating a new app
object.

Now that I think about it further, is "$fn::$appfn" the right key to
use here - do we *want* a new app object for each base file?  Surely
we should just be caching this against the appname or something.


In case I've missed the mark completely, the bug I'm seeing is this:

I've got an (offline) perl loop that repeatedly calls:
    my $rc = Embperl::Object::Execute({inputfile => $inpath,
				       outputfile => $outpath,
				       appname => 'gusweb',
				       object_app => '_app.pl',
				      });

and I'm seeing the application object get created and work correctly
on the first request - but the second request gets:

 [24276]ERR:  24:  Error in Perl code: Can't locate object method "init" via package "Embperl::__4" at /usr/lib/perl5/Embperl/Object.pm line 314, <$inv> line 5.

and the third gets:

 [24276]ERR:  32:  Warning in Perl code: Subroutine init redefined at /home/gus/public_html/gus/_app.pl line 12, <$inv> line 8.
 [24276]ERR:  32:  Warning in Perl code: Subroutine get_recipe redefined at /home/gus/public_html/gus/_app.pl line 23, <$inv> line 8.

the fourth gets:

 [24276]ERR:  24:  Error in Perl code: Can't locate object method "init" via package "Embperl::__4" at /usr/lib/perl5/Embperl/Object.pm line 314, <$inv> line 32.

the fifth gets the "subroutine redefined" errors, etc.

dbgObjectSearch log attached.

 - Gus


RE: Embperl::Object doesn't cache app object correctly?

Posted by Gerald Richter <ri...@ecos.de>.
> 
> Gerald, I think the app object logic in 
> Embperl::Object::Execute() is wrong.  It seems to always 
> recreate the application object, where it should only do it 
> once.  Looking at the code, it never seems to check if 
> $packages{"$fn::$appfn"} already exists before creating a new 
> app object.
> 

The $packages{"$fn::$appfn"} never get used, so it doesn't hurt (also I
should delete this assignment)

Normaly the run($c) a few lines below should make sure that it is compiled
in the same package, but somehow this doesn't seem to work here.

Also this code is only used to get the perl code compiled, the real object
pointer is the application object which is retrived with $r -> app and bless
into the package return by the call to run($c) .

Could you run your test again with debug set to 0x7fffffff and send me the
logfile

Gerald




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Embperl::Object doesn't cache app object correctly?

Posted by Gerald Richter <ri...@ecos.de>.
> 
> Gerald, I think the app object logic in 
> Embperl::Object::Execute() is wrong.  It seems to always 
> recreate the application object, where it should only do it 
> once.  Looking at the code, it never seems to check if 
> $packages{"$fn::$appfn"} already exists before creating a new 
> app object.
> 

I have tried to reproduce this problem, but I don't get it, so please make
the test with more debugging (see my other mail) .

Gerald


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org