How should celery handle database links (psycopg2) in prefork mode?

problem description

celery uses prefork mode (4 processes) and is used in conjunction with psycopg2. Each startup can successfully complete a celery task. InterfaceError: cursor already closed appears when the second task is carried out. What should be done?

what methods have you tried

as you can see in the psycopg2 document , this library should not be used in forked process. So I"m a little confused, is it because of celery"s prefork mode that caused the problem? So how should I handle it? Do you need to create a new database link in each celery task and turn it off after you finish it?

Mar.28,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37dbe-2c0e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37dbe-2c0e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?