"""Hooke - A force spectroscopy review & analysis tool.
"""
+if False: # Queue pickle error debugging code
+ """The Hooke class is passed back from the CommandEngine process
+ to the main process via a :class:`multiprocessing.queues.Queue`,
+ which uses :mod:`pickle` for serialization. There are a number of
+ objects that are unpicklable, and the error messages are not
+ always helpful. This block of code hooks you into the Queue's
+ _feed method so you can print out useful tidbits to help find the
+ particular object that is gumming up the pickle works.
+ """
+ import multiprocessing.queues
+ import sys
+ feed = multiprocessing.queues.Queue._feed
+ def new_feed (buffer, notempty, send, writelock, close):
+ def s(obj):
+ print 'SEND:', obj, dir(obj)
+ for a in dir(obj):
+ attr = getattr(obj, a)
+ #print ' ', a, attr, type(attr)
+ if obj.__class__.__name__ == 'Hooke':
+ # Set suspect attributes to None until you resolve the
+ # PicklingError. Then fix whatever is breaking the
+ # pickling.
+ #obj.commands = None
+ #obj.drivers = None
+ #obj.plugins = None
+ #obj.ui = None
+ pass
+ sys.stdout.flush()
+ send(obj)
+ feed(buffer, notempty, s, writelock, close)
+ multiprocessing.queues.Queue._feed = staticmethod(new_feed)
+
import multiprocessing
import optparse
import os.path
"""
ui_to_command,command_to_ui,command = self._setup_run(hooke)
try:
- self.ui.run(hooke.commands, ui_to_command, command_to_ui)
+ hooke.ui.run(hooke.commands, ui_to_command, command_to_ui)
finally:
hooke = self._cleanup_run(ui_to_command, command_to_ui, command)
return hooke
def _setup_run(self, hooke):
ui_to_command = multiprocessing.Queue()
command_to_ui = multiprocessing.Queue()
- manager = multiprocessing.Manager()
+ manager = multiprocessing.Manager()
command = multiprocessing.Process(name='command engine',
target=hooke.command.run, args=(hooke, ui_to_command, command_to_ui))
command.start()
help='Add a command line Hooke command to run.')
options,arguments = p.parse_args()
if len(arguments) > 0:
- print >> sys.stderr, 'Too many arguments to %s: %d > 0' \
- % (sys.argv[0], len(arguments))
- print >> sys.stderr, p.help()
+ print >> sys.stderr, 'More than 0 arguments to %s: %s' \
+ % (sys.argv[0], arguments)
+ p.print_help(sys.stderr)
sys.exit(1)
hooke = Hooke(debug=__debug__)
hooke = runner.run(hooke)
finally:
hooke.close()
-
-if __name__ == '__main__':
- main()