Dear HP Wei,
The error you observe is due to the distributed behavior of procedures.
The problem is: the procedure call {C.p ...} is *not* executed on the
remote host, as you apparently expect it to do! The procedure P defined
in the functor is *copied* from the remote host to the local one, then
it is executed locally. The problem is that P refers to Open.pipe, a
class that cannot be copied between sites, because it refers to site
resources (OS file descriptors, etc). That class is thus exported as a
"resource", which is an opaque unusable value.
{R apply(X C)} %%% b -- to run on remote host
%% procedure P is indeed created on the remote host
local L Cmd in
Cmd = "ls a_path | wc"
{C.p Cmd L} %% the procedure is copied and run *here*
{System.showInfo L}
end
The solution is to force the remote creation of objects, by using a
port. This can be seen as an implementation of RPC for procedure P:
X = functor
import Open
export p:P
define
Str Prt={NewPort Str}
thread
for Cmd#R in Str % process requests (on remote host)
thread
{{New Open.pipe init(cmd: "sh" args:['-c' Cmd])}
read(list:R size:all)}
end
end
end
proc {P Cmd ?R}
{Send Prt Cmd#R} % send the request on port
end
end
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users