libtclpq , by Colin McCormack, is a quick/experimental Swig-generated hack with itcl wrapper to permit asynchronous execution of PostgreSQL commands and cancellation of commands in progress.