gevent + greenlets copied from https://github.com/tobiasquinn/communifi_piratebox