Question

Trying to avoid having RQ display a warning message (to console) about using the meta dictionary for arbitrary property usage. We are using it as is specified, and the warning continues to display.

The warning displayed is as follows:

/usr/local/lib/python2.7/site-packages/rq/job.py:381: SyntaxWarning: Getting custom properties from the job instance directly will be unsupported as of RQ 0.4. Please use the meta dict to store all custom variables.  So instead of this:

 job.foo

Use this:

 job.meta['foo']

SyntaxWarning)

Basically, it is pretty annoying because it interferes with normal debugging activities.

Any ideas on how to disable this?

Was it helpful?

Solution

Use the built-in warnings module's simplefilter method. Requires use of a context manager. Code example copied wholesale from the linked section:

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()

Further arguments to simplefilter allow you to filter just the warnings you're getting from the specific place in the code you know about-- probably a good idea so other, new warnings that arise later won't be obscured.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top