Utility for TestPooling. Checks out a socket and holds it forever. Used in test_no_wait_queue_timeout.
| 102 | |
| 103 | |
| 104 | class SocketGetter(MongoTask): |
| 105 | """Utility for TestPooling. |
| 106 | |
| 107 | Checks out a socket and holds it forever. Used in |
| 108 | test_no_wait_queue_timeout. |
| 109 | """ |
| 110 | |
| 111 | def __init__(self, client, pool): |
| 112 | super().__init__(client) |
| 113 | self.state = "init" |
| 114 | self.pool = pool |
| 115 | self.sock = None |
| 116 | |
| 117 | def run_mongo_thread(self): |
| 118 | self.state = "get_socket" |
| 119 | |
| 120 | # Call 'pin_cursor' so we can hold the socket. |
| 121 | with self.pool.checkout() as sock: |
| 122 | sock.pin_cursor() |
| 123 | self.sock = sock |
| 124 | |
| 125 | self.state = "connection" |
| 126 | |
| 127 | def release_conn(self): |
| 128 | if self.sock: |
| 129 | self.sock.unpin() |
| 130 | self.sock = None |
| 131 | return True |
| 132 | return False |
| 133 | |
| 134 | |
| 135 | def run_cases(client, cases): |
no outgoing calls