100% CPU Usage when a tcp client is disconnected
Aaron Watters
aaron.watters at gmail.com
Thu Nov 22 10:29:05 EST 2007
On Nov 22, 9:53 am, Tzury Bar Yochay <Afro.Syst... at gmail.com> wrote:
> The following is a code I am using for a simple tcp echo server.
> When I run it and then connect to it (with Telnet for example) if I
> shout down the telnet the CPU tops 100% of usage and saty there
> forever....
> def handle(self):
> while 1:
> data = self.request.recv(1024)
> self.request.send(data)
> if data.strip() == 'bye':
> return
I forget exactly how the superclass works, but
that while 1 looks suspicious. Try chaning it
to
data = "dummy"
while data:
...
-- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=help+infinite+loop
More information about the Python-list
mailing list