[Tutor] intercepting and recored I/O function calls

Alan Gauld alan.gauld at btinternet.com
Fri Sep 17 18:47:18 CEST 2010


"Jojo Mwebaze" <jojo.mwebaze at gmail.com> wrote

> My applogies to begin with,  it seems i didnt state my problem 
> clearly for
> this particular case - perharps I/O was not the best way to describe 
> my
> problem.

Hmmm, perhaps not! :-)

> Specifically, i would like to track all inputs/output to 
> modules/functions -
> if a module  retrieved and used files and run some analysis on them 
> and
> produced other files in return, i would like to take not of this. 
> i.e what i
> want is to recored input and outputs to a module. and also to record 
> all
> paramaters, attribute vaules used by the same module.

You could do some of that with static code analysis I think.
And while I'm sure you could do this by delving into the innards of
Python it will be a lot of work and I'm not sure what the impact
would be on the performance of your code.

> I thought i would build a wrapper around the orignial python program 
> or
> probably pick this information at OS level.

I don't think the OS will have much of what you want you will need to
look inside Python itself I think. It might be best to tweak the 
interpreter
to trap those details but that would need to be done in C. And it 
would
slow the interpreter down for everything.

The OS knows how your app is interacting with the network and file
system but it doesn't know about the interactons between modules
inside Python. Maybe there are some of the more obscure modules
in the standard library that allow monitoring. The debug and profiling
modules might yield clues too.

An interesting challenge and I'm not sure how I'd go about it myself.
Might be a good one to try on the main comp.lang.python list, its
certainly not typical newbie stuff!

Alan G. 




More information about the Tutor mailing list