Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 1f433ac

Browse files
committed
handle exceptions
1 parent a28a13e commit 1f433ac

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

examples/example_time_calls.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,26 @@ def main():
1616

1717
print('Create')
1818
tic = time.process_time_ns()
19-
cf = CloudFlare.CloudFlare()
19+
try:
20+
cf = CloudFlare.CloudFlare()
21+
except Exception as e:
22+
print('\tError: %s' % (e))
23+
cf = None
2024
toc = time.process_time_ns()
2125
print('\t%7.3f ms' % ((toc-tic)/1000000.0))
2226
print('')
2327

28+
if not cf:
29+
return
30+
2431
print('Call')
2532
for ii in range(0,10):
2633
tic = time.process_time_ns()
27-
r = cf.ips()
34+
try:
35+
r = cf.ips()
36+
except Exception as e:
37+
print('\tError: %s' % (e))
38+
break
2839
toc = time.process_time_ns()
2940
print('\t%7.3f ms' % ((toc-tic)/1000000.0))
3041
print('')

0 commit comments

Comments
 (0)