Message from discussion
can not get lost connection msg?
network library" <gevent@googlegroups.com>
Received: by 10.52.32.66 with SMTP id g2mr21354265vdi.5.1335575066106;
Fri, 27 Apr 2012 18:04:26 -0700 (PDT)
X-BeenThere: gevent@googlegroups.com
Received: by 10.220.155.11 with SMTP id q11ls1089975vcw.4.gmail; Fri, 27 Apr
2012 18:04:25 -0700 (PDT)
Received: by 10.52.23.146 with SMTP id m18mr21299639vdf.7.1335575065101;
Fri, 27 Apr 2012 18:04:25 -0700 (PDT)
Received: by 10.52.23.146 with SMTP id m18mr21299637vdf.7.1335575065088;
Fri, 27 Apr 2012 18:04:25 -0700 (PDT)
Return-Path: <gam...@gmail.com>
Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44])
by gmr-mx.google.com with ESMTPS id cz20si1195158vdb.0.2012.04.27.18.04.25
(version=TLSv1/SSLv3 cipher=OTHER);
Fri, 27 Apr 2012 18:04:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of gam...@gmail.com designates 209.85.212.44 as permitted sender) client-ip=209.85.212.44;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gam...@gmail.com designates 209.85.212.44 as permitted sender) smtp.mail=gam...@gmail.com; dkim=pass header...@gmail.com
Received: by vbbez10 with SMTP id ez10so1131438vbb.31
for <gevent@googlegroups.com>; Fri, 27 Apr 2012 18:04:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type;
bh=+lonGv23ttSOEPh8JOPcNy9z5x4rOkgi2dSG9ErgW/k=;
b=H9cwE8kFoySJkC4UahqMyc8wyPe3PMJQLgwn8GAlkHmcKG2mOg80ADiL/Mgs8pAiML
KJEVTNkGmz0G8kZ4CW/A48zYviUG4itAtg42QSRp6VLqCFs9pazREDjzecBHHRvxf7Jb
LT/FvghiqDP4nnsJuMVHI5LUXtHZemg+jLC6zX2DB8Zxv0BQWm9/L1XCiVKN6Qbv+yo5
BbE2UrV9EWQndVha/W5xVjxjY6DPTUlZZdSKkGra/paMRSqFQPAWnRQ9mEIdJK/7oOTu
TDUXfCn7YSfczxF+vkNsIfiuV1tJmKaFNgVZyg+FJnnv9clUXwTvv6t2q7lwdLJY8v2R
4f7A==
MIME-Version: 1.0
Received: by 10.52.100.9 with SMTP id eu9mr8763102vdb.28.1335575064892; Fri,
27 Apr 2012 18:04:24 -0700 (PDT)
Received: by 10.52.29.227 with HTTP; Fri, 27 Apr 2012 18:04:24 -0700 (PDT)
In-Reply-To: <CAGrzxyvKT_rhUOBW7McX+4GR59PF6qb49D69_CChjiTH+Sj...@mail.gmail.com>
References: <CAGrzxyvKT_rhUOBW7McX+4GR59PF6qb49D69_CChjiTH+Sj...@mail.gmail.com>
Date: Sat, 28 Apr 2012 09:04:24 +0800
Message-ID: <CA+o6pZZ2RKtPHx1SZUULUVvE5Xnq9usUj7viHoVV6rksaLd...@mail.gmail.com>
Subject: Re: [gevent] can not get lost connection msg?
From: cat street <gam...@gmail.com>
To: gevent@googlegroups.com
Content-Type: multipart/alternative; boundary=20cf307f37b65053e504beb2cdc6
--20cf307f37b65053e504beb2cdc6
Content-Type: text/plain; charset=ISO-8859-1
Maybe like this:
while True:
try:
data = sock.recv(1024)
if not data: break
except socket.error:
break
2012/4/27 sleepd <slee...@gmail.com>:
> hi, I am trying to write a server by gevent, and I found that sometimes my
> server can not got the connection lost signal when client close the
> connection. this is my code and anyone can help me find out where is the
> problem?
>
> server runs on Linux, but develop on windows.
>
> def _listener(self, sock):
> while True:
> # gevent will raise a error when connection lost at windows,
so
> use "try"
> try:
> data = sock.recv(1024)
> except socket.error, e:
> break
> if not data:
> break
> self._localServer.lostConnect(self)
--
HomePage: cat.appspot.com
--20cf307f37b65053e504beb2cdc6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Maybe like this:<br><br>=A0 =A0 while True:<div>=A0 =A0 =A0 =A0 try:<br>=A0=
=A0 =A0 =A0 =A0 =A0 data =3D sock.recv(1024)<div>=A0 =A0 =A0 =A0 =A0 =A0 i=
f not data: break<br>=A0 =A0 =A0 =A0 except socket.error:</div><div>=A0 =A0=
=A0 =A0 =A0 =A0 break</div><div><br><br>2012/4/27 sleepd <<a href=3D"ma=
ilto:slee...@gmail.com">slee...@gmail.com</a>>:<br>
> hi, I am trying to write a server by gevent, and I found that sometime=
s my<br>> server can not got the connection lost signal when client clos=
e the<br>> connection. this is my code and anyone can help me find out w=
here is the<br>
> problem?<br>><br>> server runs on=A0Linux, but=A0develop=A0on wi=
ndows.<br>><br>> def _listener(self, sock):<br>> =A0 =A0 =A0 =A0 w=
hile True:<br>> =A0 =A0 =A0 =A0 =A0 =A0 # gevent will raise a error when=
connection lost at windows, so<br>
> use "try"<br>> =A0 =A0 =A0 =A0 =A0 =A0 try:<br>> =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 data =3D sock.recv(1024)<br>> =A0 =A0 =A0 =
=A0 =A0 =A0 except socket.error, e:<br>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
break<br>> =A0 =A0 =A0 =A0 =A0 =A0 if not data:<br>> =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 break<br>
> =A0 =A0 =A0 =A0 self._localServer.lostConnect(self)<br><br><br><br>-- =
<br>HomePage: <a href=3D"http://cat.appspot.com">cat.appspot.com</a><br></d=
iv></div>
--20cf307f37b65053e504beb2cdc6--