Skip to main content

use traits remotely

Project description

Background

This is a very crude hack to make Enthought’s Traits work in a multi-process situation. Let’s say a process called Alice has a variable called camera, which is an instance of (a subclass of) HasTraits. Now, if another process called Bob wants to be notified when camera.shutter changes, this should happen using the normal Traits machinery. Furthermore, if Bob wants to change Alice’s camera.shutter settings, Alice should be notified of those changes.

There was a little discussion on this subject on the enthought-dev email list, with Robert Kern’s idea being to use Python 2.6’s multiprocess module to create Proxy objects of HasTraits subclasses which would transparently do this. I suspect such an approach would be very slick, but was beyond my one-day abilities, and I was on a deadline to get some code working.

Therefore, I created a hack: both the Alice and Bob processes have full copies of the camera instance which mirror each other. For my real world usage, Alice’s camera instance would be connected to something that actually does something, such as take pictures with a real camera, whereas Bob’s camera instance would be connected to a GUI on a remote computer. The synchronization between the two processes happens using Pyro (Python remote objects). (The dependency on Pyro could probably be removed in favor of using multiprocess, but I was already familiar with Pyro and couldn’t immediately figure out how to do the equivalent things with multiprocess.)

Anyhow, that is the motivation behing the example here. I plan to continue tinkering with this code until it’s working for me in the real world.

Quickstart

To run the demo, run this in one terminal:

# Start the "do" program -- Alice in the motivation above
python wx_demo.py do

And run this in another terminal:

# Start the "view" program -- Bob in the motivation above
python wx_demo.py view

License

This code licensed with the MIT license (see the source code for the full license).

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

remote_traits-0.1.zip (8.1 kB view details)

Uploaded Source

remote_traits-0.1.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file remote_traits-0.1.zip.

File metadata

  • Download URL: remote_traits-0.1.zip
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for remote_traits-0.1.zip
Algorithm Hash digest
SHA256 057a395ad3549acbf56b13b5b609d528ff26c910caf47fe462a98875cd1bf72c
MD5 b8cc150206f898ad9d5de20279cf6c53
BLAKE2b-256 709bdeac11b1c877339e7740acfa4f51da1e05b30fd426217ba13bf938cd73c9

See more details on using hashes here.

File details

Details for the file remote_traits-0.1.tar.gz.

File metadata

File hashes

Hashes for remote_traits-0.1.tar.gz
Algorithm Hash digest
SHA256 03888853b7e8022d27602f0c640216895c8e39d3c721268442f6ad8bab513846
MD5 c22654806203b4554a465d8f46322e0c
BLAKE2b-256 12f9293eb1b2fab714377b1db2520467fc8e91a9b7bfe86dd985c759497415df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page