File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 44
55__all__ = [
66 'END' ,
7+ 'DEBUG' ,
78 'pipe' ,
89 'each' ,
910 'puts' ,
@@ -20,11 +21,17 @@ def puts(data, end="\n"):
2021def each (fn ):
2122 return partial (map , fn )
2223
23- class end :
24+ class End :
2425 "mark end of pipe"
2526 pass
2627
27- END = end ()
28+ END = End ()
29+
30+ class Debug :
31+ "mark end of pipe for debug"
32+ pass
33+
34+ DEBUG = Debug ()
2835
2936class MultiTask :
3037 def __init__ (self , func ):
@@ -92,9 +99,15 @@ def function(self, rhs):
9299 self .data = rhs (self .data )
93100
94101 def __or__ (self , rhs ):
95- if isinstance ( rhs , end ) :
102+ if rhs is END :
96103 # end of pipe
97104 return self .action (self .data )
105+ elif rhs is DEBUG :
106+ # debug end of pipe
107+ try :
108+ return self .action (self .data )
109+ except Exception as e :
110+ return e
98111 elif isinstance (rhs , list ):
99112 if len (set (rhs )) != 1 :
100113 raise SyntaxError ('Bad pipe multiprocessing syntax.' )
You can’t perform that action at this time.
0 commit comments