Skip to content

Import a models.Model custom database entity model. Error:KeyError: 'export_zip_task' #1671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vnsun opened this issue May 24, 2024 · 0 comments

Comments

@vnsun
Copy link

vnsun commented May 24, 2024

hi, I introduced the django_uwsgi library in my project
Simple tasks are executing fine, when I introduce the database model class in the task.py file, it starts reporting errors
no import model success
image

import model error
image

  • Environment: uwsgi+django

Here is my configuration and code

config uwsgi.ini

`
socket=127.0.0.1:18089

django_projects_dir = /mnt/qa

my_project = qa

processes=4

threads=2
workers=4
master=True
wsgi-file=qa/wsgi.py
module=django.core.handlers:WSGIHandler()
spooler=%(chdir)/mytasks
import=task
`

code

`
from task import export_zip_task

export_zip_task.spool(v1=base64.b64encode(serialized_q_object).decode('utf-8'), v2='This is param test')

`

`
import base64
import pickle

from django_uwsgi.decorators import spool

from qc.models import TaskLog

@spool
def export_zip_task(arguments):
print("----1111111111111:", arguments)
for i in range(10):
print(i)
print(f'---------2222222222', arguments['v2'])
base64_decode = base64.b64decode(arguments['v1'])
# 反序列化 Q 对象
v1_obj = pickle.loads(base64_decode)
file_id = v1_obj['file_id']
file_path = v1_obj['file_path']
print(f'-------3333333333 file_id:{file_id} file_path:{file_path}')
task_operate_log = TaskLog(file_id=file_id, task_name='downlioad',
file_name=file_path[file_path.rfind('/')+1:],
process_total=200)
task_operate_log.save()

`

I don't know how to manipulate the database model in the spool task
I hope this can be answered, preferably with an example, because I've tried a lot but it doesn't work!
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant