Sunday, May 20, 2018

Python Celery MySQL results error

While trying to store Celery results in a MySQL database I received the following error:

Native table 'performance_schema'.'session_variables' has the wrong structure")

After some searching I found something that said to run 'mysql_upgrade -u root -p' then restart MySQL, this fixed the issue for me. The order in which things were done:

  • MySQL was installed using brew on OS/X 10.13.4 (mysqld  Ver 5.7.22 for osx10.13 on x86_64 (Homebrew))
  • mysql.server start
  • mysql_upgrade -u root -p
  • mysql.server stop
  • mysql.server start
The Celery code:

#!/usr/bin/env python
from celery import Celery

app = Celery('tasks', \
        broker='pyamqp://guest@localhost//', \
        backend='db+mysql://root:password@localhost/pigpen')

@app.task
def add(x, y):
    return x + y

Celery output worker side:

celery@dy-mac.local v4.2.0rc3 (windowlicker)

Darwin-17.5.0-x86_64-i386-64bit 2018-05-20 15:20:01

[config]
.> app:         tasks:0x10e073590
.> transport:   amqp://guest:**@localhost:5672//
.> results:     mysql://root:**@localhost/pigpen
.> concurrency: 8 (prefork)
.> task events: OFF (enable -E to monitor tasks in this worker)

[queues]
.> celery           exchange=celery(direct) key=celery


[tasks]
  . tasks.add

[2018-05-20 15:20:02,927: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2018-05-20 15:20:02,941: INFO/MainProcess] mingle: searching for neighbors
[2018-05-20 15:20:04,071: INFO/MainProcess] mingle: all alone
[2018-05-20 15:20:04,117: INFO/MainProcess] celery@dy-mac.local ready.
[2018-05-20 15:20:32,312: INFO/MainProcess] Received task: tasks.add[9a6c0983-64cf-4053-a64f-04894704badf]
[2018-05-20 15:20:33,263: WARNING/ForkPoolWorker-5] /Users/dyoung2/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/default.py:507: Warning: Invalid utf8 character string: '80024B'
  cursor.execute(statement, parameters)
[2018-05-20 15:20:33,266: INFO/ForkPoolWorker-5] Task tasks.add[9a6c0983-64cf-4053-a64f-04894704badf] succeeded in 0.950585585s: 6

Python client side results:

Python 2.7.13 |Anaconda 4.3.1 (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from tasks import *
>>> result = add.delay(3,3)
>>> result.status
'SUCCESS'
>>> result.ready()
True
>>> result.get()
6



No comments:

Post a Comment

Current Audible Reading List

Title You Never Forget Your First: A Biography of George Washington A Self-Made Man: The Politica...