MCPcopy Create free account
hub / github.com/ActiveState/code / __call__

Method __call__

recipes/Python/578151_affinitypy/recipe-578151.py:37–45  ·  view source on GitHub ↗

Executes function on creating thread and returns result.

(self, func, *args, **kwargs)

Source from the content-addressed store, hash-verified

35 self.__action = queue.Queue()
36
37 def __call__(self, func, *args, **kwargs):
38 "Executes function on creating thread and returns result."
39 if _thread.get_ident() == self.__thread:
40 while not self.__action.empty():
41 self.__action.get_nowait()()
42 return func(*args, **kwargs)
43 delegate = _Delegate(func, args, kwargs)
44 self.__action.put_nowait(delegate)
45 return delegate.value
46
47################################################################################
48

Callers

nothing calls this directly

Calls 5

_DelegateClass · 0.85
get_nowaitMethod · 0.80
funcFunction · 0.50
emptyMethod · 0.45
put_nowaitMethod · 0.45

Tested by

no test coverage detected