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

trying to read from dying disk

I have a python file that is trying to read raw data from a raw
partition on a dying dist, eg

f = file('/dev/sda')
f.seek(SOMEWHERE)
s = f.read(SOMEBYTES)

On some blocks, the read succeeds, on others it fails and an IOError is
thrown, and on others it appears to hang indefinitely and will not
respond to any attempt to kill it with 'kill -9 PID', etc.

Is there anyway to do a timeout read on this kind of file, or even to
kill the process once it hangs?

linux kernel 2.6.10
python 2.4.1

Thanks!
JDH

Jul 19 '05 #1
5 1818
jd*****@gmail.com writes:
I have a python file that is trying to read raw data from a raw
partition on a dying dist, eg [...] On some blocks, the read succeeds, on others it fails and an IOError is
thrown, and on others it appears to hang indefinitely and will not
respond to any attempt to kill it with 'kill -9 PID', etc.

Is there anyway to do a timeout read on this kind of file, or even to
kill the process once it hangs?

linux kernel 2.6.10
python 2.4.1


This sounds like a linux kernel question much more than a Python one.
Try a linux programmers' list?
John
Jul 19 '05 #2
> This sounds like a linux kernel question much more than a Python
one. Try a linux programmers' list?


Except that I'm writing a *python* program and trying to do a timeout
on the python *file* read operation. If I asked the question on the
kernel mailing list, they would rightlyfully assume I suspect that I
should be writing a C program, and then they would suggest c.l.py.

I'm currently attempting something with

http://www.python.org/doc/current/lib/node368.html

but it seems the read operation is ignoring these signals just as it is
ignoring my signals from the kill command -- perhaps unsurprisingly.

Perhaps there is no hope.
JDH

Jul 19 '05 #3
jd*****@gmail.com wrote:
Except that I'm writing a *python* program and trying to do a timeout
on the python *file* read operation.
and that *python* program is using the *C* runtime library, which calls
the *kernel* to do the work.
If I asked the question on the kernel mailing list, they would rightly-
fully assume I suspect that I should be writing a C program, and then
they would suggest c.l.py.


if you asked the question in an intelligent way, they would probably explain
what mechanisms the kernel provides for this purpose, and give you the
hints you need to solve this. in general, Python and C has no control what-
soever over what the operating system kernel does when reading data from
a disk. surely you know that?

</F>

Jul 19 '05 #4
jd*****@gmail.com writes:
I have a python file that is trying to read raw data from a raw
partition on a dying dist, eg

f = file('/dev/sda')
f.seek(SOMEWHERE)
s = f.read(SOMEBYTES)

On some blocks, the read succeeds, on others it fails and an IOError is
thrown, and on others it appears to hang indefinitely and will not
respond to any attempt to kill it with 'kill -9 PID', etc.

Is there anyway to do a timeout read on this kind of file, or even to
kill the process once it hangs?

linux kernel 2.6.10
python 2.4.1


Don't do this in Python. Dealing with flaky hardware is a maintenance
problem, and applications should report the error, and either exit or
proceed as best as possible after the error.

Use the "dd" command to extract as much good data as you can from the
failing disk.

Ok, if you *really* want to do this in Python, the answer is - you
need to provide more information. For instance, *where* does the
process hang? It's possible you've hung the process in an
uninterruptible state in the kernel. If so, you're screwed. You need
to find out where the process hangs (kernel, libc, python, etc.), and
if in the kernel what it's waiting on. In the latter case, you need to
ask on a Linux list.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #5
Hi All--

jd*****@gmail.com wrote:

I'm currently attempting something with

http://www.python.org/doc/current/lib/node368.html

but it seems the read operation is ignoring these signals just as it is
ignoring my signals from the kill command -- perhaps unsurprisingly.

Perhaps there is no hope.

Basically, if you are waiting for a hardware interrupt that never comes,
you are doomed. You can escape by rebooting; in dire cases the only way
out is to power down. One of the prime sources of zombie processes on
unix systems is users trying to interrupt (with ^C) a process that is
waiting for a hardware interrupt.

Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/worksh...oceedings.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
Jul 19 '05 #6

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

Similar topics

4
by: Cloud Burst | last post by:
I'm writing a javascript for my own use. I'd like it to read my disk to get some information. In particular, I want to find out how much disk is being used by some directories. At present, I'm...
3
by: Matt | last post by:
Hello I am trying to rebuild indexes on our DB, but I am running into an error I am not able to solve. Server: Msg 1105, Level 17, State 2, Line 1 Could not allocate space for object 'ft' in...
6
by: tgru | last post by:
Hello, Can anyone tell me how to backup read-only databases? I want to backup the secondary databases in my log shipping pairs. Thanks, TGru *** Sent via Developersdex...
1
by: Shrirang Ballal | last post by:
I am doing a project which requires to read the raw bytes from hard disk. It rrequires to access the partition table and then the individual partitions. I want some material related to these...
5
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or...
26
by: puzzlecracker | last post by:
It'd be interesting to compare the learning practices of c++ practitioners. I'll start with mine The C++ Programming Language C++ Primer Effective C++ More Effective C++ Effective STL The...
13
by: ragtag99 | last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch, comp.lang.c++ Im working with windows xp professional, NTFS and programming with MASM, c++ (free compiler) or visual basic 6.0...
8
by: dosworldguy | last post by:
I have been having a very peculiar issue from a long time. I have an application where multiple clients read from a shared set of files. When a record is changed, sometimes the win9x clients...
18
by: Linny | last post by:
Hi, Came across this article in the ComputerWorld website which has included C in the top ten dying languages. The top 10 dead (or dying) computer skills...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.