Update for Python 2.7 support.

Problem description
===================

We are preparing for Python 2.7 and some changes are required here.


Changes description
===================

Some minor changes regarding how threads are handled in latest Python.

There is also a change in the way Twisted reactor is started and stoped. The new code uses something more close to what Twisted is using in real like to executing the reactor.

Python 2.7 comes with a good unittest implementation, so we are not using the unittest2 package.


How to try and test the changes
===============================

reviewers @alibotean 

Nothing special here.

Unfortunately the test suite for this package is minimal and useless.

I ran the test on all systems but we will find out more after using the package together with other projects.