MCPcopy Index your code
hub / github.com/python/cpython / is_unavailable_exception

Function is_unavailable_exception

Lib/test/test_xmlrpc.py:748–763  ·  view source on GitHub ↗

Returns True if the given ProtocolError is the product of a server-side exception caused by the 'temporarily unavailable' response sometimes given by operations on non-blocking sockets.

(e)

Source from the content-addressed store, hash-verified

746# This function prevents errors like:
747# <ProtocolError for localhost:57527/RPC2: 500 Internal Server Error>
748def is_unavailable_exception(e):
749 ''&#x27;Returns True if the given ProtocolError is the product of a server-side
750 exception caused by the 'temporarily unavailable' response sometimes
751 given by operations on non-blocking sockets.''&#x27;
752
753 # sometimes we get a -1 error code and/or empty headers
754 try:
755 if e.errcode == -1 or e.headers is None:
756 return True
757 exc_mess = e.headers.get('X-exception')
758 except AttributeError:
759 # Ignore OSErrors here.
760 exc_mess = str(e)
761
762 if exc_mess and 'temporarily unavailable' in exc_mess.lower():
763 return True
764
765def make_request_and_skipIf(condition, reason):
766 # If we skip the test, we have to make a request because

Callers 15

make_request_and_skipFunction · 0.85
test_simple1Method · 0.85
test_nonasciiMethod · 0.85
test_client_encodingMethod · 0.85
test_introspection1Method · 0.85
test_introspection2Method · 0.85
test_introspection3Method · 0.85
test_introspection4Method · 0.85
test_multicallMethod · 0.85
test_server_encodingMethod · 0.85

Calls 3

strFunction · 0.85
getMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…