If you have zeromq already installed and available, it's another
option...possibly also heavy-handed compared to a PIPE.

On Mon, Mar 9, 2015 at 4:12 PM, Justin Israel <[email protected]>
wrote:

> Here is an example of communicating via stdin between the parent and child
> process:
> https://gist.github.com/justinfx/b94fab9d1f056380cb28
>
> You launch the parent, and it will launch the process, using a PIPE for
> stdin. The child then starts a thread and reads lines from stdin. The
> parent can communicate to it whenever it wants.
>
> As for the topic on sockets, that is what http is using under the hood,
> with http being the protocol that is used for the handshaking pattern and
> the req-reply message pattern (i.e. there is a header and a body and it
> happens this way and that way). Dropping down to sockets just means you
> make your own connection, to a port on the local machine in this particular
> case, and speak your own protocol, whether that is just writing lines, or
> sending json or pickle. And you don't need an external web framework
> dependency to do that. It has some similar caveats to the http approach as
> well. For instance, the default port for a web server is 80. A given user
> may or may not have permissions for an application they launch to bind to
> port 80, which means you have to pick a non-privileged port. There is also
> the similar situation where port 80 is already in use by a local web server
> and not available to you, so you have to pick a random one. And in this
> case, you have to make sure to communicate the right port number to the
> child, which you could do through an env key like "PARENT_PORT=12345".
>
> A pipe is like a phone call between two people. You aren't going to clash
> because each parent/child will have their "private line". Another caveat of
> your original solution is that you might run into a problem where you
> launch two instances of the parent. They both can't bind to the same port
> to serve the http endpoints. Also if there is more than one child somehow
> (not sure exactly how things get launched), they all would try and
> communicate to the same http server that was able to bind to the port, and
> each child would pull message items from the queue so they would split the
> messages like a work pipeline.
>
> All in all, the pipe approach would probably be easiest to manage.
>
>
>
> On Tue, Mar 10, 2015 at 7:28 AM Marcus Ottosson <[email protected]>
> wrote:
>
>> But flask is an extremely heavy handed approach to getting to processes
>> talking on the same machine.
>>
>> That’s exactly what I’ve got, and can understand it’s heavy-handed.
>>
>> I did have a closer look at subprocess and pipes, but quickly remembered
>> what my struggles were last time I tried. Maybe in time I’ll transition
>> that way, because at the moment it’s above my head.
>>
>> I have no experience with sockets either; I assumed it was the same as
>> communicating via GET and POST using urllib2.
>>
>> At the end of the day, I have two processes, on the same machine, in a
>> parent/child relationship, passing plain-old-data between each other
>> (one-way, mostly) using Flask and HTTP requests. If you find the time for
>> an example of an alternative, that would be really great.
>>
>> Best,
>> Marcus
>> ​
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODhJmYKa62Dv4gkTwQyqaj1OJ__bAgrB1Kw2-%2BkS71sBA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODhJmYKa62Dv4gkTwQyqaj1OJ__bAgrB1Kw2-%2BkS71sBA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2coSA4qCSpj%2BXBkAaGA6NBbbeRzNqbh01tBUxcDpK0GA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2coSA4qCSpj%2BXBkAaGA6NBbbeRzNqbh01tBUxcDpK0GA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Tony

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAJhmvsSQ9LS2RRVaWm_yzkbBn%2BXsrMtgyhj%2BvafVdA%3DFWtCocA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to