Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-31 Thread Ricardo Pedroso
On Tue, Jan 31, 2012 at 3:14 AM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 Specifically it waits for the socket timeout of 60 seconds here:

 rocket.py line 1063:
        # Wait until they pull the
 trigger
        for t in self.threads:
            if t.isAlive():
                t.join()

 I feel it is ok to have the timeout set to 60secs but not here. I have
 not yet found a way to change the timeout at this point.
 I tried

 rocket.py line 1063:
        # Wait until they pull the
 trigger
        for t in self.threads:
            if t.isAlive():
                t.conn.socket.settimeout(1) #
                t.join()

 but it did not change a thing.

Instead of trying to change the timeout, probably is better to
force the shutdown, something like:

            if t.isAlive():
try:
t.conn.socket.shutdown(socket.SHUT_RDWR)
except socket.error:
pass
            t.join()

But can be wised to ask Tim is opinion about this.

Ricardo


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-31 Thread Massimo Di Pierro
I agree. In particular considering this:

https://groups.google.com/group/web2py/browse_thread/thread/d7f6faddb841790b/3ef04bd25c5b81b1#3ef04bd25c5b81b1

On Jan 31, 4:00 am, Ricardo Pedroso rmdpedr...@gmail.com wrote:
 On Tue, Jan 31, 2012 at 3:14 AM, Massimo Di Pierro









 massimo.dipie...@gmail.com wrote:
  Specifically it waits for the socket timeout of 60 seconds here:

  rocket.py line 1063:
         # Wait until they pull the
  trigger
         for t in self.threads:
             if t.isAlive():
                 t.join()

  I feel it is ok to have the timeout set to 60secs but not here. I have
  not yet found a way to change the timeout at this point.
  I tried

  rocket.py line 1063:
         # Wait until they pull the
  trigger
         for t in self.threads:
             if t.isAlive():
                 t.conn.socket.settimeout(1) #
                 t.join()

  but it did not change a thing.

 Instead of trying to change the timeout, probably is better to
 force the shutdown, something like:

             if t.isAlive():
                 try:
                     t.conn.socket.shutdown(socket.SHUT_RDWR)
                 except socket.error:
                     pass
                 t.join()

 But can be wised to ask Tim is opinion about this.

 Ricardo


CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-30 Thread Ricardo Pedroso
On Sun, Jan 29, 2012 at 5:28 PM, Ricardo Pedroso rmdpedr...@gmail.com wrote:
 On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
 massimo.dipie...@gmail.com 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.1CR
Host: 127.0.0.1:8000CR
Connection: keep-aliveCR
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


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-30 Thread Massimo Di Pierro
Thanks ricardo. This really helps a lot.

On Jan 30, 5:01 pm, Ricardo Pedroso rmdpedr...@gmail.com wrote:
 On Sun, Jan 29, 2012 at 5:28 PM, Ricardo Pedroso rmdpedr...@gmail.com wrote:
  On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
  massimo.dipie...@gmail.com 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.1CR
 Host: 127.0.0.1:8000CR
 Connection: keep-aliveCR
 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 gotohttp://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


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-30 Thread Massimo Di Pierro
Progress.

reverting this change makes the problem go away:

http://code.google.com/p/web2py/source/diff?spec=svn9619eb054669ed5931f65f8815731f4c52857c5dr=9619eb054669ed5931f65f8815731f4c52857c5dformat=sidepath=/gluon/widget.py

The problem is that the socket timeout was increased from 1 to 60 so
that the web server does not close connections with slow clients.
Somehow CTRL-C gets queued until the 60 seconds expire.

Massimo

On Jan 30, 5:01 pm, Ricardo Pedroso rmdpedr...@gmail.com wrote:
 On Sun, Jan 29, 2012 at 5:28 PM, Ricardo Pedroso rmdpedr...@gmail.com wrote:
  On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
  massimo.dipie...@gmail.com 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.1CR
 Host: 127.0.0.1:8000CR
 Connection: keep-aliveCR
 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 gotohttp://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


Re: CTRL-C webpy hangs (was: Re: [web2py] help with js issue)

2012-01-30 Thread Massimo Di Pierro
Specifically it waits for the socket timeout of 60 seconds here:

rocket.py line 1063:
# Wait until they pull the
trigger
for t in self.threads:
if t.isAlive():
t.join()

I feel it is ok to have the timeout set to 60secs but not here. I have
not yet found a way to change the timeout at this point.
I tried

