Re: External symbols and lists across forks, again

2011-07-25 Thread Henrik Sarvell
I'm really sorry for the confusion, I must've either forgot to restart the
server after some change, sent the wrong input when testing, or simply
tested something else than intended because when I test now after a week
long vacation I have the intended results, eg I can store a list of
externals and access it in http server forks.



On Mon, Jul 25, 2011 at 7:34 PM, Alexander Burger wrote:

> Hi Henrik,
>
> > Sorry for the wording, "non-existent" would have been better.
> >
> > The thing is I'm not able to access the objects if they are stored in a
> list
> > in the parent, eg (setq *Objs (collect ... )), if I then do (show (car
> > *Objs)) in the child process I get NIL.
>
> There must be some fundamental misunderstanding here.
>
>
> Let's do this: Edit in "family.l" from the distribution (after unpacking
> "doc/family.tgz" or "doc/family64.tgz") the 'go' function:
>
>   (de go ()
>  (rollback)
>  (setq *Objs (collect 'nm '+Person))  # Inserted this line
>  (server 8080 "!person") )
>
> '*Objs' is set in the parent, as 'server' will do the first 'fork'.
>
>
> Then I start the server
>
>   $ pil family.l -main -go +
>
> connect the browser to localhost:8080, and at the resulting prompt (we
> are in the child, right?):
>
>   : (show (car *Objs))
>   {2-o} (+Man)
>  ma {2-j}
>  fin 711698
>  dat 688253
>  nm "Adalbert Ferdinand Berengar Viktor of Prussia"
>  pa {2-h}
>   -> {2-o}
>
> or
>
>   : (more *Objs show)
>   {2-o} (+Man)
>  ma {2-j}
>  fin 711698
>  dat 688253
>  nm "Adalbert Ferdinand Berengar Viktor of Prussia"
>  pa {2-h}
>
>   {2-1L} (+Man)
>  mate {2-1M}
>  nm "Adam"
>
>   {2-1B} (+Man)
>  kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
>  nm "Albert Edward"
>  job "Prince"
>  mate {2-f}
>  fin 680370
>  dat 664554
>
>   {2-b} (+Man)
>  ma {2-Y}
>  nm "Albert Victor"
>  dat 680760
>  pa {2-a}
>  fin 690991
>   ...
>
> Voila! :)
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: External symbols and lists across forks, again

2011-07-25 Thread Alexander Burger
Hi Henrik,

> Sorry for the wording, "non-existent" would have been better.
> 
> The thing is I'm not able to access the objects if they are stored in a list
> in the parent, eg (setq *Objs (collect ... )), if I then do (show (car
> *Objs)) in the child process I get NIL.

There must be some fundamental misunderstanding here.


Let's do this: Edit in "family.l" from the distribution (after unpacking
"doc/family.tgz" or "doc/family64.tgz") the 'go' function:

   (de go ()
  (rollback)
  (setq *Objs (collect 'nm '+Person))  # Inserted this line
  (server 8080 "!person") )

'*Objs' is set in the parent, as 'server' will do the first 'fork'.


Then I start the server

   $ pil family.l -main -go +

connect the browser to localhost:8080, and at the resulting prompt (we
are in the child, right?):

   : (show (car *Objs))
   {2-o} (+Man)
  ma {2-j}
  fin 711698
  dat 688253
  nm "Adalbert Ferdinand Berengar Viktor of Prussia"
  pa {2-h}
   -> {2-o}

or

   : (more *Objs show)
   {2-o} (+Man)
  ma {2-j}
  fin 711698
  dat 688253
  nm "Adalbert Ferdinand Berengar Viktor of Prussia"
  pa {2-h}
 
   {2-1L} (+Man)
  mate {2-1M}
  nm "Adam"

   {2-1B} (+Man)
  kids ({2-1C} {2-1D} {2-1E} {2-1F} {2-1G} {2-1H} {2-1I} {2-g} {2-a})
  nm "Albert Edward"
  job "Prince"
  mate {2-f}
  fin 680370
  dat 664554

   {2-b} (+Man)
  ma {2-Y}
  nm "Albert Victor"
  dat 680760
  pa {2-a}
  fin 690991
   ...

Voila! :)

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: External symbols and lists across forks, again

2011-07-25 Thread Henrik Sarvell
Sorry for the wording, "non-existent" would have been better.

The thing is I'm not able to access the objects if they are stored in a list
in the parent, eg (setq *Objs (collect ... )), if I then do (show (car
*Objs)) in the child process I get NIL.

However if I directly store the object, (setq *Obj (db ... )) I am able to
(show *Obj) in the child and the data shows.



On Sat, Jul 16, 2011 at 11:10 PM, Alexander Burger wrote:

> Hi Henrik,
>
> > I just noticed that external symbols are only accessible in a forked
> > http server instance if they are directly stored in a variable, e.g.
> > (setq *Obj (db ... )), however if they are stored in a global list
> > they seem to be inaccessible or?
>
> Sorry, it looks like I don't understand the question.
>
> In general, a forked child process inherits everything from the parent,
> including all symbols (intern, transient and extern) and data structures
> global and local variable bindings, properties etc.
>
> What do you mean with "inaccessible"? Fetching them with a lisp function
> like 'db' or 'collect', and/or with Pilog predicates?
>
> Also the state of the cache is passed to the child, i.e. symbols fetched
> by the parent, and thus currently resident in memory, are also found
> resident by the child.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: External symbols and lists across forks, again

2011-07-16 Thread Alexander Burger
Hi Henrik,

> I just noticed that external symbols are only accessible in a forked
> http server instance if they are directly stored in a variable, e.g.
> (setq *Obj (db ... )), however if they are stored in a global list
> they seem to be inaccessible or?

Sorry, it looks like I don't understand the question.

In general, a forked child process inherits everything from the parent,
including all symbols (intern, transient and extern) and data structures
global and local variable bindings, properties etc.

What do you mean with "inaccessible"? Fetching them with a lisp function
like 'db' or 'collect', and/or with Pilog predicates?

Also the state of the cache is passed to the child, i.e. symbols fetched
by the parent, and thus currently resident in memory, are also found
resident by the child.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


External symbols and lists across forks, again

2011-07-16 Thread Henrik Sarvell
I just noticed that external symbols are only accessible in a forked
http server instance if they are directly stored in a variable, e.g.
(setq *Obj (db ... )), however if they are stored in a global list
they seem to be inaccessible or?

Doing the intern trick works though:

(put '*Testing
(intern "Obj1")
(db ... ) )

That gives me the ability to easily store a number of objects for easy
access but to be able to then do list operations I have to go via getl
which is ugly imho.

Is there no way to somehow store a list with external objects and have
that list persist in memory across forks?
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe