[erlang-questions] [gen_server] time out error when handle_call returns {noreply, State}
Marcin Maciukiewicz
ciukes2@REDACTED
Wed May 28 14:07:15 CEST 2008
>> I feel I need an extra push to understand. The reason why I play with
>> {noreply, State} is because I want to understand how to deal with this
>> case.
>
> Which case is that?
Comes from "erlang-psql-driver" connection pooling code:
http://erlang-psql-driver.googlecode.com/svn/trunk/src/psql_pool.erl
Scroll down to "handle_call({alloc, Pid}...). For "nomatch" case
{noreply, State} is returned.
Trying to use the driver I end up in the scenario I described. Code
hungs for 5 seconds, then time out error happens.
The snippet I made (http://pastebin.com/f590f0e00) is an extract from
the situation I'm struggling with.
Firstly I was following the documentation
(http://erlang-psql-driver.googlecode.com/svn/trunk/doc/overview.edoc):
[code]
test()->
psql_pool:start_link(),
P = psql:allocate(),
... more code
[/code]
Code above causes time out. "more code" is not executed. After digging
the erlang-psql-driver code (good lesson for newbie like me) I
realized I have no idea how gen_server:call behaves when {noreply,
State} from handle_call is returned. An example from "Programming
Erlang" (http://media.pragprog.com/titles/jaerlang/code/my_bank.erl)
doesn't explain this too. This is how I end up with asking you guys
for help.
At the end of the day I want to learn the answers to following questions:
- Why/When use {noreply, State} in handle_call
- How to write proper code for this value returned - you gave me a
lot of input on that, thank you.
- Why the heck psql:handle_call({allocate,Pid}... ) from
erlang-psql-driver is not working.
Regards,
Marcin.
More information about the erlang-questions
mailing list