(url)
| 491 | ######################################################################### |
| 492 | |
| 493 | def error_handler(url): |
| 494 | global HANDLE_ERRORS |
| 495 | orig = HANDLE_ERRORS |
| 496 | keepalive_handler = HTTPHandler() |
| 497 | opener = _urllib.request.build_opener(keepalive_handler) |
| 498 | _urllib.request.install_opener(opener) |
| 499 | pos = {0: 'off', 1: 'on'} |
| 500 | for i in (0, 1): |
| 501 | print(" fancy error handling %s (HANDLE_ERRORS = %i)" % (pos[i], i)) |
| 502 | HANDLE_ERRORS = i |
| 503 | try: |
| 504 | fo = _urllib.request.urlopen(url) |
| 505 | foo = fo.read() |
| 506 | fo.close() |
| 507 | try: status, reason = fo.status, fo.reason |
| 508 | except AttributeError: status, reason = None, None |
| 509 | except IOError as e: |
| 510 | print(" EXCEPTION: %s" % e) |
| 511 | raise |
| 512 | else: |
| 513 | print(" status = %s, reason = %s" % (status, reason)) |
| 514 | HANDLE_ERRORS = orig |
| 515 | hosts = keepalive_handler.open_connections() |
| 516 | print("open connections:", hosts) |
| 517 | keepalive_handler.close_all() |
| 518 | |
| 519 | def continuity(url): |
| 520 | from hashlib import md5 |
no test coverage detected
searching dependent graphs…