Get helper for scheduling in place

This commit is contained in:
Luke Murphy 2020-07-22 19:17:32 +02:00
parent 6a9892b4de
commit 4b4818d4cc
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -80,6 +80,7 @@ class DropShip:
files = data.get_text().split()
self.files_to_send = files
if len(files) == 1:
self.schedule(self.wormhole_send(self, files[0]))
self.drop_label.set_text("Sending..")
else:
log.info("Multiple file sending coming soon ™")
@ -92,11 +93,15 @@ class DropShip:
# enabled by https://github.com/jhenstridge/asyncio-glib/pull/7
self._running.set_result(None)
async def wormhole_send(self, fpath):
def schedule(self, function):
"""Schedule an task."""
loop.call_soon_threadsafe(asyncio.ensure_future, function)
async def wormhole_send(self, widget, fpath):
"""Run `wormhole send` on a local file path."""
log.info("Pretending to start wormhole send...")
log.info(f"Pretending to start wormhole send {fpath}")
await asyncio.sleep(2)
log.info("Pretending to finish wormhole send...")
log.info(f"Pretending to finish wormhole send {fpath}")
async def main():