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


Groups > comp.lang.python > #99284

Re: Bi-directional sub-process communication

From Cameron Simpson <cs@zip.com.au>
Newsgroups comp.lang.python
Subject Re: Bi-directional sub-process communication
Date 2015-11-24 08:45 +1100
Message-ID <mailman.77.1448316242.2291.python-list@python.org> (permalink)
References <5A3A00A6-CFD2-42FC-9C87-6F8C6861F775@ravnalaska.net>

Show all headers | View raw


On 23Nov2015 12:22, Israel Brewster <israel@ravnalaska.net> wrote:
>On Nov 23, 2015, at 11:51 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> Concurrency, ugh.

I'm a big concurrency fan myself.

>> It's probably better just to have a Condition/Event per thread and
>> have the response thread identify the correct one to notify, rather
>> than just notify a single shared Condition and hope the threads wake
>> up in the right order.
>
>Tell me about it :-) I've actually never worked with conditions or 
>notifications (actually even this bi-drectional type of communication is new 
>to me), so I'll have to look into that and figure it out. Thanks for the 
>information!

I include a tag with every request, and have the responses include the tag; the 
request submission function records the response hander in a mapping by tag and 
the response handing thread looks up the mapping and passes the response to the 
right handler.

Works just fine and avoids all the worrying about ordering etc.

Israel, do you have control over the protocol between you and your subprocess?  
If so, adding tags is easy and effective.

Cheers,
Cameron Simpson <cs@zip.com.au>

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


Thread

Re: Bi-directional sub-process communication Cameron Simpson <cs@zip.com.au> - 2015-11-24 08:45 +1100

csiph-web