def test_unique_dictionary_serialization_json(self): queue = UniqueQ(path=self.path, multithreading=True, auto_commit=self.auto_commit, serializer=serializers.json) queue.put({"foo": 1, "bar": 2}) self.assertEqual(queue.total, 1) queue.put({"bar": 2, "foo": 1}) self.assertEqual(queue.total, 1)
class FdfsUploader(object): def __init__(self): self.cli = client.Fdfs_client(client.get_tracker_conf(CONF_FILE)) self.queue = UniqueQ(QUEUE_NAME) def add_to_queue(self, local_file_full_path): self.queue.put(local_file_full_path) self.cli.modify_by_buffer() @staticmethod def start_thread_listen(): t1 = threading.Thread(target=listen_thread) t1.start()
def test_add_duplicate_item(self): q = UniqueQ(self.path) q.put(1111) self.assertEqual(1, q.size) # put duplicate item q.put(1111) self.assertEqual(1, q.size) q.put(2222) self.assertEqual(2, q.size) del q q = UniqueQ(self.path) self.assertEqual(2, q.size)