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 2 1977
Matt Leslie wrote: 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.
A way to accomplish this is the usage of metaclasses. A metaclass gives you
a sort of callback that gets invoked with the classname, the base classes
and the class dictionary before the actual class object is created. Here
you then can creat wrappers around all callables that implement your
desired behaviour.
See this reciepe: http://aspn.activestate.com/ASPN/Coo.../Recipe/198078
--
Regards,
Diez B. Roggisch
Diez B. Roggisch wrote: A way to accomplish this is the usage of metaclasses. A metaclass gives you a sort of callback that gets invoked with the classname, the base classes and the class dictionary before the actual class object is created. Here you then can creat wrappers around all callables that implement your desired behaviour.
Thanks, I'll take a look at that.
Ta,
Matt This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fenix |
last post by:
I want intercept the call to a object method or object property .
Its plausible ?
Are there any event fired when i invoke a object method or property ?
|
by: Peter Olcott |
last post by:
Is there any way to intercept system calls to windows such as TextOut and DrawText?
what kinds of system calls can be intercepted, and what is the mechanism to accomplish this?
|
by: Valery Polyakov |
last post by:
I am drawing lines with a semi-transparent color
(alpha=100). When these lines intercept, the color
becomes more intense. Is there a way to avoid this, so
that I would get the same intensity of color?
Thanks a lot.
|
by: sk |
last post by:
Hi,
I'm trying to override the Render method of my Page class. Are there any
standard guidelines for this?
Thanks.
Shardul
|
by: Microsoft Newsserver |
last post by:
Hi,
I am using VS2005/.Ajax 1.1 . I need to mask the screen during async calls
back to the server. I can do this by surrounding the whole screen with a
filtered div to prevent click throughs to controls.
The issue is how or when to turn the filter on the div on. Basically, I need
to know how to intercept any of the async calls and turn the div filter on,
which I then turn off again during page load.
| |
by: Gabriel Genellina |
last post by:
En Thu, 18 Sep 2008 19:24:26 -0300, Robert Dailey <rcdailey@gmail.com>
escribió:
Why don't you try it yourself?
You may replace builtins.print with your own function too. It's not
exactly the same thing, but given your request "intercepting things send
to print() before they're sent to sys.stdout" it may be more adequate.
--
|
by: K Viltersten |
last post by:
I've seen some people calling a stored procedure
on MS SQL Server and intercepting an invalid
parameter list by a switch statement, demanding
that each of the parameters names is exactly as
the one in the procedure that's about to be
called. If we let in an invalid parameter, we'll
get the following error message.
Msg 8145, Level 16, State 1, Procedure Prc, Line 0
@Param is not a parameter for procedure Prc.
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |