exopy.utils.flags module

Thread safe bit flag with convenient interface.

class exopy.utils.flags.BitFlag[source]

Bases: object

Bit flag conveniency class providing thread safety facilities.

Parameters

flags (iterable[unicode]) – Name of the flags that this flag understand.

set(*flags)[source]

Set specified flags.

If a flag is already set this is a no-op. If a thread is waiting on a flag, it gets notified.

clear(*flags)[source]

Clear the specified flags.

If a flag is already cleared this is a no-op.

test(*flags)[source]

Test is all specified flags are set.

wait(timeout, *flags)[source]

Wait till some flags are set.

Parameters
  • timeout (float|None) – Maximum time to wait. If None waits forever.

  • flags (iterable[unicode]) – Flags upon which to wait.

Returns

result – False if the method returned because of the timeout.

Return type

bool

flags