Skip to content

Commit

Permalink
Update RQ Event Emitter docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdapena committed Mar 25, 2024
1 parent c539635 commit 4da034b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/pyventus/emitters/rq/rq_event_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@

class RQEventEmitter(EventEmitter):
"""
A class that enables event handling using the powerful Redis Queue (RQ) pub/sub and
worker system.
An event emitter subclass that utilizes the Redis Queue system to handle the
execution of event emissions.
This class extends the base `EventEmitter` class and provides the functionality to enqueue
event emissions using the [RQ package](https://python-rq.org/). Once enqueued, these event
emissions are processed by RQ workers. This event emitter is particularly useful when
dealing with events that require resource-intensive tasks like model optimization
or video processing.
**Notes:**
For more information and code examples, please refer to the `RQEventEmitter` tutorials
at: [https://mdapena.github.io/pyventus/tutorials/emitters/rq/](https://mdapena.github.io/pyventus/tutorials/emitters/rq/).
- This class uses a Redis Queue instance to enqueue event emissions, which are
subsequently executed by Redis Queue workers. This approach provides a scalable
and distributed method for handling the execution of event emissions.
---
Read more in the
[Pyventus docs for RQ Event Emitter](https://mdapena.github.io/pyventus/tutorials/emitters/rq/).
"""

def __init__(
Expand All @@ -36,7 +37,7 @@ def __init__(
debug: bool | None = None,
):
"""
Initializes an instance of the `RQEventEmitter` class.
Initialize an instance of `RQEventEmitter`.
:param queue: The Redis queue for enqueuing event handlers.
:param options: Additional options for the RQ package enqueueing method.
Defaults to an empty dictionary.
Expand All @@ -45,19 +46,16 @@ def __init__(
:param debug: Specifies the debug mode for the logger. If `None`, it is
determined based on the execution environment.
"""
# Call the parent class' __init__ method to set up the event linker
# Call the parent class' __init__ method
super().__init__(event_linker=event_linker, debug=debug)

# Validate the queue argument
if queue is None or not isinstance(queue, Queue):
raise PyventusException("The 'queue' argument must be a valid (RQ) queue.")

# Store the RQ queue and options
# Store the Redis queue and RQ options
self._queue: Queue = queue
""" The Redis queue for enqueuing event handlers. """

self._options: Dict[str, Any] = options if options is not None else {}
""" Additional options for the RQ package enqueueing method. """

def _process(self, event_emission: EventEmitter.EventEmission) -> None:
# Add the event emission to the Redis Queue
Expand Down

0 comments on commit 4da034b

Please sign in to comment.