Intercepting method calls

Matt Leslie matthewleslie at hotmail.com
Tue Apr 27 12:14:27 EDT 2004


I want to write a package to simulate a distributed system with objects 
at various locations interacting with each other. What I'd like to do is 
simulate network delays between distant objects using an event queue.

That is, when I call A.B(foo), I want this call to be intercepted 
somehow, and the call to B added to a central event queue thread, and is 
called later, possibly after other previously enqued method calls. The 
central queue would also do some accounting to keep track of things like 
messages sent, message size, etc.

The idea is that you just write these objects as if they were local 
objects communicating normally, and all the network simulation is done 
for you transparently - perhaps by some 'NetworkObject' superclass.

I took a look at the language reference and it is not immediately clear 
to me how or if I could do this in Python, perhaps I need to override 
the __call__ methods for all the instancemethods in the class? I'm not 
even sure how I could do this... Any help or suggestions appreciated.

Thanks,
	Matt



More information about the Python-list mailing list