rocket.py line 1063:
# Wait until they pull the
trigger
for t in self.threads:
if t.isAlive():
t.conn.socket.settimeout(1) #
t.join()

but it did not change a thing.

On Jan 30, 8:20 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Progress.

 reverting this change makes the problem go away:

 http://code.google.com/p/web2py/source/diff?spec=svn9619eb054669ed593...

 The problem is that the socket timeout was increased from 1 to 60 so
 that the web server does not close connections with slow clients.
 Somehow CTRL-C gets queued until the 60 seconds expire.

 Massimo

 On Jan 30, 5:01 pm, Ricardo Pedroso rmdpedr...@gmail.com wrote:







  On Sun, Jan 29, 2012 at 5:28 PM, Ricardo Pedroso rmdpedr...@gmail.com 
  wrote:
   On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
   massimo.dipie...@gmail.com 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.1CR
  Host: 127.0.0.1:8000CR
  Connection: keep-aliveCR
  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 gotohttp://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


[web2py] help with js issue

2012-01-29 Thread Massimo Di Pierro
I would like to post web2py 2.0 since we have no major pending issues.
Yet there are two issues I would like to fix first:

http://code.google.com/p/web2py/issues/detail?id=627

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 could use some help. ;-)

Massimo


Re: [web2py] help with js issue

2012-01-29 Thread Bruno Rocha
the same for me, I always have to kill - 9 PID.

But it only happens after some time.

http://zerp.ly/rochacbruno
Em 29/01/2012 14:27, Massimo Di Pierro massimo.dipie...@gmail.com
escreveu:

 I would like to post web2py 2.0 since we have no major pending issues.
 Yet there are two issues I would like to fix first:

 http://code.google.com/p/web2py/issues/detail?id=627

 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 could use some help. ;-)

 Massimo


Re: [web2py] help with js issue

2012-01-29 Thread Ovidio Marinho
Ctrl+C in Mac is Cmd+C



   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil




2012/1/29 Bruno Rocha rochacbr...@gmail.com

 the same for me, I always have to kill - 9 PID.

 But it only happens after some time.

 http://zerp.ly/rochacbruno
 Em 29/01/2012 14:27, Massimo Di Pierro massimo.dipie...@gmail.com
 escreveu:

  I would like to post web2py 2.0 since we have no major pending issues.
 Yet there are two issues I would like to fix first:

 http://code.google.com/p/web2py/issues/detail?id=627

 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 could use some help. ;-)

 Massimo




Re: [web2py] help with js issue

2012-01-29 Thread Jonathan Lundell
On Jan 29, 2012, at 10:44 AM, Ovidio Marinho wrote:

 Ctrl+C in Mac is Cmd+C

It is for copy, but not for quitting a process from the terminal. Control-C.

Massimo, are you sure web2py isn't running in the background when you do this? 
If you hit return, do you get a shell prompt? Control-C won't work then.

   
 
 
Ovidio Marinho Falcao Neto
 Web Developer
  ovidio...@gmail.com 
   ovidiomari...@itjp.net.br
  ITJP - itjp.net.br
83   8826 9088 - Oi
83   9334 0266 - Claro
 Brasil
   
 
 
 
 2012/1/29 Bruno Rocha rochacbr...@gmail.com
 the same for me, I always have to kill - 9 PID.
 
 But it only happens after some time.
 
 http://zerp.ly/rochacbruno
 
 Em 29/01/2012 14:27, Massimo Di Pierro massimo.dipie...@gmail.com 
 escreveu:
 
 I would like to post web2py 2.0 since we have no major pending issues.
 Yet there are two issues I would like to fix first:
 
 http://code.google.com/p/web2py/issues/detail?id=627
 
 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 could use some help. ;-)
 
 Massimo
 




Re: [web2py] help with js issue

2012-01-29 Thread Ricardo Pedroso
On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
massimo.dipie...@gmail.com 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.

Probably something wrong inside rocket.

see:
http://stackoverflow.com/questions/1148062/python-socket-accept-blocks-prevents-app-from-quitting

Regards,
Ricardo


Re: [web2py] help with js issue

2012-01-29 Thread Michele Comitini
Yes probably some system call hangs somewhere.


2012/1/29 Ricardo Pedroso rmdpedr...@gmail.com:
 On Sun, Jan 29, 2012 at 4:27 PM, Massimo Di Pierro
 massimo.dipie...@gmail.com 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.

 Probably something wrong inside rocket.

 see:
 http://stackoverflow.com/questions/1148062/python-socket-accept-blocks-prevents-app-from-quitting

 Regards,
 Ricardo