Cothread: Create cosocket.create_connection function

Seems silly not be wrapping this basic helper function.

git-svn-id: svn+ssh://serv0002.cs.diamond.ac.uk/home/subversion/repos/controls/diamond/trunk/python/cothread@113114 e099a375-04f9-0310-9d5f-a741eaff62e1
Cothread: Export server_close() and use it in tests

To avoid warnings in tests it is necessary to actually close the
listening socket using the undocumented server_close() function.

Signed-off-by: Michael Davidsaver <mdavidsaver@bnl.gov>

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

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

Lazy creation is only done for Spawn(), so add PrepareThread()
to allow threads other than the original importer
to pre-create a scheduler, Quit event, and Callback queue.

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.
separate epics target name detection
allow catools to be used my 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.