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

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: [Newbie] How to wait for asyncronous input
Date 2012-08-11 14:21 -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>
Newsgroups comp.lang.python
Message-ID <mailman.3196.1344709296.4697.python-list@python.org> (permalink)

Show all headers | 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