fixing uncaught async exceptions due to missing await

fixes uncaught exceptions in the event loop.
passing timeout and timeout_callback through.
This commit is contained in:
Florian Klien
2018-10-27 21:38:50 +02:00
committed by Emmanuel Gil Peyrot
parent 897610d819
commit d4d542b741
2 changed files with 9 additions and 5 deletions

View File

@@ -34,7 +34,10 @@ class HttpUpload(slixmpp.ClientXMPP):
async def start(self, event):
log.info('Uploading file %s...', self.filename)
url = await self['xep_0363'].upload_file(self.filename)
def timeout_callback(arg):
raise TimeoutError("could not send message in time")
url = await self['xep_0363'].upload_file(
self.filename, timeout=10, timeout_callback=timeout_callback)
log.info('Upload success!')
log.info('Sending file to %s', self.recipient)