| Author |
Message |
|
| siv |
Posted: Sun May 09, 2010 10:41 am |
|
|
|
User
Joined: 06 May 2010
Posts: 19
|
Hi all,
as a result of a previous discussion, I am now launching processes from a
gen_server with supervisor_bridge, so I can have them under supervision.
The following code is my bridge module:
-module(my_process).
-export([install/1, start/1, init/1, terminate/2]).
install(F) ->
Key = uuid:uuid(),
ChildPid = proc_lib:spawn_link(fun() -> F() end),
Params = {Key, {?MODULE, start, [ChildPid]}, temporary, infinity,
supervisor, [?MODULE]},
{ok, _BridgePid} = supervisor:start_child(main_sup, Params),
{Key, ChildPid}.
start([ChildPid]) ->
supervisor_bridge:start_link(?MODULE, [ChildPid]).
init([ChildPid]) ->
{ok, ChildPid, ChildPid}.
terminate(_Reason, ChildPid) ->
exit(ChildPid, kill).
I need to create the non-otp process linked to the supervisor_bridge
externally (in install()), instead of in init(), because I need its pid for
communicating with it, and I have found that I cannot bring any term outside
the init() function; so, this process is created outside and then linked
inside the bridge itself (which should work, I have checked the
supervisor_bridge sources).
But then, when calling install() (with a valid fun as argument), the
following report is created:
** Reason for termination ==
** {{badmatch,
{error,
{{'EXIT',
{function_clause,
[{my_process,start,[<0.68.0>]},
{supervisor,do_start_child,2},
{supervisor,handle_start_child,2},
{supervisor,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}},
{child,undefined,'17a10803-f064-4718-ae46-4a6d3c88415c',
{my_process,start,[<0.68.0>]},
temporary,infinity,supervisor,
[my_process]}}}},
[{my_process,install,1},
{my_peer,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
Now, I have no idea from where the EXIT error is produced; I have added a
print line in start(), before start_link, but it seems not to be executed;
what am I doing wrong here?
--
Sivieri Alessandro
alessandro.sivieri@gmail.com
http://www.chimera-bellerofonte.eu/
http://www.poul.org/
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Mon May 10, 2010 8:33 am |
|
|
|
Guest
|
On Sun, May 9, 2010 at 11:39 AM, Alessandro Sivieri <
alessandro.sivieri@gmail.com> wrote:
> Hi all,
>
> as a result of a previous discussion, I am now launching processes from a
> gen_server with supervisor_bridge, so I can have them under supervision.
> The following code is my bridge module:
>
> -module(my_process).
> -export([install/1, start/1, init/1, terminate/2]).
> install(F) ->
> Key = uuid:uuid(),
> ChildPid = proc_lib:spawn_link(fun() -> F() end),
> Params = {Key, {?MODULE, start, [ChildPid]}, temporary, infinity,
> supervisor, [?MODULE]},
> {ok, _BridgePid} = supervisor:start_child(main_sup, Params),
> {Key, ChildPid}.
> start([ChildPid]) ->
> supervisor_bridge:start_link(?MODULE, [ChildPid]).
> init([ChildPid]) ->
> {ok, ChildPid, ChildPid}.
> terminate(_Reason, ChildPid) ->
> exit(ChildPid, kill).
>
> I need to create the non-otp process linked to the supervisor_bridge
> externally (in install()), instead of in init(), because I need its pid for
> communicating with it, and I have found that I cannot bring any term
> outside
> the init() function; so, this process is created outside and then linked
> inside the bridge itself (which should work, I have checked the
> supervisor_bridge sources).
> But then, when calling install() (with a valid fun as argument), the
> following report is created:
>
> ** Reason for termination ==
> ** {{badmatch,
> {error,
> {{'EXIT',
> {function_clause,
> [{my_process,start,[<0.68.0>]},
> {supervisor,do_start_child,2},
> {supervisor,handle_start_child,2},
> {supervisor,handle_call,3},
> {gen_server,handle_msg,5},
> {proc_lib,init_p_do_apply,3}]}},
> {child,undefined,'17a10803-f064-4718-ae46-4a6d3c88415c',
> {my_process,start,[<0.68.0>]},
> temporary,infinity,supervisor,
> [my_process]}}}},
> [{my_process,install,1},
> {my_peer,handle_call,3},
> {gen_server,handle_msg,5},
> {proc_lib,init_p_do_apply,3}]}
>
> Now, I have no idea from where the EXIT error is produced; I have added a
> print line in start(), before start_link, but it seems not to be executed;
> what am I doing wrong here?
>
>
>
Your child spec states: {?MODULE, start, [ChildPid]} as the Module,
Function, Arglist to use.
But your definition of start() expects a list to be passed in, not a simple
pid.
So, simply remove the [] brackets from your start/1 definition, I'd think.
Oh, the error function_clause means that you were trying to invoke a
function that exists, but where the arguments could not be matched to any
clause.
Robby
Post received from mailinglist |
|
|
| Back to top |
|
| siv |
Posted: Mon May 10, 2010 2:16 pm |
|
|
|
User
Joined: 06 May 2010
Posts: 19
|
2010/5/10 Robert Raschke <rtrlists@googlemail.com>
> Oh, the error function_clause means that you were trying to invoke a
> function that exists, but where the arguments could not be matched to any
> clause.
>
Ah yes, of course, I knew there was some stupid error somewhere...
Anyway, now that aspect is solved, but there is one more interesting thing:
in a situation like the one pictured here [1], where 78 and 81 are bridges
and 77 and 80 are the two monitored processes (created with the code
previously reported), if I kill one of those 4 processes, all the 4 ones are
killed, while I thought that only the bridge (if killing its child) or the
child (if killing the bridge) should die, while the others shouldn't be
involved.
Why this is not happening? The main supervisor policy is one_for_one.
[1] http://yfrog.com/5jtreeip
--
Sivieri Alessandro
alessandro.sivieri@gmail.com
http://www.chimera-bellerofonte.eu/
http://www.poul.org/
Post received from mailinglist |
|
|
| Back to top |
|
| siv |
Posted: Tue May 11, 2010 3:28 pm |
|
|
|
User
Joined: 06 May 2010
Posts: 19
|
|
| Back to top |
|
| siv |
Posted: Wed May 12, 2010 1:58 pm |
|
|
|
User
Joined: 06 May 2010
Posts: 19
|
|
| Back to top |
|
| wuji |
Posted: Sat Aug 11, 2012 1:30 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
for your appeal. There are really only three basic basic cheap replica *beep* basic arguments you can make to appeal your tax assessment.
keeps it nice and simple. See if one applies:1. The The replica designer *beep* The assessor made a mistake in describing your house. This
covers situations where the assessor made simple math mistakes. Maybe Maybe cheap Ralph Lauren Polo Maybe he got the square footage wrong (only heated, livable
should be counted), or stated that you have five bedrooms bedrooms cheap designer *beep* bedrooms when you have three. If you uncover these errors,
you – you've just upped your chances of a slam slam replica designer bags for sale slam dunk win. All you have to do is gather
and describe the errors in writing or in person.2. You You cheap replica *beep* You just bought the house for less. If you recently |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|