Michael Forbes avatar Michael Forbes committed 0f1886a

Added notes about desired auto-client interface

Comments (0)

Files changed (3)

 
 Still Needs:
 
+* Comprehensive testing
+* Logging (print debug messages in debug mode for checking network problems)
+* Profile performance
+* Auto-launch client.
+
+  * Ideally, the user can define the plotting code in a (picklable) class, and
+    then simply provide that class to the Server() constructor.  The class will
+    then spawn, or fork a new python interpreter, import a client, and run the
+    client.  (Right now the user needs to specify the entire command line
+    including the invocation of the interpreter and all imports.)
+
+* 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
-* hard coded ports - put args.
+* error handling. ex. when a client disconnects then server listen continues,
+  network errors
 * multiple clients (plotting)
 
 

asyncplot/client.py

 import time
 import socket
 
-from matplotlib import pyplot as plt
-
-import threading_server
 import server
 
 
 def run_client():
     #create the Client instance and pass the Plot object, then call
     #run().
-    class Plot(threading_server.Plot):
+    class Plot(object):
+        def __init__(self):
+            from matplotlib import pyplot as plt
+            self.plt = plt
+
         def draw(self, x, y):
+            plt = self.plt
             plt.ioff()
             plt.clf()
             plt.plot(x, y)

asyncplot/server.py

     def __enter__(self):
         self.start()
         if self.client_cmd is not None:
-            self.client_process = subprocess.Popen(self.client_cmd)
+            self.client_process = subprocess.Popen(self.client_cmd,
+                                                   # I/O??????
+                                                   )
         else:
             self.client_process = None
         
         return value is None
 
 
+class PlotClient(object):
+    def __init__(self):
+        from matplotlib import pyplot as plt
+        self.plt = plt
+
+    def draw(self, x, y):
+        plt = self.plt
+        plt.ioff()
+        plt.clf()
+        plt.plot(x, y)
+        #print y
+        plt.ion()
+        plt.draw()
+        #time.sleep(0.5)     # Pretend this is slow
+
+
 def example_server():
     import time
     import numpy as np
     t = 0
     dt = 0.01
     tic = time.time()
+    # Ideal code:
+    #with Server(client=PlotClient, wait_for_client=True) as s:
     with Server(client_cmd=['ipython', '--pylab=osx', 'client.py'],
                 wait_for_client=True) as s:
         for n in xrange(1000000):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.