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

Method run

recipes/Python/496979_threaded_pipes/recipe-496979.py:26–43  ·  view source on GitHub ↗

runs the overridden fn() if fn() returns False, put it on the stack and quit so any other pipes will get it and pass it on, quitting if fn() returns None, don't put anything

(self)

Source from the content-addressed store, hash-verified

24 pass
25
26 def run(self):
27 """
28 runs the overridden fn()
29 if fn() returns False, put it on the stack and quit
30 so any other pipes will get it and pass it on, quitting
31 if fn() returns None, don't put anything
32 """
33 ret = True
34 while ret is not False:
35 if self.input is None: # it's a faucet
36 ret = self.fn()
37 elif hasattr(self.input, 'get'): # it's a pipe
38 ob = self.input.get()
39 if ob is False:
40 self.put(ob)
41 break
42 ret = self.fn(ob)
43 if ret is not None: self.put(ret)

Callers

nothing calls this directly

Calls 3

fnMethod · 0.95
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected