Util

check_not_none(val, message)

Tests if an argument is not None.

Parameters:
  • val – (object), the argument tested to see if it is not None.
  • message – (str), the error message.
check_true(val, message)

Tests whether the provided expression is true.

Parameters:
  • val – (bool), the expression tested to see if it is true.
  • message – (str), the error message.
check_not_negative(val, message)

Tests if a value is not negative.

Parameters:
  • val – (Number), the value tested to see if it is not negative.
  • message – (str), the error message.
check_not_empty(collection, message)

Tests if a collection is not empty.

Parameters:
  • collection – (Collection), the collection tested to see if it is not empty.
  • message – (str), the error message.
current_time()

Returns the current time of the system.

Returns:(float), current time of the system.
thread_id()

Returns the current thread’s id.

Returns:(int), current thread’s id.
to_millis(seconds)

Converts the time parameter in seconds to milliseconds. If the given time is negative, returns the original value.

Parameters:seconds – (Number), the given time in seconds.
Returns:(int), result of the conversation in milliseconds.
validate_type(_type)

Validates the type.

Parameters:_type – (Type), the type to be validated.
validate_serializer(serializer, _type)

Validates the serializer for given type.

Parameters:
  • serializer – (Serializer), the serializer to be validated.
  • _type – (Type), type to be used for serializer validation.
class AtomicInteger(initial=0)

Bases: object

AtomicInteger is an Integer which can work atomically.

get_and_increment()

Returns the current value and increment it.

Returns:(int), current value of AtomicInteger.
set(value)

Sets the value of this AtomicInteger. :param value: (int), the new value of AtomicInteger.

class LockReferenceIdGenerator

Bases: object

This class generates unique (per client) incrementing reference id which is used during locking related requests. The server side uses this id to match if any previous request with the same id was issued and shall not re-do the lock related operation but it shall just return the previous result. Hence, this id identifies the request sent to the server side for locking operations. Similarly, if the client re-sends the request to the server for some reason it will use the same reference id to make sure that the operation is not executed more than once at the server side.

get_next()
Returns:(int), A per client unique reference id.
enum(**enums)

Utility method for defining enums. :param enums: Parameters of enumeration. :return: (Enum), the created enumerations.

get_possible_addresses(addresses=[], member_list=[])
get_provider_addresses(providers=[])
parse_addresses(addresses=[])
class ImmutableLazyDataList(list_data, to_object)

Bases: _abcoll.Sequence

get_portable_version(portable, default_version)
class TimeUnit

Bases: object

Represents the time durations at given units in seconds.

NANOSECOND = 1e-09
MICROSECOND = 1e-06
MILLISECOND = 0.001
SECOND = 1.0
MINUTE = 60.0
HOUR = 3600.0
static to_seconds(value, time_unit)
Parameters:
  • value – (Number), value to be translated to seconds
  • time_unit – Time duration in seconds
Returns:

Value of the value in seconds