I\'ve the following code using asyncio and aiohttp to make asynchronous HTTP requests.
import sys
import asyncio
import aiohttp
@a
To debug or "handle" exceptions in callback:
Coroutine which return some result or raise exceptions:
@asyncio.coroutine
def async_something_entry_point(self):
try:
return self.real_stuff_which_throw_exceptions()
except:
raise Exception(some_identifier_here + ' ' + traceback.format_exc())
And callback:
def callback(self, future: asyncio.Future):
exc = future.exception()
if exc:
# Handle wonderful empty TimeoutError exception
if type(exc) == TimeoutError:
self.logger(' callback exception TimeoutError')
else:
self.logger(" callback exception " + str(exc))
# store your result where you want
self.result.append(
future.result()
)