def test_write_to(self): person = Person(first_name="Granny", last_name="Goose") person.save() person = Person.objects.get_by_id(person.id) person.first_name = 'Pages' pipeline = person.db.pipeline() person.write_to(pipeline) with Mutex(person): pipeline.execute() person = Person.objects.get_by_id(person.id) self.assertEqual('Pages', person.first_name)
def test_lock_expired(self): Mutex(self.p1).lock() with Mutex(self.p2): self.assert_(True)
def f2(person, t): with Mutex(person): t['time'] = time.time()
def f1(person, t): with Mutex(person): time.sleep(0.4) t['time'] = time.time()