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

Class ApplyResult

Lib/multiprocessing/pool.py:745–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743#
744
745class ApplyResult(object):
746
747 def __init__(self, pool, callback, error_callback):
748 self._pool = pool
749 self._event = threading.Event()
750 self._job = next(job_counter)
751 self._cache = pool._cache
752 self._callback = callback
753 self._error_callback = error_callback
754 self._cache[self._job] = self
755
756 def ready(self):
757 return self._event.is_set()
758
759 def successful(self):
760 if not self.ready():
761 raise ValueError("{0!r} not ready".format(self))
762 return self._success
763
764 def wait(self, timeout=None):
765 self._event.wait(timeout)
766
767 def get(self, timeout=None):
768 self.wait(timeout)
769 if not self.ready():
770 raise TimeoutError
771 if self._success:
772 return self._value
773 else:
774 raise self._value
775
776 def _set(self, i, obj):
777 self._success, self._value = obj
778 if self._callback and self._success:
779 self._callback(self._value)
780 if self._error_callback and not self._success:
781 self._error_callback(self._value)
782 self._event.set()
783 del self._cache[self._job]
784 self._pool = None
785
786 __class_getitem__ = classmethod(types.GenericAlias)
787
788AsyncResult = ApplyResult # create alias -- see #17805
789

Callers 1

apply_asyncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…