share objects

share objects

am 03.04.2008 17:32:16 von fjmolinabravo

------=_Part_2804_400561.1207236741537
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi

I have installed static mp2 with apache 2.0.63 (forker). I am using perl
bind (Sleepycat::DBXML) from dbxml; then I create an object (reference to
Sleepycat::DBXML) in startup.pl because i want to share it. After some test
(stress it) for my application I saw some error in error.log; the problem is
that reference to object created in startup.pl was lost

then the question is ... is possible to share objects?


I know I can share data between processes, but what I also shared objects?



thanks in advance

------=_Part_2804_400561.1207236741537
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi

I have  installed static mp2 with apache
2.0.63 (forker).  I am using perl bind (Sleepycat::DBXML) from dbxml;
then I create an object (reference to Sleepycat::DBXML) in startup.pl
because i want to share it. After some test (stress it) for my
application I saw some error in error.log; the problem is that
reference to object created in startup.pl was lost


then the question is ... is possible to share objects?


I know I can share data between processes, but what I also shared objects?



thanks in advance


------=_Part_2804_400561.1207236741537--

Re: share objects

am 03.04.2008 17:48:15 von Jeff Pang

On Thu, Apr 3, 2008 at 11:32 PM, Felipe de Jes=FAs Molina Bravo
wrote:
> hi
>
> I have installed static mp2 with apache 2.0.63 (forker). I am using per=
l
> bind (Sleepycat::DBXML) from dbxml; then I create an object (reference to
> Sleepycat::DBXML) in startup.pl because i want to share it. After some te=
st
> (stress it) for my application I saw some error in error.log; the problem=
is
> that reference to object created in startup.pl was lost
>
> then the question is ... is possible to share objects?
>

If your object has its own package name space, you can share it
between multi-processes.
But if you state this in startup.pl,

my $obj =3D Sleepycat::DBXML->new();

this $obj can't be shared among multi-processes. Because it doesn't
have its package name space.

So,you'd better write a package to encap that object, like:

package MyPKG;
use strict;
use Sleepycat::DBXML;

our $obj =3D Sleepycat::DBXML->new;
sub initobj { $obj }

1;

And put 'use MyPKG' in the startup.pl.
then in your scripts you can access this object by saying 'our $obj'
or via the method of 'my $obj =3D MyPKG->initobj'.

Good luck.

Re: share objects

am 03.04.2008 18:24:19 von Perrin Harkins

On Thu, Apr 3, 2008 at 11:32 AM, Felipe de Jes=FAs Molina Bravo
wrote:
> I know I can share data between processes, but what I also shared objects=
?

It depends on what you mean by share. You can create a simple perl
object in startup.pl and access it from all processes later, but if
you change it in one process, the change will not be seen in the
others. With objects that contain open sockets, file handles, or XS
structures, you usually can't share them at all. This is why you
can't open a DBI connection in startup and use it from your child
processes.

I don't know Sleepycat::DBXML, but it sounds like something that would
use file handles. Try creating your object in a PerlInitHandler
instead, which runs in the child process when it is first created.

- Perrin

Re: share objects

am 03.04.2008 19:17:39 von fjmolinabravo

------=_Part_3311_20894592.1207243059918
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

2008/4/3, Jeff Pang :
>
> On Thu, Apr 3, 2008 at 11:32 PM, Felipe de Jes=FAs Molina Bravo
> wrote:
> > hi
> >
> > I have installed static mp2 with apache 2.0.63 (forker). I am using
> perl
> > bind (Sleepycat::DBXML) from dbxml; then I create an object (reference
> to
> > Sleepycat::DBXML) in startup.pl because i want to share it. After some
> test
> > (stress it) for my application I saw some error in error.log; the
> problem is
> > that reference to object created in startup.pl was lost
> >
> > then the question is ... is possible to share objects?
> >
>
>
> If your object has its own package name space, you can share it
> between multi-processes.
> But if you state this in startup.pl,
>
> my $obj =3D Sleepycat::DBXML->new();
>
> this $obj can't be shared among multi-processes. Because it doesn't
> have its package name space.
>
> So,you'd better write a package to encap that object, like:
>
> package MyPKG;
> use strict;
> use Sleepycat::DBXML;
>
> our $obj =3D Sleepycat::DBXML->new;
> sub initobj { $obj }
>
> 1;
>
> And put 'use MyPKG' in the startup.pl.
> then in your scripts you can access this object by saying 'our $obj'
> or via the method of 'my $obj =3D MyPKG->initobj'.
>
> Good luck.
>

thanks a lot

My problem was solved ... The problem was that I had the buildup of the
object (new) within "sub initobj () "

regards

------=_Part_3311_20894592.1207243059918
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline



2008/4/3, Jeff Pang < "mailto:pangj@earthlink.net">pangj@earthlink.net>: class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); =
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Apr 3, 2008 at 11:32 PM, Felipe de Jes=FAs Molina Bravo
< href=3D"mailto:fjmolinabravo@gmail.com">fjmolinabravo@gmail. com> wro=
te:
> hi
>
> I have  installed static mp2 wi=
th apache 2.0.63 (forker).  I am using perl

> bind (Sleepycat::DBXML) from dbxml; then I create an object (referenc=
e to
> Sleepycat::DBXML) in startup.pl because i want to share it. A=
fter some test
> (stress it) for my application I saw some error in =
error.log; the problem is

> that reference to object created in startup.pl was lost
>
=
> then the question is ... is possible to share objects?
>
r>
If your object has its own package name space, you can share it

between multi-processes.
But if you state this in startup.pl,

=
my $obj =3D Sleepycat::DBXML->new();

this $obj can't be sh=
ared among multi-processes. Because it doesn't
have its package nam=
e space.


