Celery and Sybase SQL Anywhere
source link: https://hynek.me/articles/celery-and-sybase/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Celery and Sybase SQL Anywhere
In our newest installation of “why you should not use Sybase SQL Anywhere” I’d like to report the latest problem I had to solve: for some reason, I couldn’t connect using sqlanydb from Celery tasks.
I had code that worked fine if ran from plain Python, but barfed from a celery worker task with the ominous error:
OperationalError: Failed to initialize connection object
Turns out, sqlanydb
isn’t only not thread safe; it’s also not fork safe.
The possible solutions:
- Import the driver inside of your task function.
- Use
on_worker_process_init()
(untested).
Hynek Schlawack
In ❤️ with Python 🐍 & Go 🐹, blogger 📝, speaker 📢, PSF fellow 🏆, #RoamCult Believer 𐃏, big city beach bum 🏄🏻.
Is my content helpful and/or enjoyable to you? Please consider supporting me! Every bit helps to motivate me in creating more.
If you’re not into RSS, but would like to be notified about new content (along with exclusive “director’s commentary” about what I did and why), check out my extremely low-volume “Hynek Did Something” newsletter.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK