+ def dergister(self):
+ self._log.debug("De-registering download status for project {}".
+ format(self.project.name))
+ if self.reg:
+ self.reg.deregister()
+ self.reg = None
+
+ @staticmethod
+ def _async_func(func, fut):
+ try:
+ ret = func()
+ fut.set_result(ret)
+ except Exception as e:
+ fut.set_exception(e)
+
+ def _schedule_dts_work(self, download_job_msg):
+ # Create a coroutine
+ cort = self._dts_publisher(download_job_msg)
+ # Use main asyncio loop (running in main thread)
+ newfunc = functools.partial(asyncio.ensure_future, cort, loop=self.loop)
+ fut = concurrent.futures.Future()
+ # Schedule future in main thread immediately
+ self.loop.call_soon_threadsafe(DownloadStatusPublisher._async_func, newfunc, fut)
+ res = fut.result()
+ exc = fut.exception()
+ if exc is not None:
+ self.log.error("Caught future exception during download: %s type %s", str(exc), type(exc))
+ raise exc
+ return res