473,396 Members | 1,713 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,396 software developers and data experts.

Python Threads + MPI

Hello,

I'd like to use a Python MPI wrapper (pypar, pyMPI, or ScientificPython) but
I can't get threading to work. I'd like individual threads responsible for
MPI_Send and MPI_Recv. Things tend to either work perfectly or hang,
depending on ordering and sleep times.

My best guess is that the signal waking up the C-level MPI_Recv gets snagged
by another thread, which promptly ignores it. (This theory is based
entirely on a single sentence culled from the thread module documentation:
"Threads interact strangely with interrupts".

I've also tried surrounding the C call to MPI_Recv with
Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS, to no avail.

I guess this boils down to: can I put C blocking socket calls in their own
Python threads and expect them to work? If so, how?

Thanks much,

Barry Rountree

Sample code:

#!/opt/install/bin/mpipython

import Scientific.MPI as MPI
import time
import threading as T

class Sender(T.Thread):
def run(self):
count = 0
while True:
time.sleep(0.2)
print "Starting send of", count
MPI.world.send( "x"+str(count)+"x", 0, count )
print "Finished send of", count
count+=1
break;
class Recver(T.Thread):
def run(self):
count = 0
while True:
time.sleep(1.0)
print "Starting recv"
x = MPI.world.receiveString()
print "Received", x
count += 1

r = Recver()
s = Sender()
r.start()
s.start()

Jul 18 '05 #1
0 1142

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

Similar topics

0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.