Pengines calling Pengines?

42 views
Skip to first unread message

Ralf Wolter

unread,
Jan 27, 2016, 11:44:00 AM1/27/16
to SWI-Prolog
Hello,

While playing around with the Pengine library I ran into a problem. I created a small expert system with four components. Control and linking of these components was done through JavaScript from a html page. This worked fine, but offloaded a lot of logic to the client. So next I tried to create an engine for controlling the components. Here I am running into a few problems however. 

The current version creates a controller component pengine from javascript. The controller component creates the four specific pengines for the expert system. This seems to work but when I start the event loop the controller component stops responding to queries, as per pengine_start_event_loop, while without the event loop there are no callbacks from components other then the controller.

What would be the best way to handle such a scenario?

sincerely,

Ralf

Pasi Xyy

unread,
Jan 29, 2016, 10:54:33 AM1/29/16
to swi-p...@googlegroups.com
Maybe this is the case. There is a limit for how many slaves/servers it is possible to create by master/client, the limit is 3 current_pengine_application/1

So the pengine_event_handler/3 can handle just three remote pengines when created like pengine_create([ ... server(IPaddress) ...]). pengine_rpc/2 can deal with many more. I am not sure why the limit is just 3??? I believe the pengine_rpc/2 is being used under the hood while using event handlers???

In documentation, the remote pengines are in master--slave perspective called slaves, and in client--server perspective called servers. This is confusing.

Pengines: Web Logic Programming Made Easy-- 1.5 Pengine settings says that Maximum number of pengines a client can create is 1
Source code for current_pengine_application says Maximum number of slave pengines a master pengine can create is 3

Jan Wielemaker

unread,
Jan 29, 2016, 11:40:36 AM1/29/16
to Pasi Xyy, SWI-Prolog
On 01/29/2016 04:54 PM, Pasi Xyy wrote:
> Maybe this is the case. There is a limit for how many slaves/servers it
> is possible to create by master/client, the limit is 3
> current_pengine_application/1
> <http://www.swi-prolog.org/pldoc/doc/usr/lib/swi-prolog/library/pengines.pl?show=src#current_pengine_application/1>
>
> So the pengine_event_handler/3 can handle just three remote pengines
> when created like pengine_create([ ... server(IPaddress) ...]).
> pengine_rpc/2 can deal with many more. I am not sure why the limit is
> just 3??? I believe the pengine_rpc/2 is being used under the hood while
> using event handlers???

The limit is low to avoid overloading the server by forgetting to close
the unused pengines. pengine_rpc/2 takes care of the destruction.

Cheers --- Jan

> In documentation, the remote pengines are in master--slave perspective
> called slaves, and in client--server perspective called servers. This is
> confusing.
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Anne Ogborn

unread,
Jan 29, 2016, 5:15:33 PM1/29/16
to Pasi Xyy, SWI-Prolog
That limit is settable -

http://www.swi-prolog.org/pldoc/man?section=pengine-settings

It's reasonable to have a max number of pengines/session to prevent denial of service attacks by limiting how much work you're willing to do for a given client.

Forgive me for plumping my own stuff, but you might find this useful -

https://www.youtube.com/watch?v=JmOHV5IlPyU

pengine_rpc makes a new pengine for each call and disposes when it fails/suceeds.

Pasi Xyy

unread,
Feb 2, 2016, 2:47:24 PM2/2/16
to swi-p...@googlegroups.com, pasi...@dnainternet.net, anni...@yahoo.com
Thanks!

I couldn't change the settings because I didn't know how, but now when I few minutes ago googled the whole swi-prolog.org site I found the settings.pl    Please update the pengines documentation, 1) about how to change the settings and 2) with your remarks about the maximum value. Also the  Swi-Prolog Help does not know about the settings library
Reply all
Reply to author
Forward
0 new messages