MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / ~Connection

Method ~Connection

src/connection.cxx:51–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51Connection::~Connection()
52{
53 // lets automatically shutdown the cluster
54 // NOTE: close() is idempotent w/in C++ core, so okay if user has called cluster.close()
55 auto barrier = std::make_shared<std::promise<void>>();
56 auto f = barrier->get_future();
57 cluster_.close([barrier]() {
58 barrier->set_value();
59 });
60 if (f.wait_for(std::chrono::seconds(5)) != std::future_status::ready) {
61 CB_LOG_WARNING("PYCBC: Cluster close timed out in destructor.");
62 }
63
64 io_.stop();
65
66 for (auto& t : io_threads_) {
67 if (t.get_id() == std::this_thread::get_id()) {
68 // Cannot join from the same thread - detach instead to avoid deadlock
69 CB_LOG_DEBUG("PYCBC: dealloc_conn called from IO thread, detaching instead of joining");
70 t.detach();
71 } else {
72 t.join();
73 }
74 }
75}
76
77void
78Connection::handle_connection_operation_callback(std::error_code ec,

Callers

nothing calls this directly

Calls 2

closeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected