2020-11-18 12:13:46 +01:00
|
|
|
import giambio
|
|
|
|
|
|
|
|
|
|
|
|
async def child():
|
2020-12-05 17:09:59 +01:00
|
|
|
print("[child] Child spawned!! Sleeping for 4 seconds")
|
|
|
|
await giambio.sleep(4)
|
2020-11-18 12:13:46 +01:00
|
|
|
print("[child] Had a nice nap!")
|
2020-11-26 16:57:20 +01:00
|
|
|
|
2020-11-18 12:13:46 +01:00
|
|
|
|
|
|
|
async def child1():
|
|
|
|
print("[child 1] Child spawned!! Sleeping for 2 seconds")
|
|
|
|
await giambio.sleep(2)
|
|
|
|
print("[child 1] Had a nice nap!")
|
|
|
|
|
2020-11-22 14:35:07 +01:00
|
|
|
|
2020-11-18 12:13:46 +01:00
|
|
|
async def main():
|
|
|
|
start = giambio.clock()
|
2020-11-28 13:04:27 +01:00
|
|
|
async with giambio.create_pool() as pool:
|
2021-06-08 17:21:59 +02:00
|
|
|
await pool.spawn(child)
|
|
|
|
await pool.spawn(child1)
|
2020-11-28 13:04:27 +01:00
|
|
|
print("[main] Children spawned, awaiting completion")
|
2021-07-22 11:13:08 +02:00
|
|
|
print(f"[main] Children execution complete in {giambio.clock() - start:.2f} seconds")
|
2020-11-26 16:57:20 +01:00
|
|
|
|
2020-11-18 12:13:46 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-11-27 21:52:45 +01:00
|
|
|
giambio.run(main)
|