473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Inter-process communication, how? Part 2

Hello,

just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.

I decided to go with sockets, thanks for replies, once more.

However, I would like to ask another thing: I would like to collect
everyting what the Workers print and display in Manager. Or, redirect
all Workers' stdout to stdio of Manager. If there was only one Worker
I could use a pipe, right? But if there are more than one Worker, what
to do? I found something called "named pipe" which seems rather
complicated. Then I thought I could somehow (how?) create a fake
(virtual) file object, redirect stdout of a Worket into it and from
there send the data to Manager via sockets. Please, what do you think?

Preferably, it should look like this:

--- Worker 1 ---
....some code...
print '123'

--- Manager ---
Worker 1: 123

--- Worker 2 ---
....some code...
print '456'

--- Manager ---
Worker 1: 123
Worker 2: 456

Thanks in advance!
Dec 23 '07 #1
7 1783
2007/12/22, ec*******@gmail.com <ec*******@gmail.com>:
Hello,

just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.

I decided to go with sockets, thanks for replies, once more.

However, I would like to ask another thing: I would like to collect
everyting what the Workers print and display in Manager. Or, redirect
all Workers' stdout to stdio of Manager. If there was only one Worker
I could use a pipe, right? But if there are more than one Worker, what
to do? I found something called "named pipe" which seems rather
complicated.
Named pipe is called FIFO, but they are not that complicated.
Then I thought I could somehow (how?) create a fake
(virtual) file object,
That is why it is called named pipe, because you will be using a
(especial) file in your filesystem to use as a pipe.
redirect stdout of a Worket into it and from
there send the data to Manager via sockets. Please, what do you think?

Preferably, it should look like this:

--- Worker 1 ---
...some code...
print '123'

--- Manager ---
Worker 1: 123

--- Worker 2 ---
...some code...
print '456'

--- Manager ---
Worker 1: 123
Worker 2: 456

Thanks in advance!
--
http://mail.python.org/mailman/listinfo/python-list
Manager would create and open the FIFO, Workers would open this same
FIFO. So workers write to FIFO and the manager reads from FIFO.

--
-- Guilherme H. Polo Goncalves
Dec 23 '07 #2
On Dec 23, 4:54 am, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
On Sat, 22 Dec 2007 17:56:05 -0800 (PST), ecir.h...@gmail.com declaimed
the following in comp.lang.python:
just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.

Never considered a graphical control process as a "backend"
before... Backend processing, to me, implies some sort of server without
a user interface.
However, I would like to ask another thing: I would like to collect
everyting what the Workers print and display in Manager. Or, redirect
all Workers' stdout to stdio of Manager. If there was only one Worker
I could use a pipe, right? But if there are more than one Worker, what
to do? I found something called "named pipe" which seems rather
complicated. Then I thought I could somehow (how?) create a fake
(virtual) file object, redirect stdout of a Worket into it and from
there send the data to Manager via sockets. Please, what do you think?

I'd forget about stdout as a data communication means... The parent
should probably set up a socket that accepts messages from any worker...
or create a "reply" socket for each worker, and pass the worker the port
on which the master expects to retrieve its output.
Ok, but how to redirect "print" statement into a socket?
>
"Named pipes" are, I think, a M$ Windows creation (though I think
the Amiga supported disjoint pipes by using "run program >pipe:name" and
"program <pipe:name" instead of "program | program"http://stason.org/TULARC/pc/amiga/faq/2-5-1-Using-PIPE-in-a-standard-...
-- "run program" being ~ "program &" in most UNIX-based shells)
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfr...@ix.netcom.com wulfr...@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-a...@bestiaria.com)
HTTP://www.bestiaria.com/
Dec 23 '07 #3
On Dec 23, 10:30 am, "Guilherme Polo" <ggp...@gmail.comwrote:
2007/12/22, ecir.h...@gmail.com <ecir.h...@gmail.com>:
Hello,
just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.
I decided to go with sockets, thanks for replies, once more.
However, I would like to ask another thing: I would like to collect
everyting what the Workers print and display in Manager. Or, redirect
all Workers' stdout to stdio of Manager. If there was only one Worker
I could use a pipe, right? But if there are more than one Worker, what
to do? I found something called "named pipe" which seems rather
complicated.

Named pipe is called FIFO, but they are not that complicated.
Then I thought I could somehow (how?) create a fake
(virtual) file object,

That is why it is called named pipe, because you will be using a
(especial) file in your filesystem to use as a pipe.
redirect stdout of a Worket into it and from
there send the data to Manager via sockets. Please, what do you think?
Preferably, it should look like this:
--- Worker 1 ---
...some code...
print '123'
--- Manager ---
Worker 1: 123
--- Worker 2 ---
...some code...
print '456'
--- Manager ---
Worker 1: 123
Worker 2: 456
Thanks in advance!
--
http://mail.python.org/mailman/listinfo/python-list

Manager would create and open the FIFO, Workers would open this same
FIFO. So workers write to FIFO and the manager reads from FIFO.

--
-- Guilherme H. Polo Goncalves
What I don't like about FIFO, is that on Unix they are persistent
files. So whatever happens to Manager they would stay there...
I was just wondering if there's another way of doing the above and if
not, I would probably go with FIFO. Thanks!
Dec 23 '07 #4
ec*******@gmail.com wrote:
What I don't like about FIFO, is that on Unix they are persistent
files. So whatever happens to Manager they would stay there...
Nope. /tmp exists. Many distributions delete /tmp contents on
reboot.
I was just wondering if there's another way of doing the above and
if not, I would probably go with FIFO. Thanks!
Didn't you write you went with sockets?

Regards,
Björn

--
BOFH excuse #354:

Chewing gum on /dev/sd3c

Dec 23 '07 #5
ec*******@gmail.com wrote:
Ok, but how to redirect "print" statement into a socket?
Create an object that has the socket's send-or-what-it's-called
method as a member called "write" and bind this object to
sys.stdout. Alternatively, you can use the "print "text" >object"
syntax (see language reference).

Regards,
Björn

--
BOFH excuse #116:

the real ttys became pseudo ttys and vice-versa.

Dec 23 '07 #6
ec*******@gmail.com wrote:
Hello,

just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.

I decided to go with sockets, thanks for replies, once more.

However, I would like to ask another thing: I would like to collect
everyting what the Workers print and display in Manager. Or, redirect
all Workers' stdout to stdio of Manager. If there was only one Worker
I could use a pipe, right? But if there are more than one Worker, what
to do? I found something called "named pipe" which seems rather
complicated. Then I thought I could somehow (how?) create a fake
(virtual) file object, redirect stdout of a Worket into it and from
there send the data to Manager via sockets. Please, what do you think?
Take a look at

http://aspn.activestate.com/ASPN/Coo...n/Recipe/52296

which does this. I wouldn'd do it quite that way; read the notes
on the article for some criticism. But it's an approach that works.

One can get fancier. I wrote a system under QNX where each
real time process had its text output labeled, timestamped, and transmitted
using QNX interprocess communication to a lower priority logging process
on a different machine. Text output never blocked; if a queue
filled, "..." appeared in the log file. That's a special real-time situation.

John Nagle
Dec 23 '07 #7
Sunday 23 December 2007 Tarihinde 03:56:05 yazmıştı:
Hello,

just to recap: last time I asked how to do an interprocess
communitation, between one Manager process (graphical beckend) and
some Worker processes.
Why just dont use dbus , and then have a drink :)
Feb 16 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tertius Cronje | last post by:
Hi All, Q: Is it possible for a thread on SocketServer.ThreadingTCPServer to get the socket info of *other* open thread/s and use that info to send data to the accepting client? I wrote a...
1
by: Thierry Marneffe | last post by:
Hello Suppose a database Db1 with tables tl1 and tl2 and a second database db2 with tables tl3 et tl4. Is it possible to make a join between tables of the two databases ? As for example,...
1
by: David M. Karr | last post by:
I've been asked to help debug a complex problem involving inter-frame references, so I just want to understand the elements involved with this. Apparently, there is a page with multiple frames,...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
6
by: les | last post by:
Here's a class which uses 2.0 generics to implement an inter-thread message queue in C#. Any number of threads can post and read from the queue simultaneously, and the message object can be any...
7
by: Sumedh | last post by:
Hi everyone There is a C# project which calls C++/CLI dll to be able to call native C++ including templates. But the C++/CLI code itself also requires the C# dll to get the types. For example: ...
1
by: Laurence | last post by:
Hi folks, As I konw: database partition (aka data partition?), the database can span multiple machines; table partition, the data within a table can seperate by certain condition. How about...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
0
by: rkprasad | last post by:
I am able to create BASIC-CLEAR-INTEGRATED sql http endpoint and consume it on a LAN. But i am not able to consume the created endpoint on inter domain network. If i create endpoint on a server...
1
by: rsennat | last post by:
Hi, what is the order of the libraries in the Makefile, for linking inter dependent libraries. i'm getting linker error for the following scenario. I have lib1.a and lib2.a, with which lib1.a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.