In Twitter's Finagle
, map
and flatMap
can be used to chain multiple asynchronous operations. For example, a simple web scraper might do something like,
downloadURL(url) // download a web page
.flatMap(extractProducts) // extract individual products for sale on it
.foreach(saveToDatabase) // save output to a database
I would like to do something very similar using gevent
in Python, but I'm not sure how to do so. Greenlet.link
seems to be a start, but it doesn't give me access to the Greenlet
containing the final result (as far as I can tell).
How do I mimic Finagle
's map
and flatMap
operations with gevent.Greenlet
?