So,you'd better write a package to encap that object, like:
<=
br> package MyPKG;
use strict;
use Sleepycat::DBXML;

our $=
obj =3D  Sleepycat::DBXML->new;
sub initobj { $obj }
<=
br> 1;


And put 'use MyPKG' in the startup.pl.
then in your scrip=
ts you can access this object by saying 'our $obj'
or via the m=
ethod of 'my $obj =3D MyPKG->initobj'.

Good luck.


thanks a lot

My problem was solved ... The p=
roblem was that I had the buildup of the object (new) within "sub init=
obj () "

regards


------=_Part_3311_20894592.1207243059918--

Re: share objects

am 03.04.2008 19:33:54 von fjmolinabravo

------=_Part_3364_25270428.1207244034283
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

2008/4/3, Perrin Harkins :
>
> On Thu, Apr 3, 2008 at 11:32 AM, Felipe de Jes=FAs Molina Bravo
> wrote:
>
> > I know I can share data between processes, but what I also shared
> objects?
>
>
> It depends on what you mean by share. You can create a simple perl
> object in startup.pl and access it from all processes later, but if
> you change it in one process, the change will not be seen in the
> others. With objects that contain open sockets, file handles, or XS
> structures, you usually can't share them at all.


Is when they can be shared? and if my file handle is open of "ro" .... it
can share between process?


This is why you
> can't open a DBI connection in startup and use it from your child
> processes.
>
> I don't know Sleepycat::DBXML, but it sounds like something that would
> use file handles. Try creating your object in a PerlInitHandler
> instead, which runs in the child process when it is first created.

- Perrin
>

Thanks ...
best regards

felipe

------=_Part_3364_25270428.1207244034283
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline



2008/4/3, Perrin Harkins < ef=3D"mailto:perrin@elem.com">perrin@elem.com>:
ass=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); mar=
gin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Apr 3, 2008 at 11:32 AM, Felipe de Jes=FAs Molina Bravo
< href=3D"mailto:fjmolinabravo@gmail.com">fjmolinabravo@gmail. com> wro=
te:

> I know I can share data between processes, but what I also=
shared objects?



It depends on what you mean by share.  You can create a=
simple perl
object in startup.pl and access it from all processes late=
r, but if
you change it in one process, the change will not be seen in =
the

others.  With objects that contain open sockets, file handles, o=
r XS
structures, you usually can't share them at all.   blockquote>

Is when they can be shared?  and if my file handle=
is open of "ro"  .... it can share between process?

 

solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">T=
his is why you
can't open a DBI connection in startup and use it fr=
om your child

processes.

I don't know Sleepycat::DBXML, but it sounds like =
something that would
use file handles.  Try creating your obj=
ect in a PerlInitHandler
instead, which runs in the child process when =
it is first created.

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> - Perrin
lockquote>

Thanks ...
best regards

felipe



------=_Part_3364_25270428.1207244034283--

Re: share objects

am 03.04.2008 20:59:50 von Perrin Harkins

On Thu, Apr 3, 2008 at 1:33 PM, Felipe de Jes=FAs Molina Bravo
wrote:
> > It depends on what you mean by share. You can create a simple perl
> > object in startup.pl and access it from all processes later, but if
> > you change it in one process, the change will not be seen in the
> > others. With objects that contain open sockets, file handles, or XS
> > structures, you usually can't share them at all.
>
> Is when they can be shared? and if my file handle is open of "ro" .... =
it
> can share between process?

It can be done, but it's tricky. When you try to use one file handle
from multiple process it gets confused about the location in the file.
If you really need to do it, read about shared file handles in
Programming Perl or your favorite Unix reference.

- Perrin

Re: share objects

am 03.04.2008 22:17:47 von fjmolinabravo

------=_Part_4163_1491849.1207253867081
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

2008/4/3, Perrin Harkins :
>
> On Thu, Apr 3, 2008 at 1:33 PM, Felipe de Jes=FAs Molina Bravo
> wrote:
> > > It depends on what you mean by share. You can create a simple perl
> > > object in startup.pl and access it from all processes later, but if
> > > you change it in one process, the change will not be seen in the
> > > others. With objects that contain open sockets, file handles, or XS
> > > structures, you usually can't share them at all.
> >
> > Is when they can be shared? and if my file handle is open of "ro" ...=
..
> it
> > can share between process?
>
>
> It can be done, but it's tricky. When you try to use one file handle
> from multiple process it gets confused about the location in the file.
> If you really need to do it, read about shared file handles in
> Programming Perl or your favorite Unix reference.
>
>
> - Perrin
>

ok ...thanks a lot


regards
felipe

------=_Part_4163_1491849.1207253867081
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline



2008/4/3, Perrin Harkins < ef=3D"mailto:perrin@elem.com">perrin@elem.com>:
ass=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); mar=
gin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Apr 3, 2008 at 1:33 PM, Felipe de Jes=FAs Molina Bravo
< ref=3D"mailto:fjmolinabravo@gmail.com">fjmolinabravo@gmail.c om> wrot=
e:
> > It depends on what you mean by share.  You can c=
reate a simple perl

> > object in startup.pl and access it from all processes later, but=
if
> > you change it in one process, the change will not be seen=
in the
> > others.  With objects that contain open soc=
kets, file handles, or XS

> > structures, you usually can't share them at all.
> > > Is when they can be shared?  and if my file handle is open=
of "ro"  .... it
> can share between process? r>

It can be done, but it's tricky.  When you try to=
use one file handle

from multiple process it gets confused about the location in the file.
=
  If you really need to do it, read about shared file handles in<=
br> Programming Perl or your favorite Unix reference.


- Perrin=



ok ...thanks a lot


regards
felipe



------=_Part_4163_1491849.1207253867081--