File: utils.py

package info (click to toggle)
python-sparkpost 1.3.10-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 512 kB
  • sloc: python: 2,528; makefile: 31; sh: 10
file content (14 lines) | stat: -rw-r--r-- 333 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from tornado.concurrent import Future


def wrap_future(future, convert):
    wrapper = Future()

    def handle_future(future):
        try:
            wrapper.set_result(convert(future.result()))
        except Exception as ex:
            wrapper.set_exception(ex)

    future.add_done_callback(handle_future)
    return wrapper