notice

This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).

Version: Main/Unreleased

rasa.core.lock

Ticket Objects

class Ticket()

dumps

def dumps() -> Text

Return json dump of Ticket as dictionary.

from_dict

@classmethod
def from_dict(cls, data: Dict[Text, Union[int, float]]) -> "Ticket"

Creates Ticket from dictionary.

TicketLock Objects

class TicketLock()

Locking mechanism that issues tickets managing access to conversation IDs.

Tickets are issued in the order in which they are requested. A detailed explanation of the ticket lock algorithm can be found at http://pages.cs.wisc.edu/~remzi/OSTEP/threads-locks.pdf#page=13

from_dict

@classmethod
def from_dict(cls, data: Dict[Text, Any]) -> "TicketLock"

Create TicketLock from dictionary.

dumps

def dumps() -> Text

Return json dump of TicketLock.

is_locked

def is_locked(ticket_number: int) -> bool

Return whether ticket_number is locked.

Returns:

True if now_serving is not equal to ticket.

issue_ticket

def issue_ticket(lifetime: float) -> int

Issue a new ticket and return its number.

remove_expired_tickets

def remove_expired_tickets() -> None

Remove expired tickets.

last_issued

@property
def last_issued() -> int

Return number of the ticket that was last added.

Returns:

Number of Ticket that was last added. NO_TICKET_ISSUED if no tickets exist.

now_serving

@property
def now_serving() -> Optional[int]

Get number of the ticket to be served next.

Returns:

Number of Ticket that is served next. 0 if no Ticket exists.

is_someone_waiting

def is_someone_waiting() -> bool

Return whether someone is waiting for the lock to become available.

Returns:

True if the self.tickets queue has length greater than 0.

remove_ticket_for

def remove_ticket_for(ticket_number: int) -> None

Remove Ticket for `ticket_number.