473,800 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(SOMEWHER E)
s = f.read(SOMEBYTE S)

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 1851
jd*****@gmail.c om 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.c om 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.c om 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(SOMEWHER E)
s = f.read(SOMEBYTE S)

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.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #5
Hi All--

jd*****@gmail.c om 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
1949
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 pasting the output of a command line "du -s" into some text fields and using that information. As I understand it, for security reasons javascript isn't allowed to do disk input/output. Please correct me if I'm wrong.
3
3120
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 database 'HastaDemo' because the 'PRIMARY' filegroup is full. The statement has been terminated.
6
17821
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 http://www.developersdex.com ***
1
6292
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 issues. If someone can suggest of a book then that is also good. All the books I have seen are related to the GUI design. Waiting for reply, Thank you
5
5120
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 Partition we are using ReadFile , WriteFile and setFilePointerEx to read and write the sectors and we are reading/writing 102400 sectors together, even we have reduced the sectors still it is not able to read or write, our program is working fine...
26
3672
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 C++ Standard Library : A Tutorial and Reference (most of it) Exceptional C++
13
4883
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 === question 1 Primarily Im trying to design a program that has full control over a hard disk. What it needs to do is find out what sectors haven't been
8
2344
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 still read the old data (if it was read earlier) and this is causing data corruption. WinNT clients inlcuding windows2000 & XP do not have this issue. The program is complied in VC++, console mode. I am unable to understand the cause. I flush the...
18
1916
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 http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=9020942 To quote from the article <snip>
0
9551
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,...
0
10504
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, 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...
1
10251
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,...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
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();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3
2945
bsmnconsultancy
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...

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.