Hello,every one, I meet a question:
in my old script, I usually use os.popen2() to get info from standard
unix(LinuX) program like ps,ifconfig...
Now, I write a OO-based programme, I still use os.popen2( check
whether mplayer still working via ps command ), but some things I got
the following message:
Traceback (most recent call last):
File "./mkt.py", line 351, in loop_timeout
self.process(se lf.event.get_ne xt())
File "./mkt.py", line 361, in process
self.player.pla y(command[1])
File "./mkt.py", line 107, in play
if self.is_playing ():
File "./mkt.py", line 78, in is_playing
info = rfd.readlines()
IOError: [Errno 4] Interrupted system call
why? Thank you!
--
LinuX Power 7 22229
In article <ma************ *************** ************@py thon.org>,
Marco <ma***@waven.co mwrote:
Hello,every one, I meet a question:
in my old script, I usually use os.popen2() to get info from standard
unix(LinuX) program like ps,ifconfig...
Now, I write a OO-based programme, I still use os.popen2( check
whether mplayer still working via ps command ), but some things I got
the following message:
Traceback (most recent call last):
File "./mkt.py", line 351, in loop_timeout
self.process(se lf.event.get_ne xt())
File "./mkt.py", line 361, in process
self.player.pla y(command[1])
File "./mkt.py", line 107, in play
if self.is_playing ():
File "./mkt.py", line 78, in is_playing
info = rfd.readlines()
IOError: [Errno 4] Interrupted system call
why? Thank you!
Some signal was evidently delivered to your process, while
you had a "slow" read in progress (i.e., not from disk.)
The read was interrupted to deliver the signal.
Look for signal handlers in your code and any library functions
you call. I hope library functions don't have signal handlers,
sounds like a horrible idea to me. If your code has a signal
handler for SIGCHLD, try to get rid of that - the handler itself
is causing your problem.
OO (Object Oriented?) doesn't have anything to do with the problem,
that I can think of.
Donn Cave, do**@u.washingt on.edu
i'm getting the same error when trying to read results from popen2
within a pyQt window. is this a threading issue? is my pyQt window
responsible for interrupting the read? i'm fairly new to python so
i'm struggling to figure this out. can you recommend any possible
methods of preventing this? for instance, could acquiring a thread
lock before calling popen solve the problem?
thanks,
chad
En Thu, 15 Feb 2007 23:57:29 -0300, <ch*****@gmail. comescribió:
i'm getting the same error when trying to read results from popen2
within a pyQt window. is this a threading issue? is my pyQt window
responsible for interrupting the read? i'm fairly new to python so
i'm struggling to figure this out. can you recommend any possible
methods of preventing this? for instance, could acquiring a thread
lock before calling popen solve the problem?
I dont know pyQt but in general, blocking operations (like a syncronous
read) can return EINTR when a signal arrives in the middle. Just retrying
the operation would be enough; by example, if you have a read() inside a
loop, just ignore the exception and continue.
--
Gabriel Genellina
In article <11************ **********@l53g 2000cwa.googleg roups.com>, ch*****@gmail.c om wrote:
i'm getting the same error when trying to read results from popen2
within a pyQt window. is this a threading issue? is my pyQt window
responsible for interrupting the read? i'm fairly new to python so
i'm struggling to figure this out. can you recommend any possible
methods of preventing this? for instance, could acquiring a thread
lock before calling popen solve the problem?
No.
Did you look at the text of the post you responded to here?
What do you think about that advice? Do you have any
signal handlers?
Donn Cave, do**@u.washingt on.edu
i don't have any signal handlers in my code, but i have no idea what
is going on in the internals of the pyQt framework that i'm using for
the GUI.
as far as simply ignoring the exception, that does not seem to work.
for instance, here's some code i've tried:
p = subprocess.Pope n('mycommand', shell=True, stdin=subproces s.PIPE,
stdout=subproce ss.PIPE, close_fds=True)
output = ''
tries = 0
while tries < 12:
try:
tries = tries+1
print "retrieving results"
output = p.stdout.readli nes()
except IOError:
print "IOError! try %s" % tries
print "output:", output
#time.sleep(1)
else:
print "Great Success"
print "output:", output
break
--printout: successful run--
retrieving results
Great Success
output: []
--printout: IOError run--
retrieving results
IOError! try 1
output:
retrieving results
Great Success
output: []
if the first try raises an error output does not get set and then the
second try succeeds but returns an empty list when it should return
results. moving the Popen inside the loop isn't an option either,
because, in addition to returning results, the command performs an
action which should only run once.
sorry if i'm missing something obvious here, i'm a python newb.
-chad
In article <11************ **********@k78g 2000cwa.googleg roups.com>, ch*****@gmail.c om wrote:
i don't have any signal handlers in my code, but i have no idea what
is going on in the internals of the pyQt framework that i'm using for
the GUI.
as far as simply ignoring the exception, that does not seem to work.
for instance, here's some code i've tried:
p = subprocess.Pope n('mycommand', shell=True, stdin=subproces s.PIPE,
stdout=subproce ss.PIPE, close_fds=True)
output = ''
tries = 0
while tries < 12:
try:
tries = tries+1
print "retrieving results"
output = p.stdout.readli nes()
except IOError:
print "IOError! try %s" % tries
print "output:", output
#time.sleep(1)
else:
print "Great Success"
print "output:", output
break
....
if the first try raises an error output does not get set and then the
second try succeeds but returns an empty list when it should return
results. moving the Popen inside the loop isn't an option either,
because, in addition to returning results, the command performs an
action which should only run once.
sorry if i'm missing something obvious here, i'm a python newb.
No, actually this is somewhat non-obvious, if I'm right.
You can't use readlines() like that, it's a Python
thing that evidently loses some or all of its buffered
data, and you start over from scratch.
Instead, probably the simplest thing would be to implement
your own readlines around that restart loop, actually reading
one line at a time and appending to the line list. I'm not
sure that's totally bulletproof - probably will work, but
if you need a sure thing, I would go to UNIX I/O (posix.read),
in a loop, and then split the concatenated results by newline.
Or, of course if you could shut down the signals...
Donn Cave, do**@u.washingt on.edu
En Fri, 16 Feb 2007 18:07:40 -0300, <ch*****@gmail. comescribió:
i don't have any signal handlers in my code, but i have no idea what
is going on in the internals of the pyQt framework that i'm using for
the GUI.
p = subprocess.Pope n('mycommand', shell=True, stdin=subproces s.PIPE,
stdout=subproce ss.PIPE, close_fds=True)
output = p.stdout.readli nes()
There is a problem using a high-level approach like readlines(): *either*
there is no exception, and you get all the output, *or* there is an
exception and you get nothing. readlines() can't return a partial result
*and* raise an exception at the same time. (Perhaps EINTR should be a
special case, but currently it's converted into an IOError like all other
error codes).
You could read one character at a time with read(1) (to minimize the risk
of data loss), or simply use a temporary file: "mycomand >temporary" and
then read its contents. This appears to be the safest way.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jakub Moscicki |
last post by:
Hello,
A small problem: I get a signal during a system call (from xmlrpclib ->
httplib) and an exception "IOError: Interrupted system call" is
raised (this is system dependant, on other machine it does not raise this
exception). I have my own signal handler so I want to simply ignore this
exception if it occures. But for a reason mysterious to me I cannot catch
this exception in the main's program try block.
Anybody knows what's...
|
by: Sylwia |
last post by:
Hi!
I have implemented a Python services. It behaves as a supervisor for
log files.
If the space used by log files is bigger than a given upper limit,
then it starts to delete log files until the space is less than a
given lower limit. It checks the space every 1000 secs. After that it
falls asleep. It is configured to start up automatically on system
boot. Everything works ok except one thing ... :( The service should
run even when I...
|
by: Sylwia |
last post by:
Hi!
I need your help...
I have the following problem. I've implemented the python Windows
Service which behaves like a log supervisor. If the space
used by log files is bigger than a given upper limit, then it starts
to delete log files until the space is less than a given
|
by: Nazgul |
last post by:
Hi!
Sorry if I posted it twice...
I need your help...
I have the following problem. I've implemented the python Windows Service
which behaves like a log supervisor. If the space
used by log files is bigger than a given upper limit, then it starts to
delete log files until the space is less than a given
lower limit. I configured the service to start up automatically on system
boot. The script checks the space used by log files
every 1000...
|
by: Nigel King |
last post by:
I have a problem with the logging module.
It reports a Broken Pipe error after outputing to the log file
occasionally (5%). This does not appear to happen on Mac OSX using
current finked python (2.3.3) but does appear to occur on Python 2.3.4
running on a very old Redhat Linux xxxxx 2.2.14-5.0 #1 Tue Mar 7
21:07:39 EST 2000 i686. The actual logged error follows my signature.
Note that "files used:-" has been sent to the file.
From a...
| |
by: nicogrubert |
last post by:
Hi there
I am trying to read the content of a really large text file (1GByte) and I get
the following exception if I try to call readlines() on the opened textfile:
IOError: Cannot allocate memory
This is my code:
INFILE="/home/myuser/myfile"
|
by: Marco |
last post by:
Hello,every one, I meet a question:
in my old script, I usually use os.popen2() to get info from standard
unix(LinuX) program like ps,ifconfig...
Now, I write a OO-based programme, I still use os.popen2( check
whether mplayer still working via ps command ), but some things I got
the following message:
Traceback (most recent call last):
|
by: ashish |
last post by:
Hi All,
I wanted to know how to handle events like 'logoff' in the main thread
so that any process which is being run by svcDoRun method of service
does not get 'interrupted function call' exception.
I am posting a very simple service program , and i want to know that
is there a way to handle such interrupts without explicitly calling
try except block over blocking calls.
Here is the example which is getting interrupted exception at...
|
by: Gilles Ganault |
last post by:
Hello
I'm trying to use urllib to download web pages with the GET method,
but Python 2.5.1 on Windows turns the URL into something funny:
========
url = "amazon.fr/search/index.php?url=search"
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |