-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
27 lines (22 loc) · 787 Bytes
/
test.py
File metadata and controls
27 lines (22 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%%asyncpython
import time
import math
print("Starting comprehensive asynchronous Python test...")
print("Performing calculations:")
# Loop to simulate iterative processing and calculations.
for i in range(1, 6):
time.sleep(1) # Simulate work with a delay.
result = math.sqrt(i * 10)
print(f"Iteration {i}: sqrt({i*10}) = {result}")
print("\nNow testing error handling:")
try:
print("About to perform a division by zero...")
_ = 10 / 0 # Intentional error.
except Exception as e:
print(f"Expected error caught: {e}")
print("\nResuming normal execution:")
# Additional loop to continue after the error.
for j in range(6, 9):
time.sleep(1)
print(f"Iteration {j}: continuing after error...")
print("\nAsynchronous Python test completed successfully!")