import re import logging from ast import literal_eval from streams import Stream from secop import EnumConvert OP_TELL = '=' OP_ASK = '?' OP_WILDCARD = '*' OP_SUBSCRIBE = ':' OP_UNSUBSCRIBE = '|' OP_TELLOLD = '!' OP_LOCK = '$' OP_REWRITE = '~' OP_LOCK_LOCK = '+' OP_LOCK_UNLOCK = '-' # put flags between key and op... FLAG_NO_STORE = '#' # end/sync special token END_MARKER = '###' SYNC_MARKER = '#sync#' PING = '#ping#' # Time constant CYCLETIME = 0.1 opkeys = OP_TELL + OP_ASK + OP_WILDCARD + OP_SUBSCRIBE + OP_UNSUBSCRIBE + \ OP_TELLOLD + OP_LOCK + OP_REWRITE # regular expression matching a cache protocol message msg_pattern = re.compile(r''' ^ (?: \s* (?P