Add support for greenlets

Patch by @hpk42 .