docs/how-to/upload-file: example not working, please assist.
Hi @AMontagu and @legau, the file upload example in the how-to is not working: https://github.com/socotecio/django-socio-grpc/blob/master/docs/how-to/upload-file.rst
read_in_chunks should rather return data (I guess) and UploadFile() receives a CancelledError.
To reproduce this behaviour, I created an example in a new feature branch (image-upload): https://github.com/socotecio/django-socio-grpc-example/blob/feature/image-upload/backend/image_upload_client_async.py
Any ideas, why I receive this CancelledError ?
Merci.
Hi, I think, I found a way ... please check the PR https://github.com/socotecio/django-socio-grpc-example/pull/18
Hi @AMontagu and @legau, I applied the same code structure to my large LARAsuite application ... and it failed with the CancelledError:
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError
... somehow the async streaming connection simply shuts down - the server code is not even executed.... I do not understand, why. I hope, you have some ideas, how to make the connection more stable. (I already tried asyncio.shield, but it did not help).
Merci :)
Hello @markdoerr,
I completed the upload exemple on your branch and is working well.
Are you uplaoding back to back or front to back ?
The cancelled error may happen when:
-
front close stream
-
front reload page or change page if stream localy instancied
-
back when the upload script do not wait for the server answer and finish itself between the end of the upload.
If you can provide a minimal reproductible repository I may look further on that
Merci, @AMontagu, for checking (and improving) the example so quickly. Yes I am uploading back-to-back (no front-end involved). I think, the last of your options is very likely. Everything works with the toy bibliography example - but not on my larger system. I will check, if all packages are on the same version and that there is no timing issue, like you guessed, that the client cancels without awaiting answers from the server (this would be still very strange, since I put - as you saw - awaits everywhere and run_until_completion).