Skip to content

Instantly share code, notes, and snippets.

@jordic
Last active July 7, 2019 05:26
Show Gist options
  • Save jordic/80b1f544a369403d844855806ebb4bde to your computer and use it in GitHub Desktop.
Save jordic/80b1f544a369403d844855806ebb4bde to your computer and use it in GitHub Desktop.
order of exec
const out = () => console.log("Hola 2")
const out2 = () => console.log("Hola 4")
console.log("Hola 1")
out()
console.log("Hola 3")
Promise.resolve().then(out2)
console.log("Hola 5")
/*
Outputs:
Hola 1
Hola 2
Hola 3
Hola 5
Hola 4
*/
import asyncio
async def next_tick():
print("hello 2")
async def delayed(num=4):
print(f"hello {num}")
async def main():
print("Hello 1")
await next_tick()
print("Hello 3")
asyncio.create_task(delayed())
print("Hello 5")
if __name__ == "__main__":
asyncio.run(main())
"""Outputs
Hello 1
hello 2
Hello 3
Hello 5
hello 4
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment