From dc519602ac0f35d39a70c91f0e6057e865a61dfc Mon Sep 17 00:00:00 2001
From: Erik Johnston <erik@matrix.org>
Date: Thu, 18 Jan 2018 11:07:17 +0000
Subject: [PATCH] Ensure we registerProducer isn't called twice

---
 synapse/util/file_consumer.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/synapse/util/file_consumer.py b/synapse/util/file_consumer.py
index 479e480614..d7bbb0aeb8 100644
--- a/synapse/util/file_consumer.py
+++ b/synapse/util/file_consumer.py
@@ -69,6 +69,9 @@ class BackgroundFileConsumer(object):
             streaming (bool): True if push based producer, False if pull
                 based.
         """
+        if self.producer:
+            raise Exception("registerProducer called twice")
+
         self.producer = producer
         self.streaming = streaming
         self.finished_deferred = threads.deferToThread(self._writer)