Skip to content

Commit

Permalink
Applying @joezuntz's patch from #38
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm committed Jan 28, 2013
1 parent 75a93f8 commit ca9abf3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions emcee/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,23 @@ def map(self, function, tasks):
self.wait()
return

F = _function_wrapper(function)
if function is not self.function:
if self.debug:
print(u"Master replacing pool function with {0}."
.format(function))

# Tell all the workers what function to use.
requests = []
for i in range(self.size):
r = self.comm.isend(F, dest=i + 1)
requests.append(r)
self.function = function
F = _function_wrapper(function)

# Wait until all of the workers have responded. See:
# https://gist.github.com/4176241
MPI.Request.waitall(requests)
# Tell all the workers what function to use.
requests = []
for i in range(self.size):
r = self.comm.isend(F, dest=i + 1)
requests.append(r)

# Wait until all of the workers have responded. See:
# https://gist.github.com/4176241
MPI.Request.waitall(requests)

# Send all the tasks off and wait for them to be received.
# Again, see the bug in the above gist.
Expand Down

0 comments on commit ca9abf3

Please sign in to comment.