Queue

The Queue module provides a flexible, reliable means of managing a stream of data within your application. Users can effortlessly enqueue messages, ensuring that no data is lost or overlooked. Later, these messages can be consumed at a pace that suits the workflow, offering a seamless integration of production and consumption processes.

This documentation will be your reference for using the Queue module from Lepton AI. If you are using python SDK, make sure you are logged in via lep login command with the workspace token. You can find it under settings page

Create Queue

How to initialize and set up a new queue for storing and managing data.

from leptonai.queue import Queue
# Craete queue
my_queue = Queue("somequeue", create_if_not_exists=True)

List Queues

View and enumerate all existing queues.

from leptonai.queue import Queue
# List queues
my_queue = Queue.list_queue()
# this will return a queue name

Send message to a queue

Add new messages to a queue for processing or storage.

from leptonai.queue import Queue
# Fetch the queue by name
my_queue = Queue("somequeue", create_if_not_exists=True)
# Send message to the queue
my_queue.send('this is a message')

Get message to a queue

Retrieve messages waiting in the queue.

from leptonai.queue import Queue
# Fetch the queue by name
my_queue = Queue("somequeue", create_if_not_exists=True)
# Send message to the queue
my_queue.receive()

Get Queue Length

Find out how to quickly retrieve the number of items currently waiting in the queue.

from leptonai.queue import Queue
# Get length of a queue
Queue.length('somequeue')

Delete queue

Understand the steps and precautions needed to safely remove an existing queue and its contents.

from leptonai.queue import Queue
# Delete queue
Queue.delete_queue('somequeue')
Lepton AI

© 2024