Description
For instance, this will segfault because the AsyncBucket is connecting in the background...
auth = PasswordAuthenticator(username="Administrator", password="password") |
c = Cluster("couchbase://localhost", ClusterOptions(authenticator=auth)) |
await c.on_connect()
|
b = c.bucket("default") |
# uncomment this, and no crash
|
# await b.on_connect()
|
await c.close()
|
Of course, we can't prevent all racing, but lets think about how to make this better. First off, lets insure close() is being called when a Cluster is deleted, so users never need to call it.
At that point, we can figure out if we want something which helps with this, since it is a misuse of the api, but not an obvious one. Some options:
- c.bucket(...) could return an Awaitable, which makes this scenario not possible
- we could think about holding weak references to the conn object in places we use it (bucket, collection, etc...). There's still a race here though, I believe...
- we could find a way to chain the close off any existing operations (but that sounds difficult/complex, however maybe not?)
- Something else.
This ticket needs to address the close() not being necessary to call - that seems like the first level of defense. We can spawn a new ticket for any ancillary work (perhaps for later), when we decide we need it.
Attachments
Issue Links
- relates to
-
PYCBC-1312 Test issues using cluster.close()
- Resolved
For Gerrit Dashboard: PYCBC-1298 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
173750,1 | PYCBC-1298: Clean up connect and close operations | master | couchbase-python-client | Status: ABANDONED | 0 | +1 |