Fix Python deadlock/GIL issues.

SWIG now releases the lock on entry to C++ code, and the various
handlers must acquire the GIL prior to invoking a Python C API. This
is annoying but seems to work.

A bunch of small fixes:

Simplify task assignment for now.
Move Assert class to util for general use.
Make the testing script a bit more command-line drivable.