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


Groups > comp.lang.python > #96769

Re: pyserial and threads

From pozz <pozzugno@gmail.com>
Newsgroups comp.lang.python
Subject Re: pyserial and threads
Date 2015-09-17 15:26 +0200
Organization A noiseless patient Spider
Message-ID <mteev9$tg1$3@dont-email.me> (permalink)
References <mte0vh$alh$1@dont-email.me> <mailman.691.1442482931.8327.python-list@python.org>

Show all headers | View raw


Il 17/09/2015 11:42, Chris Angelico ha scritto:
> On Thu, Sep 17, 2015 at 7:28 PM, pozz <pozzugno@gmail.com> wrote:
>> At startup I open the ports and create and start a thread to manage the
>> receiving. When a byte is received, I call the .write() method for all the
>> other ports.
>>
>> It works, but sometimes it seems to block. I think I haven't used correctly
>> the threads.
>>
>
> Seems a fairly reasonable model. From what I'm seeing here, you start
> a thread to read from each serial port, but then those threads will
> make blocking writes to all the other serial ports. Is it possible
> that one of them is getting full?
>
> When I do this kind of thing with TCP/IP sockets, I usually end up
> having to go non-blocking in both directions, and maintaining a buffer
> of unsent text for each socket. You may find that you need to do the
> same thing here.

How to have a non-blocking write?

Maybe the problem happens when port 1 thread is in .read() (it blocks 
for 1 second) and port 2 thread tries to write one byte (that was just 
received) to port 1.


> Where's the code getting blocked?

I don't knwo exactly. I can only see no more bytes are received on COM 
ports.

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


Thread

pyserial and threads pozz <pozzugno@gmail.com> - 2015-09-17 11:28 +0200
  Re: pyserial and threads Chris Angelico <rosuav@gmail.com> - 2015-09-17 19:42 +1000
    Re: pyserial and threads pozz <pozzugno@gmail.com> - 2015-09-17 15:26 +0200
      Re: pyserial and threads Chris Angelico <rosuav@gmail.com> - 2015-09-17 23:45 +1000
  Re: pyserial and threads alister <alister.nospam.ware@ntlworld.com> - 2015-09-17 12:00 +0000
    Re: pyserial and threads Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-17 09:04 -0400
      Re: pyserial and threads pozz <pozzugno@gmail.com> - 2015-09-17 15:23 +0200
    Re: pyserial and threads pozz <pozzugno@gmail.com> - 2015-09-17 15:22 +0200

csiph-web