2020-12-20 15:58:53 +01:00
|
|
|
import giambio
|
|
|
|
from debugger import Debugger
|
|
|
|
|
|
|
|
|
2021-04-22 11:30:35 +02:00
|
|
|
async def child(name: int):
|
|
|
|
print(f"[child {name}] Child spawned!! Sleeping for {name} seconds")
|
|
|
|
await giambio.sleep(name)
|
|
|
|
print(f"[child {name}] Had a nice nap!")
|
2020-12-20 15:58:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
start = giambio.clock()
|
|
|
|
try:
|
2021-04-23 09:17:55 +02:00
|
|
|
async with giambio.with_timeout(10) as pool:
|
2021-06-08 17:21:59 +02:00
|
|
|
await pool.spawn(child, 7) # This will complete
|
|
|
|
await child(20) # TODO: Broken
|
2020-12-20 15:58:53 +01:00
|
|
|
except giambio.exceptions.TooSlowError:
|
|
|
|
print("[main] One or more children have timed out!")
|
2021-07-22 11:13:08 +02:00
|
|
|
print(f"[main] Children execution complete in {giambio.clock() - start:.2f} seconds")
|
2020-12-20 15:58:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-08 17:21:59 +02:00
|
|
|
giambio.run(main, debugger=())
|