On Sun, Jan 29, 2012 at 5:28 PM, Ricardo Pedroso <[email protected]> wrote:
> On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
> <[email protected]> wrote:
>
>> I used to be able to stop the server with CRTL+C but it does not work
>> anymore on my mac. I now have to kill it. Why?
>
> I'm new to web2py, but I already see this happened
> in other scripts when working with sockets and threads.

I've been analyzing this issue and I think I've found the problem
I think the problem could be with HTTP/1.1 keep_alive feature.

How to test:
1. In a console start web2py:
$ ./web2py

2. In other console start a telnet connection to web2py:
$ telnet 127.0.0.1 8000
GET / HTTP/1.1<CR>
Host: 127.0.0.1:8000<CR>
Connection: keep-alive<CR>
<CR>

After this last <CR>, telnet session doesn't quit.

Now in the other console stop web2py with CTRL-C
it will hand, but if you kill the telnet web2py quit immediately.


This test can be done with a browser also:
Just run one and only one browser instance and goto http://127.0.0.1:8000
Then CTRL-C web2py, it will hang
Close your browser and web2py quits immediately

web2py after some time eventually quits, the socket will timeout, I'm not
sure but this timeout is the default from the OS.

web2py is hanging in the thread join in rocket.py around line 1066 in
the stop method.

This was not easy for me to explain but I hope that I gave some more
leads to this issue.

Ricardo

Reply via email to