Beispiel #1
0
    def test_multiple_writers_save_at_same_time(self):
        blob_hash = self.fake_content_hash
        blob_file = BlobFile(self.blob_dir, blob_hash, self.fake_content_len)
        writer_1, finished_d_1 = blob_file.open_for_writing(peer=1)
        writer_2, finished_d_2 = blob_file.open_for_writing(peer=2)

        blob_file.save_verified_blob(writer_1)
        # second write should fail to save
        yield self.assertFailure(blob_file.save_verified_blob(writer_2), DownloadCanceledError)

        # schedule a close, just to leave the reactor clean
        finished_d_1.addBoth(lambda x:None)
        finished_d_2.addBoth(lambda x:None)
        self.addCleanup(writer_1.close)
        self.addCleanup(writer_2.close)
 def save_verified_blob(self, writer):
     result = BlobFile.save_verified_blob(self, writer)
     if not self.callback.called:
         self.callback.callback(True)
     return result