第一个任务正常,但之后每个任务都会出现此错误 -
[2018-06-15 16:39:25,960: ERROR/MainProcess] Task export.pentabarf[a6d4977c-a4ec-4819-97c5-1c9ef6c20dd2] raised unexpected: OperationalError('(psycopg2.OperationalError) SSL error: decryption failed or bad record mac\n',)
Traceback (most recent call last):
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/mayank/OpenSource/open-event-server/app/api/helpers/request_context_task.py", line 46, in __call__
result = call()
File "/home/mayank/OpenSource/open-event-server/app/api/helpers/request_context_task.py", line 32, in <lambda>
call = lambda: super(RequestContextTask, self).__call__(*args, **kwargs)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/home/mayank/OpenSource/open-event-server/app/api/helpers/tasks.py", line 167, in export_pentabarf_task
event = safe_query(db, Event, 'id', event_id, 'event_id')
File "/home/mayank/OpenSource/open-event-server/app/api/helpers/db.py", line 46, in safe_query
record = self.session.query(model).filter(getattr(model, column_name) == value).one()
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2814, in one
ret = self.one_or_none()
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2784, in one_or_none
ret = list(self)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
return self._execute_and_instances(context)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
compiled_sql, distilled_params
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
context)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
exc_info
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
context)
File "/home/mayank/anaconda3/envs/openevent3/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL error: decryption failed or bad record mac
[SQL: 'SELECT events.id AS events_id, events.identifier AS events_identifier, events.name AS events_name, events.external_event_url AS events_external_event_url, events.logo_url AS events_logo_url, events.starts_at AS events_starts_at, events.ends_at AS events_ends_at, events.timezone AS events_timezone, events.latitude AS events_latitude, events.longitude AS events_longitude, events.location_name AS events_location_name, events.searchable_location_name AS events_searchable_location_name, events.description AS events_description, events.original_image_url AS events_original_image_url, events.thumbnail_image_url AS events_thumbnail_image_url, events.large_image_url AS events_large_image_url, events.icon_image_url AS events_icon_image_url, events.organizer_name AS events_organizer_name, events.is_map_shown AS events_is_map_shown, events.has_organizer_info AS events_has_organizer_info, events.organizer_description AS events_organizer_description, events.is_sessions_speakers_enabled AS events_is_sessions_speakers_enabled, events.privacy AS events_privacy, events.state AS events_state, events.event_type_id AS events_event_type_id, events.event_topic_id AS events_event_topic_id, events.event_sub_topic_id AS events_event_sub_topic_id, events.ticket_url AS events_ticket_url, events.code_of_conduct AS events_code_of_conduct, events.schedule_published_on AS events_schedule_published_on, events.is_ticketing_enabled AS events_is_ticketing_enabled, events.deleted_at AS events_deleted_at, events.payment_country AS events_payment_country, events.payment_currency AS events_payment_currency, events.paypal_email AS events_paypal_email, events.is_tax_enabled AS events_is_tax_enabled, events.can_pay_by_paypal AS events_can_pay_by_paypal, events.can_pay_by_stripe AS events_can_pay_by_stripe, events.can_pay_by_cheque AS events_can_pay_by_cheque, events.can_pay_by_bank AS events_can_pay_by_bank, events.can_pay_onsite AS events_can_pay_onsite, events.cheque_details AS events_cheque_details, events.bank_details AS events_bank_details, events.onsite_details AS events_onsite_details, events.created_at AS events_created_at, events.pentabarf_url AS events_pentabarf_url, events.ical_url AS events_ical_url, events.xcal_url AS events_xcal_url, events.is_sponsors_enabled AS events_is_sponsors_enabled, events.discount_code_id AS events_discount_code_id \nFROM events \nWHERE events.id = %(id_1)s'] [parameters: {'id_1': '24'}]
芹菜初始化是:
def make_celery(app):
celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
task_base = celery.Task
class ContextTask(task_base):
abstract = True
def __call__(self, *args, **kwargs):
if current_app.config['TESTING']:
with app.test_request_context():
return task_base.__call__(self, *args, **kwargs)
with app.app_context():
return task_base.__call__(self, *args, **kwargs)
celery.Task = ContextTask
return celery
celery = make_celery(current_app)
我正在使用的任务如下:
@celery.task(base=RequestContextTask, name='export.event', bind=True)
def export_event_task(self, email, event_id, settings):
event = safe_query(db, Event, 'id', event_id, 'event_id')
user = db.session.query(User).filter_by(email=email).first()
try:
logging.info('Exporting started')
path = event_export_task_base(event_id, settings)
# task_id = self.request.id.__str__() # str(async result)
download_url = path
result = {
'download_url': download_url
}
logging.info('Exporting done.. sending email')
send_export_mail(email=email, event_name=event.name, download_url=download_url)
send_notif_after_export(user=user, event_name=event.name, download_url=download_url)
except Exception as e:
print(traceback.format_exc())
result = {'__error': True, 'result': str(e)}
logging.info('Error in exporting.. sending email')
send_export_mail(email=email, event_name=event.name, error_text=str(e))
send_notif_after_export(user=user, event_name=event.name, error_text=str(e))
return result
RequestContextTask 取自https://gist.github.com/aviaryan/8620390d832678f0de4528bbc4b4b272
我不知道我在这里失踪了什么。我尝试了Github回购中提到的所有解决方案但没有工作。