Open IshanMi opened 3 years ago
Yes this was because it seems you cannot pass a list of objects to a task (here a list of US patent objects): https://stackoverflow.com/questions/50666990/how-to-send-django-objects-to-celery-tasks https://stackoverflow.com/questions/49373825/kombu-exceptions-encodeerror-user-is-not-json-serializable
So I had to redefine the signature of the function a bit (not happy yet about it but hey)
More importantly I also needed to restructure the code, particularly moving app.py into src/ and making the app object more reusable. I will shoot you a PR and let you decide if you want to merge it or not.
Now the search returns much faster and Celery does the downloading asynchronously:
I ran this like: celery -A src.patent_fetcher worker --loglevel=DEBUG
Code changes: https://github.com/IshanMi/reverse-image-search-patent/pull/13#pullrequestreview-697542122
I tried adding the celery.task decorator to the download_patents function in patent_fetcher.py, but ran into an error: