Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66628
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <Nikolaus@rath.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'preferred.': 0.05; '(except': 0.07; 'socket': 0.07; 'pgp': 0.09; '(),': 0.16; 'fingerprint:': 0.16; 'fruit': 0.16; 'non-blocking': 0.16; 'reliably': 0.16; 'reproduce': 0.16; 'select.': 0.16; 'subject:ready': 0.16; 'well-known': 0.16; 'exception': 0.16; 'header:User-Agent:1': 0.23; 'ssl': 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'subject:) ': 0.29; 'mode': 0.30; 'catching': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'problem': 0.35; 'skip:s 30': 0.35; 'done.': 0.35; 'but': 0.35; 'url:org': 0.36; '(i.e.,': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'url:3': 0.61; 'situation': 0.65; 'flies': 0.84; 'encrypted': 0.91 |
| From | Nikolaus Rath <Nikolaus@rath.org> |
| To | python-list@python.org |
| Subject | Re: select(sock) indicates not-ready, but sock.recv does not block |
| References | <87a9dq9rh1.fsf@vostro.rath.org> |
| Mail-Copies-To | never |
| Mail-Followup-To | python-list@python.org |
| Date | Mon, 17 Feb 2014 17:29:42 -0800 |
| In-Reply-To | <87a9dq9rh1.fsf@vostro.rath.org> (Nikolaus Rath's message of "Sun, 16 Feb 2014 22:35:22 -0800") |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7112.1392686986.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392686986 news.xs4all.nl 2894 [2001:888:2000:d::a6]:58934 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66628 |
Show key headers only | View raw
Nikolaus Rath <Nikolaus@rath.org> writes:
> Hello,
>
> I have a problem with using select. I can reliably reproduce a situation
> where select.select((sock.fileno(),), (), (), 0) returns ((),(),())
> (i.e., no data ready for reading), but an immediately following
> sock.recv() returns data without blocking.
[...]
Turns out that I fell into the well-known (except to me) ssl-socket
trap: http://docs.python.org/3/library/ssl.html#notes-on-non-blocking-sockets
TL;DR: Relying on select() on an SSL socket is not a good idea because
some internal buffering is done. Better put the socket in non-blocking
mode and try to read something, catching the ssl.Want* exception if
nothing is ready.
Best,
-Nikolaus
--
Encrypted emails preferred.
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
»Time flies like an arrow, fruit flies like a Banana.«
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: select(sock) indicates not-ready, but sock.recv does not block Nikolaus Rath <Nikolaus@rath.org> - 2014-02-17 17:29 -0800
csiph-web