我用產量和任務來獲得異步4個jsons:Python:如何使用龍捲風從發電機功能返回?
@gen.engine
def get_user_data(self, sn, snid, fast_withdrawals):
end_timestamp = time.time()
start_timestamp = end_timestamp - CONFIG.LOYALITY_LEVELS.PERIOD
active_apps_response, total_payments_response, payments_for_period_response, withdrawals_response = yield [
gen.Task(self.http_client.fetch, self.__get_active_apps_url(sn, snid)), gen.Task(self.http_client.fetch, self.__get_total_payments_url(sn, snid)),
gen.Task(self.http_client.fetch, self.__get_payments_sum_for_period_url(sn, snid, start_timestamp, end_timestamp)),
gen.Task(self.http_client.fetch, self.__get_total_withdrawals_url(sn, snid, fast_withdrawals))
]
active_apps = self.__active_apps_handler(active_apps_response)
total_payments = self.__get_total_payments_handler(total_payments_response)
payments_for_period = self.__payments_sum_for_period_handler(payments_for_period_response)
withdrawals = self.__get_total_withdrawals_handler(withdrawals_response)
yield gen.Return(active_apps, total_payments, payments_for_period, withdrawals)
但是,如果我用產量,而不是返回上層函數成爲生成器也是一樣,我不能太使用的回報。那麼,如何在沒有調用函數發生器的情況下返回龍捲風函數的結果呢? 我正在使用Python 2.7