mpf.core.delays

Delays

MPF contains a Delay Manager.

class mpf.core.delays.DelayManager(registry)

Handles delays for one object

add(ms, callback, name=None, **kwargs)

Adds a delay.

Parameters:
  • ms – Int of the number of milliseconds you want this delay to be for. Note that the resolution of this time is based on your machine’s tick rate. The callback will be called on the first machine tick after the delay time has expired. For example, if you have a machine tick rate of 30Hz, that’s 33.33ms per tick. So if you set a delay for 40ms, the actual delay will be 66.66ms since that’s the next tick time after the delay ends.
  • callback – The method that is called when this delay ends.
  • name – String name of this delay. This name is arbitrary and only used to identify the delay later if you want to remove or change it. If you don’t provide it, a UUID4 name will be created.
  • **kwargs – Any other (optional) kwarg pairs you pass will be passed along as kwargs to the callback method.
Returns:

String name of the delay which you can use to remove it later.

check(delay)

Checks to see if a delay exists.

Parameters:delay – A string of the delay you’re checking for.

Returns: The delay object if it exists, or None if not.

clear()

Removes (clears) all the delays associated with this DelayManager.

remove(name)

Removes a delay. (i.e. prevents the callback from being fired and cancels the delay.)

Parameters:name – String name of the delay you want to remove. If there is no delay with this name, that’s ok. Nothing happens.
reset(name, ms, callback, **kwargs)

Resets a delay, first deleting the old one (if it exists) and then adding new delay with the new settings.

Parameters:as add() (same) –