SWI-Prolog / packages-pengines

Pengines: Prolog engines
11 stars 13 forks source link

pengine gets immediately destroyed #40

Closed kollapsderwellenfunktion closed 5 years ago

kollapsderwellenfunktion commented 5 years ago

hello, i'm trying to start a local pengine using the following code with the genealogist module taken from your pengine application server samples:

:- module(app_genealogist, []).
:- use_module(library(pengines)).
:- use_module(library(pengines_sandbox)).
:- pengine_application(genealogist).
:- use_module(genealogist:genealogist).

launch :-
    pengine_create([
        alias(gen),application(genealogist)
    ]),
    pengine_event_loop(handle, []).

handle(create(ID, _)) :-
    pengine_ask(gen, assert_mother_child(mama, sohn) , []),
    %!  pengine_ask(ID,parent_child(mama,sohn),[]),
    writeln(ID).
handle(success(ID, [assert_mother_child(mama,sohn)], false)) :-
    writeln('asserted mother child'),
    writeln(ID).

handle(success(ID,[X],false)) :-
    writeln('the other success returned'),
    writeln(X).

handle(success(ID, [X], true)) :-
    writeln(X),
    pengine_next(ID, []).

handle(failure(ID)) :-
    writeln('failure happended').
handle(error(ID, Term)) :-
    writeln('error'),
    writeln(ID),
    writeln(Term).

handle(destroy(ID)) :-
    writeln('destroyed pengine'),
    writeln(ID).

when load i load this code with swipl app.pl, i get the following result:

?- launch. Correct to: "app_genealogist:launch"? yes 31532ea6-9c1e-4bde-8a4a-e9dcdb2cc755 asserted mnother child 31532ea6-9c1e-4bde-8a4a-e9dcdb2cc755 destroyed pengine 31532ea6-9c1e-4bde-8a4a-e9dcdb2cc755 true.

why does the pengine get immediately destroyed ?

with best regards...