add Source.on_exception event hook

This commit is contained in:
lilydjwg 2018-05-08 18:17:45 +08:00
parent de1634a587
commit cf817ffe27
1 changed files with 6 additions and 1 deletions

View File

@ -170,7 +170,9 @@ class Source:
for fu in asyncio.as_completed(futures):
name, result = await fu
if isinstance(result, Exception):
logger.error('unexpected error happened', name=name, exc_info=result)
logger.error('unexpected error happened',
name=name, exc_info=result)
self.on_exception(name, result)
elif result is not None:
self.print_version_update(name, result)
@ -191,6 +193,9 @@ class Source:
def on_update(self, name, version, oldver):
pass
def on_exception(self, name, exc):
pass
def __repr__(self):
return '<Source from %r>' % self.name