Cothread: Use catools timeout for PV waiting

git-svn-id: svn+ssh://serv0002.cs.diamond.ac.uk/home/subversion/repos/controls/diamond/trunk/python/cothread@121110 e099a375-04f9-0310-9d5f-a741eaff62e1
Cothread: Allow independent cothreads in multiple threads

Allow each thread the possibility of having a scheduler, uses thread local
storage to keep track of the scheduler of the current thread.

The cothread scheduler is initialised on the first creation of any waitable
object on that thread.  Waitable objects can be signalled from any thread
but can only be blocked (waited for) from the originating thread.

Replaces the module globals _scheduler, _QuitEvent, and Callback with
per-thread alternatives.

To preserve existing behavour, the Callback() function allows dispatches to
the original importer.

The function GetCallback([thread]) is added which returns the queue for the
current thread, or the thread passed as an argument.
Cothread: allow catools to be used by cothreads in independent OS threads

Dispatch callbacks to the thread which created the channels.

Cleanup CA contexts as each thread exits with weakrefs instead of atexit,
except for the main thread which still needs an atexit.