| 58 | |
| 59 | |
| 60 | class Insert(threading.Thread): |
| 61 | def __init__(self, collection, n, expect_exception): |
| 62 | threading.Thread.__init__(self) |
| 63 | self.collection = collection |
| 64 | self.n = n |
| 65 | self.expect_exception = expect_exception |
| 66 | self.daemon = True |
| 67 | |
| 68 | def run(self): |
| 69 | for _ in range(self.n): |
| 70 | error = True |
| 71 | |
| 72 | try: |
| 73 | self.collection.insert_one({"test": "insert"}) |
| 74 | error = False |
| 75 | except: |
| 76 | if not self.expect_exception: |
| 77 | raise |
| 78 | |
| 79 | if self.expect_exception: |
| 80 | assert error |
| 81 | |
| 82 | |
| 83 | class Update(threading.Thread): |
no outgoing calls