From 2ffc83f9eef401e346202b1c2ee7a3d56f81a71f Mon Sep 17 00:00:00 2001
From: Matthew Pitkin <matthew.pitkin@ligo.org>
Date: Mon, 28 Jan 2019 11:01:16 +0000
Subject: [PATCH] emcee.py: set __getstate__ attribute to allow use of pool

---
 bilby/core/sampler/emcee.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bilby/core/sampler/emcee.py b/bilby/core/sampler/emcee.py
index 9f028c9f..75eaed43 100644
--- a/bilby/core/sampler/emcee.py
+++ b/bilby/core/sampler/emcee.py
@@ -104,6 +104,13 @@ class Emcee(MCMCSampler):
     def nsteps(self, nsteps):
         self.kwargs['iterations'] = nsteps
 
+    def __getstate__(self):
+        # In order to be picklable with dill, we need to discard the pool
+        # object before trying.
+        d = self.__dict__
+        d["_Sampler__kwargs"]["pool"] = None
+        return d
+
     def run_sampler(self):
         import emcee
         tqdm = get_progress_bar()
-- 
GitLab