Get helper for scheduling in place
This commit is contained in:
parent
6a9892b4de
commit
4b4818d4cc
11
dropship.py
11
dropship.py
@ -80,6 +80,7 @@ class DropShip:
|
|||||||
files = data.get_text().split()
|
files = data.get_text().split()
|
||||||
self.files_to_send = files
|
self.files_to_send = files
|
||||||
if len(files) == 1:
|
if len(files) == 1:
|
||||||
|
self.schedule(self.wormhole_send(self, files[0]))
|
||||||
self.drop_label.set_text("Sending..")
|
self.drop_label.set_text("Sending..")
|
||||||
else:
|
else:
|
||||||
log.info("Multiple file sending coming soon ™")
|
log.info("Multiple file sending coming soon ™")
|
||||||
@ -92,11 +93,15 @@ class DropShip:
|
|||||||
# enabled by https://github.com/jhenstridge/asyncio-glib/pull/7
|
# enabled by https://github.com/jhenstridge/asyncio-glib/pull/7
|
||||||
self._running.set_result(None)
|
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."""
|
"""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)
|
await asyncio.sleep(2)
|
||||||
log.info("Pretending to finish wormhole send...")
|
log.info(f"Pretending to finish wormhole send {fpath}")
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user