T
T
to_east2018-08-29 13:43:17
Python
to_east, 2018-08-29 13:43:17

Python communication between processes via Pipes?

Greetings Toaster Members!
Please explain one point, when using Pipes, there is one caveat in the documentation that data can be corrupted if two or more processes use the same end of the pipe.
That is, do I understand correctly that there should be one and only one consumer that calls recv () from the pipe, but there can be one or more Producers, despite the fact that the order of data arrival is unimportant.
Or still adhere to a strict Producer-Consumer scheme.
And one more question: the Producer sends data by calling the send() function, can the Consumer immediately read this data, or until the Producer closes the pipe (close()), the data will not be available to the Consumer?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2018-08-29
@deliro

That is, do I understand correctly that the consumer should be one and only one

Yes, it's written in the documentation. Otherwise, use Queue or its derivatives.

T
to_east, 2018-08-31
@to_east

A little off topic, but is it possible to use Queue along with asyncio, to prevent races in shared data, with several routes.
And another question. The other day I got acquainted offhand with asynchronous programming in Python, in fact everything is done in one thread, it just effectively distributes processor time between tasks (correct if it’s not right or inaccurate), so that’s why synchronization primitives are needed, such as Lock, Event, Condition , Semaphore (in asyncio module) if only one thread has access at a time?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question