# `ThreadDict`

digraph inheritance6b35506f62 { bgcolor=transparent; rankdir=UD; ratio=compress; size="8.0, 12.0"; "ThreadDict" [URL="#taurus.core.util.containers.ThreadDict",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="Thread safe dictionary with redefinable read/write methods and a"]; }

class ThreadDict(other=None, read_method=None, write_method=None, timewait=0.1, threaded=True)

  Thread safe dictionary with redefinable read/write methods and a background thread for hardware update. All methods are thread-safe using @self_lock decorator.

  Note

  any method decorated in this way CANNOT call other decorated methods! All values of the dictionary will be automatically updated in a separate Thread using read_method provided. Any value overwritten in the dict should launch the write_method.

  Briefing:

      a[2] equals to a[2]=read_method(2)
      a[2]=1 equals to a[2]=write_method(2,1)

  Import from `taurus.core.util.containers` as:

      from taurus.core.util.containers import ThreadDict

  alive()
  append(*args, **kwargs)
  copy(*args, **kwargs)

    Return a shallow copy of the dict.

  get(*args, **kwargs)

    Return the value for key if key is in the dictionary, else default.

  get_last_cycle_start(*args, **kwargs)
  get_last_update(*args, **kwargs)
  get_timewait(*args, **kwargs)
  items(*args, **kwargs)

    Return a set-like object providing a view on the dict’s items.

  keys(*args, **kwargs)

    Return a set-like object providing a view on the dict’s keys.

  pop(k[, d]) → v, remove specified key and return the corresponding value.

    If the key is not found, return the default if given; otherwise, raise a KeyError.

  run()
  set_last_cycle_start(*args, **kwargs)
  set_last_update(*args, **kwargs)
  set_timewait(*args, **kwargs)
  start()
  stop()
  threadkeys(*args, **kwargs)
  tracer(text)
  update([E, ]**F) → None. Update D from mapping/iterable E and F.

    If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

  values(*args, **kwargs)

    Return an object providing a view on the dict’s values.