I have a simple function in tasks.py
which takes a screenshot of a webpage using CutyCapt and xvfb-run. The screenshot is taken as a command fed through to the OS
python library. I also have another script called call.py
which calls the function.
This function works perfectly when I run it just as a regular function from call.py
(it visits the webpage, takes the screenshot, and saves it in a local folder) but when I add the .delay
and it runs it in celery, I get the following error:
[2016-12-21 13:17:52,649: INFO/MainProcess] Connected to amqp://*******************************
[2016-12-21 13:17:52,851: INFO/MainProcess] mingle: searching for neighbors
[2016-12-21 13:17:54,665: INFO/MainProcess] mingle: all alone
[2016-12-21 13:17:55,469: INFO/MainProcess] celery@myubuntucomputer ready.
[2016-12-21 13:18:01,470: CRITICAL/MainProcess] Can't decode message body: ContentDisallowed(u'Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)',) [type:'application/x-python-serialize' encoding:'binary' headers:{}]
body: '\x80\x02}q\x01(U\x07expiresq\x02NU\x03utcq\x03\x88U\x04argsq\x04U http://www.reddit.com/q\x05\x85q\x06U\x05chordq\x07NU\tcallbacksq\x08NU\x08errbacksq\tNU\x07tasksetq\nNU\x02idq\x0bU$518f96eb-e132-4261-984b-255fcb5b2252q\x0cU\x07retriesq\rK\x00U\x04taskq\x0eU\x15tasks.take_screenshotq\x0fU\ttimelimitq\x10NN\x86U\x03etaq\x11NU\x06kwargsq\x12}q\x13U\nserializerq\x14U\x06pickleq\x15su.' (278b)
Traceback (most recent call last):
File "/usr/local/Desktop/celery/venv/local/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 551, in on_task_received
payload = message.decode()
File "/usr/local/Desktop/celery/venv/local/lib/python2.7/site-packages/kombu/message.py", line 192, in decode
self._decoded_cache = self._decode()
File "/usr/local/Desktop/celery/venv/local/lib/python2.7/site-packages/kombu/message.py", line 197, in _decode
self.content_encoding, accept=self.accept)
File "/usr/local/Desktop/celery/venv/local/lib/python2.7/site-packages/kombu/serialization.py", line 253, in loads
raise self._for_untrusted_content(content_type, 'untrusted')
ContentDisallowed: Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)
I am not calling/setting any deserialization preferences at the moment in my code.
When I run the function on it's own the typical output I get (if it's working) looks like:
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
I'm wondering if this output is the problem ... I have tried hiding any error output from the screenshot command, but cutycapt still throws the same deserialization error. Other functions in tasks.py
do not throw the same error. Any ideas?