Created
March 1, 2020 06:43
-
-
Save podhmo/79177b3f203728e93dd8bbe453b24172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from handofcats import as_command, print | |
@as_command | |
def run(): | |
print("hello") | |
print("byebye") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 01update_check.py 2020-03-01 15:37:07.000000000 +0900 | |
+++ 02update_check.py 2020-03-01 15:37:22.000000000 +0900 | |
@@ -31,7 +31,8 @@ | |
def main(): | |
async def run(): | |
fut = asyncio.ensure_future(update_check()) | |
- run_main() | |
+ loop = asyncio.get_event_loop() | |
+ await loop.run_in_executor(None, run_main) | |
update_version = await fut | |
if update_version is not None: | |
print(f"A new release of gh is available: xxx → {update_version}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as t | |
import asyncio | |
import random | |
from handofcats import as_command, print | |
async def update_check() -> t.Awaitable[t.Optional[str]]: | |
print("-> update_check ...") | |
await asyncio.sleep(0.5) | |
print("<- ... update_check") | |
if random.random() < 0.2: | |
# update is not found | |
return None | |
# update is found | |
return "0.8.8" | |
def run_main(): | |
import time | |
print("do something (main)") | |
for i in range(6): | |
print(".") | |
time.sleep(0.1) | |
print("ok") | |
@as_command | |
def main(): | |
async def run(): | |
fut = asyncio.ensure_future(update_check()) | |
run_main() | |
update_version = await fut | |
if update_version is not None: | |
print(f"A new release of gh is available: xxx → {update_version}") | |
asyncio.run(run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as t | |
import asyncio | |
import random | |
from handofcats import as_command, print | |
async def update_check() -> t.Awaitable[t.Optional[str]]: | |
print("-> update_check ...") | |
await asyncio.sleep(0.5) | |
print("<- ... update_check") | |
if random.random() < 0.2: | |
# update is not found | |
return None | |
# update is found | |
return "0.8.8" | |
def run_main(): | |
import time | |
print("do something (main)") | |
for i in range(6): | |
print(".") | |
time.sleep(0.1) | |
print("ok") | |
@as_command | |
def main(): | |
async def run(): | |
fut = asyncio.ensure_future(update_check()) | |
loop = asyncio.get_event_loop() | |
await loop.run_in_executor(None, run_main) | |
update_version = await fut | |
if update_version is not None: | |
print(f"A new release of gh is available: xxx → {update_version}") | |
asyncio.run(run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00: | |
DEBUG=1 python $(shell echo $@*.py) | |
01: | |
LOGGING_TIME=relative DEBUG=1 python $(shell echo $@*.py) | |
02: | |
LOGGING_TIME=relative DEBUG=1 python $(shell echo $@*.py) | |
03: | |
diff -u 01*.py 02*.py > 0102.diff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment