def _submit(self, contracts):
        submitted = set()
        retry = set()

        try:
            with self.submitting_counter(len(contracts)):
                start = time.clock()

                url = '{0}/answer/{1}'.format(self.api_url,
                                              self.token)

                proofs = [c.proof_data for c in contracts]
                contract_dict = {c.hash: c for c in contracts}

                data = {
                    'proofs': proofs
                }
                headers = {
                    'Content-Type': 'application/json',
                    'Content-Encoding': 'gzip'
                }
                json_data = json.dumps(data)

                try:
                    self.logger.debug('{0} proofs being submitted ({1})'
                                      .format(len(proofs),
                                              sizeof_fmt(len(json_data))))
                    resp = self.session.post(url,
                                             data=json_data,
                                             headers=headers,
                                             verify=self.requests_verify_arg)
                except:
                    raise DownstreamError('Unable to perform HTTP post.')

                try:
                    r_json = handle_json_response(resp)
                except:
                    raise DownstreamError(
                        'Challenge answer failed: {0}'
                        .format(str(sys.exc_info()[1])))

                if ('report' not in r_json or not isinstance(r_json['report'],
                                                             list)):
                    raise DownstreamError('Malformed response from server.')

                for contract_report in r_json['report']:
                    if ('file_hash' not in contract_report or
                            contract_report['file_hash']
                            not in contract_dict):
                        # fail nicely with a malformed contract report
                        self.logger.warn('Unexpected contract report.')
                        continue

                    contract = contract_dict[contract_report['file_hash']]

                    if ('error' in contract_report):
                        self.logger.error('Error answering challenge for'
                                          ' contract {0}: {1}'
                                          .format(contract,
                                                  contract_report['error']))
                        continue
                    if ('status' not in contract_report or
                            contract_report['status'] != 'ok'):
                        self.logger.error('No status for contract {0}'
                                          .format(contract))
                        continue

                    # everything seems to be in order for this contract
                    # and now, once a new challenge is obtained, this contract
                    # can be answered again
                    contract.answered = True
                    submitted.add(contract)
                    with self.heartbeat_count_lock:
                        self.heartbeat_count += 1
                        self.thread_manager.stats.set(
                            'heartbeats', self.heartbeat_count)
                        if (self.desired_heartbeats is not None):
                            self.contract_thread.wake()

                stop = time.clock()
                self.logger.info('Submitted {0} proofs successfully in {1} '
                                 'seconds'
                                 .format(len(submitted),
                                         round(stop - start, 3)))
        except:
            self.logger.error('Submission error: {0}'
                              .format(sys.exc_info()[1]))
            # we had an issue submitting these contracts
            # we shall retry until they expire... then they'll
            # get dropped
            retry = set(contracts)

        # place submitted proofs in update queue
        earliest = None
        resubmission_time = datetime.utcnow() \
            + timedelta(seconds=self.retry_interval)
        for c in contracts:
            if (c in retry and c.expiration > resubmission_time):
                self.submission_queue.put(c, resubmission_time)
                continue
            if (c in submitted):
                ready_time = c.expiration
                update_time = (c.expiration +
                               timedelta(seconds=self.update_margin))
                self.update_queue.put(c, update_time, ready_time)
                if (earliest is None or c.expiration < earliest):
                    earliest = c.expiration
                continue
            # otherwise, remove
            self.logger.error('Contract {0} not successfully '
                              'submitted, dropping'.format(c))
            self._remove_contract(c)

        if (earliest is not None):
            self.logger.debug('Earliest submitted contract ready in '
                              '{0} seconds'
                              .format((earliest - datetime.utcnow())
                                      .total_seconds()))

        # and wake heartbeat manager again
        self.heartbeat_thread.wake()
Will return True when user is part of the test group in
dataset/ETHPy150Open StorjOld/downstream-farmer/downstream_farmer/client.py/DownstreamClient._submit--crossover with--dataset/ETHPy150Open e-loue/django-lean/django_lean/experiments/models.py/Experiment.test