diff --git a/bilby/core/prior.py b/bilby/core/prior.py
index c1a11013e1e86b76bafcc86de649f41e82ccf5f0..63f38004cfd5d3ec174b88008c7d97c54b30368a 100644
--- a/bilby/core/prior.py
+++ b/bilby/core/prior.py
@@ -348,9 +348,15 @@ class PriorDict(dict):
                     return sample
         else:
             needed = np.prod(size)
+            constraint_keys = list()
+            for ii, key in enumerate(keys[-1::-1]):
+                if isinstance(self[key], Constraint):
+                    constraint_keys.append(-ii - 1)
+            for ii in constraint_keys[-1::-1]:
+                del keys[ii]
             all_samples = {key: np.array([]) for key in keys}
             _first_key = list(all_samples.keys())[0]
-            while len(all_samples[_first_key]) <= needed:
+            while len(all_samples[_first_key]) < needed:
                 samples = self.sample_subset(keys=keys, size=needed)
                 keep = np.array(self.evaluate_constraints(samples), dtype=bool)
                 for key in samples: