Skip to main content

Asynchronous client-server library for simple plotting.

Project description

Async Plotter

Simple two-process client/server plotting with the following features:

  • Plotting does not slow down calculations.

  • User maintains control of the calculation (i.e. KeyboardInterrupts work).

  • Auto-launch client from the server.

    • The user defines the plotting code in a (picklable) class, and provides the class to the Server() constructor. The Server passes the pickled Plotter to the client when the client process is launched in a new python interpreter. The python interpreter command line options for the client are passed to the Server constructor at the time of instantiation. Default values are: (ex. [“ipython”, “–pylab=osx”, “-c”])

To Do

Prototype for asynchronous plotting with separate processes using sockets

Still Needs:

  • Comprehensive testing

  • Logging (print debug messages in debug mode for checking network problems)

  • Profile performance.

  • Configuration (hostname, port specification etc.)

I think that these have been dealt with, but they need testing:

  • socket buffer overflow (recv)

  • cleanup thread and socket command line termination

  • error handling. ex. when a client disconnects then server listen continues, network errors

  • multiple clients (plotting)

Other Design Approaches

Threading Solution

The simplest approach is a multi-thread approach. In principle, one can run the computations in the main thread and plotting in a separate thread. This solution is sketched in thread.py but fails with most matplotlib backends due to their requirement of running in the main thread. A quick work-around is to run the computation in a secondary thread, but this precludes the user being able to interrupt the computation.

A nice feature of the python GIL is that one can be fairly confident about sharing data (a careful solution would require locks etc.)

Multiprocessing Solution

This same solution should work with multiprocessing, but this fails on my development platform (Mac OS X 10.5) with the following error:

The process has forked and you cannot use this CoreFoundation
functionality safely. You MUST exec().
Break on
__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

Separate Processes

It seems that the most robust solution is to have the calculation and plotters run in completely separate processes. This has an added benefit:

  • User can plot remotely.

One issue that needs to be addressed here (and in the multiprocessing solution) is the copying of data. One common use-case is that the plotter may be slower than the computation. Thus, intermediate data may be discarded and should not be sent across the network.

Additional Approaches

It seems that one should be able to use IPython to do this, but I have not found a simple way to do this yet.

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 Distribution

asyncplot-0.1.tar.gz (8.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: asyncplot-0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asyncplot-0.1.tar.gz
Algorithm Hash digest
SHA256 a24f15f74e9aeb806f03b90f3997b9602c59364efa1189fe3813e65ecfcb0ced
MD5 ccff58381bab858481b7c7fd591d6867
BLAKE2b-256 98a9c6758ac3e222a238b72734659735adfc7d9d3525d3ba036a70ccddd72211

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