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

Function wait

Lib/multiprocessing/connection.py:1082–1166  ·  view source on GitHub ↗

Wait till an object in object_list is ready/readable. Returns list of those objects in object_list which are ready/readable.

(object_list, timeout=None)

Source from the content-addressed store, hash-verified

1080 _ready_errors = {_winapi.ERROR_BROKEN_PIPE, _winapi.ERROR_NETNAME_DELETED}
1081
1082 def wait(object_list, timeout=None):
1083 '''
1084 Wait till an object in object_list is ready/readable.
1085
1086 Returns list of those objects in object_list which are ready/readable.
1087 '''
1088 object_list = list(object_list)
1089
1090 if not object_list:
1091 if timeout is None:
1092 while True:
1093 time.sleep(1e6)
1094 elif timeout > 0:
1095 time.sleep(timeout)
1096 return []
1097
1098 if timeout is None:
1099 timeout = INFINITE
1100 elif timeout < 0:
1101 timeout = 0
1102 else:
1103 timeout = int(timeout * 1000 + 0.5)
1104 waithandle_to_obj = {}
1105 ov_list = []
1106 ready_objects = set()
1107 ready_handles = set()
1108
1109 try:
1110 for o in object_list:
1111 try:
1112 fileno = getattr(o, 'fileno')
1113 except AttributeError:
1114 waithandle_to_obj[o.__index__()] = o
1115 else:
1116 # start an overlapped read of length zero
1117 try:
1118 ov, err = _winapi.ReadFile(fileno(), 0, True)
1119 except OSError as e:
1120 ov, err = None, e.winerror
1121 if err not in _ready_errors:
1122 raise
1123 if err == _winapi.ERROR_IO_PENDING:
1124 ov_list.append(ov)
1125 waithandle_to_obj[ov.event] = o
1126 else:
1127 # If o.fileno() is an overlapped pipe handle and
1128 # err == 0 then there is a zero length message
1129 # in the pipe, but it HAS NOT been consumed...
1130 if ov and sys.getwindowsversion()[:2] >= (6, 2):
1131 # ... except on Windows 8 and later, where
1132 # the message HAS been consumed.
1133 try:
1134 _, err = ov.GetOverlappedResult(False)
1135 except OSError as e:
1136 err = e.winerror
1137 if not err and hasattr(o, '_got_empty_message'):
1138 o._got_empty_message = True
1139 ready_objects.add(o)

Callers 15

wait_for_handleFunction · 0.90
test_timeoutMethod · 0.90
test_eventMethod · 0.90
test_waitMethod · 0.90
test_wait_socketMethod · 0.90
test_wait_timeoutMethod · 0.90
test_wait_integerMethod · 0.90
test_neg_timeoutMethod · 0.90
waitMethod · 0.90
pollMethod · 0.90
is_aliveMethod · 0.90
joinMethod · 0.90

Calls 13

listClass · 0.85
setFunction · 0.85
filenoFunction · 0.85
_exhaustive_waitFunction · 0.85
sleepMethod · 0.45
__index__Method · 0.45
appendMethod · 0.45
addMethod · 0.45
keysMethod · 0.45
cancelMethod · 0.45
updateMethod · 0.45
registerMethod · 0.45

Tested by 8

wait_for_handleFunction · 0.72
test_timeoutMethod · 0.72
test_eventMethod · 0.72
test_waitMethod · 0.72
test_wait_socketMethod · 0.72
test_wait_timeoutMethod · 0.72
test_wait_integerMethod · 0.72
test_neg_timeoutMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…