Commits

Cameron Simpson  committed 71ee47c

cs.threads: runTree: coerce functions returning generators to list, forcing execution of the generator in parallel with other tasks instead of constructing a huge single threaded generator tree executed later

  • Participants
  • Parent commits 334e94f

Comments (0)

Files changed (1)

File lib/python/cs/threads.py

   LFs = []
   for input in inputs:
     substate = copy(state) if fork_state else state
-    LF = funcQ.defer(func, input, substate)
+    def submit_func(func, input, substate):
+      return list(func(input, substate))
+    LF = funcQ.defer(submit_func, func, input, substate)
     LFs.append(LF)
 
   # now submit a function to collect the results