def _poll(self, timeout=None):
		"""Override in order to handle events in a threadsafe manner."""
		if timeout is None:
			ms = UINT32_MAX  # wait for eternity
		elif timeout < 0:
			raise ValueError("negative timeout")
		else:
			# GetQueuedCompletionStatus() has a resolution of 1 millisecond,
			# round away from zero to wait *at least* timeout seconds.
			ms = math.ceil(timeout * 1e3)
			if ms >= UINT32_MAX:
				raise ValueError("timeout too big")

		with QtCore.QMutexLocker(self._lock):
			while True:
				# self._logger.debug('Polling IOCP with timeout {} ms in thread {}...'.format(
				# 	ms, threading.get_ident()))
				status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
				if status is None:
					break

				err, transferred, key, address = status
				try:
					f, ov, obj, callback = self._cache.pop(address)
				except __HOLE__:
					# key is either zero, or it is used to return a pipe
					# handle which should be closed to avoid a leak.
					if key not in (0, _overlapped.INVALID_HANDLE_VALUE):
						_winapi.CloseHandle(key)
					ms = 0
					continue

				if obj in self._stopped_serving:
					f.cancel()
				# Futures might already be resolved or cancelled
				elif not f.done():
					self.__events.append((f, callback, transferred, key, ov))

				ms = 0
dataset/ETHPy150Open harvimt/quamash/quamash/_windows.py/_IocpProactor._poll