jobs – Client Job Helpers

class eventmq.client.jobs.Job(broker_addr=None, queue=None, async=True, *args, **kwargs)

Defines a deferred EventMQ job.

Usage:

from eventmq import job

@job(queue='messaging')
def send_email(recipient, subject, message):
    from email.mime.text import MIMEText
    import smtplib

    msg = MIMEText(message)
    msg['Subject'] = subject
    msg['From'] = 'no-reply@foobar.io'
    msg['To'] = recipient

    s = smtplib.SMTP('smtp.gmail.com')

    s.login('me@gmail.com', 'my-app-password')

    s.sendmail('me@gmail.com', [recipient,], msg.as_string())
    s.quit()
__init__(broker_addr=None, queue=None, async=True, *args, **kwargs)
Parameters:
  • queue (str) – Name of the queue this function should be executed in. If no queue provided default is used.
  • broker_addr (str) – Address of the broker to send the job to. If no address is given then the value of the environment variable EMQ_BROKER_ADDR will be used, If that is undefined a warning will be emitted and the job will be run synchronously.
  • async (bool) – If you want to run all executions of a particular job synchronously but still decorate it with the job decorator you can set this to False. This is useful for unit tests.
__weakref__

list of weak references to the object (if defined)

eventmq.client.jobs.job(func, broker_addr=None, queue=None, async=True, *args, **kwargs)

Functional decorator helper for creating a deferred eventmq job. See Job for more information.