473,396 Members | 1,923 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.

Threads blocking on OpenBSD w/ Python 2.4.2

I'm attempting to write a faily simple threaded app that fires off a
thread to select() on a FIFO while the main loop handles data read from
that pipe and a few other tasks. For some reason, calls to
time.sleep() seem to block until the first time data is dumped into the
pipe. Clearly, I could work around this quite easily by "priming the
pipe" as it were with a bit of garbage data. However, I'd rather
understand the problem.

Here's a code snippet:

===========================================
ipList = []

def readPipe(pipeName):
p = file(pipeName, 'r')
while True:
x = select.select([p.fileno()], [], [])
dataLine = p.readline()
ipList.append(dataLine)

def main():
if not os.path.exists('bob'):
os.mkfifo('bob')
print "FIFO created."
print "Starting thread."
thread.start_new_thread(readPipe, ('bob',))
print "Thread started."
while True:
print time.time()
time.sleep(1)
===========================================

On Linux and OS X, this behaves as expected. Running the code
immediately produces output like this:

tarja:~ ben$ ./mycapd
Starting thread.
Thread started.
1158608481.67 []
1158608482.67 []
1158608483.67 []
....

But on OpenBSD I get this:

[ ben@rampart ] $ ./mycapd
Starting thread.
Thread started.
1158608528.5 []

And there it hangs until I dump some data into the fifo. Then it runs
as expected, dumping out a timestamp every second.

So the question is this: Am I doing something wrong or is there a
problem on OpenBSD?

-Ben

Sep 18 '06 #1
1 1391

in****@gmail.com wrote:
I'm attempting to write a faily simple threaded app that fires off a
thread to select() on a FIFO while the main loop handles data read from
that pipe and a few other tasks. For some reason, calls to
time.sleep() seem to block until the first time data is dumped into the
pipe. Clearly, I could work around this quite easily by "priming the
pipe" as it were with a bit of garbage data. However, I'd rather
understand the problem.
I've verified the same behavior with Python 2.5.

-Ben

Sep 19 '06 #2

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

Similar topics

5
by: Bart Nessux | last post by:
Could someone explain the concept of threads and how I might use them in Python? I was a math major, not a CS major (theory instead of practice). Most of my programming knowledge has grown out of...
3
by: Noah | last post by:
I'm getting configure warnings and make errors when I try to build Python 2.3.4 under OpenBSD 3.5. I don't see anything in the README under "Platform specific note" for OpenBSD. I tried opening...
29
by: Jeffrey Maitland | last post by:
Hello all, I am in the process of writing a multithreading program and what I was wondering is a sleep command in an executing function will affect the threads below it? Here is a basic example...
1
by: Geoff | last post by:
Hi! I'm wanting to use openbsd to run a webserver because of its high security. The website is written in python. Before I was using linux with apache 2 and mod_python and this worked well. My...
2
by: Kevin Walzer | last post by:
I'm trying to decide whether I need threads in my Tkinter application or not. My app is a front end to a command-line tool; it feeds commands to the command-line program, then reads its output and...
1
by: nazgul | last post by:
Hi all, I have an app that runs on multiple boxes. On my slackware box, running Python 2.5.1, top shows this: Mem: 1002736k total, 453268k used, 549468k free, 31392k buffers Swap: ...
18
by: Jon Slaughter | last post by:
"Instead of just waiting for its time slice to expire, a thread can block each time it initiates a time-consuming activity in another thread until the activity finishes. This is better than...
5
by: eliben | last post by:
Hello, I have a small wxPython application. Today I was trying to add some RPC capability to it, so I implemented an instance of SimpleXMLRPCServer that runs in a separate thread when invoked...
7
by: Brendon Costa | last post by:
Hi all, I have a small python project i am working on. Basically i always have two threads. A "Read" thread that sits in a loop reading a line at a time from some input (Usually stdin) and then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.