MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / pop

Method pop

couchbase/datastructures.py:956–1018  ·  view source on GitHub ↗

Removes an item from the front of the queue. Args: timeout (timedelta, optional): Amount of time allowed when attempting to remove the value. Defaults to 10 seconds. Returns: Any: The value that was removed from the front of the queue.

(self, timeout: Optional[timedelta] = None)

Source from the content-addressed store, hash-verified

954 create_type=True)
955
956 def pop(self, timeout: Optional[timedelta] = None) -> Any:
957 """Removes an item from the front of the queue.
958
959 Args:
960 timeout (timedelta, optional): Amount of time allowed when attempting
961 to remove the value. Defaults to 10 seconds.
962
963
964 Returns:
965 Any: The value that was removed from the front of the queue.
966 """
967 op_type = DatastructureOperationType.QueuePop
968 with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
969 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
970 if timeout is None:
971 timeout = timedelta(seconds=10)
972
973 timeout_millis = timeout.total_seconds() * 1000
974
975 interval_millis = float(50)
976 start = time.perf_counter()
977 time_left = timeout_millis
978 parent_span = ds_obs_handler.wrapped_span
979 while True:
980 try:
981 kv_op_type = KeyValueOperationType.LookupIn
982 with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
983 op = subdoc_get('[-1]')
984 lookup_in_req, tc = self._impl.request_builder.build_lookup_in_request(self._key,
985 (op,),
986 obs_handler,
987 parent_span=parent_span)
988 sd_res = self._impl.lookup_in(lookup_in_req, tc, obs_handler)
989 val = sd_res.value[0].get('value', None)
990
991 kv_op_type = KeyValueOperationType.MutateIn
992 with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
993 try:
994 op = remove('[-1]')
995 mutate_in_opts = MutateInOptions(cas=sd_res.cas, parent_span=parent_span)
996 mutate_in_req = self._impl.request_builder.build_mutate_in_request(self._key,
997 (op,),
998 obs_handler,
999 mutate_in_opts)
1000 self._impl.mutate_in(mutate_in_req, obs_handler)
1001 return val
1002 except CasMismatchException:
1003 pass
1004
1005 interval_millis += 500
1006 if interval_millis > 1000:
1007 interval_millis = 1000
1008
1009 time_left = timeout_millis - ((time.perf_counter() - start) * 1000)
1010 if interval_millis > time_left:
1011 interval_millis = time_left
1012
1013 if time_left <= 0:

Callers 15

create_cmake_configMethod · 0.45
finalize_optionsMethod · 0.45
build_binding_kv_opMethod · 0.45
build_binding_mgmt_opMethod · 0.45
set_cpp_core_typesMethod · 0.45
as_dictMethod · 0.45
as_dictMethod · 0.45
unregister_profileMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 13

removeFunction · 0.90
MutateInOptionsClass · 0.90
QueueEmptyClass · 0.90
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45
lookup_inMethod · 0.45
getMethod · 0.45
mutate_inMethod · 0.45