diff --git a/instana/collector/base.py b/instana/collector/base.py index ba2c73c3f..bdd767e7e 100644 --- a/instana/collector/base.py +++ b/instana/collector/base.py @@ -150,16 +150,11 @@ def prepare_and_report_data(self): Prepare and report the data payload. @return: Boolean """ - if env_is_test is False: - lock_acquired = self.background_report_lock.acquire(False) - if lock_acquired: - try: - payload = self.prepare_payload() - self.agent.report_data_payload(payload) - finally: - self.background_report_lock.release() - else: - logger.debug("prepare_and_report_data: Couldn't acquire lock") + if env_is_test: + return True + with self.background_report_lock: + payload = self.prepare_payload() + self.agent.report_data_payload(payload) return True def prepare_payload(self):