Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26922

Re: [Newbie] How to wait for asyncronous input

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.03; 'subject:: [': 0.03; 'exit': 0.07; 'missed': 0.09; 'subject:How': 0.09; 'may,': 0.09; 'port,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thread,': 0.09; 'timeout': 0.09; 'thread': 0.11; 'aug': 0.13; 'sat,': 0.15; 'blocks': 0.16; 'cleanly': 0.16; 'daemon,': 0.16; 'encountered.': 0.16; 'for,': 0.16; 'no...': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'why,': 0.16; 'bytes': 0.17; 'subject:] ': 0.19; 'pending': 0.20; 'putting': 0.20; 'runs': 0.22; 'header:X-Complaints-To:1': 0.28; '(unless': 0.29; 'sleep': 0.29; 'could': 0.32; 'says': 0.33; '+0200,': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'data,': 0.35; 'open': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'data.': 0.36; 'test': 0.36; 'should': 0.36; 'charset :us-ascii': 0.36; 'data': 0.37; 'behind': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'close': 0.63; 'different': 0.63; 'serial': 0.66; 'subject:wait': 0.84; 'dennis': 0.91; 'killed': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: [Newbie] How to wait for asyncronous input
Date Sat, 11 Aug 2012 14:21:30 -0400
Organization > Bestiaria Support Staff <
References <k03u8u$lv4$1@nnrp.ngi.it> <mailman.3191.1344640333.4697.python-list@python.org> <k050c7$l4q$1@nnrp.ngi.it>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-253-105-172.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3196.1344709296.4697.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1344709296 news.xs4all.nl 6987 [2001:888:2000:d::a6]:60669
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26922

Show key headers only | View raw


On Sat, 11 Aug 2012 09:07:51 +0200, pozz <pozzugno@gmail.com> declaimed
the following in gmane.comp.python.general:

> Il 11/08/2012 01:12, Dennis Lee Bieber ha scritto:
> > 	What you apparently missed is that serial.read() BLOCKs until data
> > is available (unless the port was opened with a read timeout set).
> > [...]
> >
> > 	serial.read() may, there for, be using select() behind the scenes.
> 
> Hmm..., so I could open the serial port with timeout=0 so the read(), 
> that runs in a different thread, would block forever, so putting the 
> thread in a sleep state until some bytes arrive.

	No... timeout=0 says "never block" -- it will return immediately
with or without any data.

	timeout=None is "block until data arrives"

http://pyserial.sourceforge.net/pyserial_api.html#classes

> 
> When the main thread wants to close the serial port, the receiving 
> thread can be killed (I don't know why, but I think it will be possible).

	If the thread is a daemon, it should die when the main program does.
Not sure what happens on port closure -- the pending read may return
with no data, which would be a condition the thread could test for and
exit cleanly when encountered.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[Newbie] How to wait for asyncronous input pozz <pozzugno@gmail.com> - 2012-08-10 23:25 +0200
  Re: [Newbie] How to wait for asyncronous input Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-10 19:12 -0400
    Re: [Newbie] How to wait for asyncronous input pozz <pozzugno@gmail.com> - 2012-08-11 09:07 +0200
      Re: [Newbie] How to wait for asyncronous input Hans Mulder <hansmu@xs4all.nl> - 2012-08-11 11:24 +0200
        Re: [Newbie] How to wait for asyncronous input Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-11 09:56 +0000
      Re: [Newbie] How to wait for asyncronous input Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-11 14:21 -0400

csiph-web