Skip to content
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

docs/how-to/upload-file: example not working, please assist. #265

Open
markdoerr opened this issue Feb 11, 2024 · 4 comments
Open

docs/how-to/upload-file: example not working, please assist. #265

markdoerr opened this issue Feb 11, 2024 · 4 comments
Assignees

Comments

@markdoerr
Copy link
Contributor

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.

@markdoerr
Copy link
Contributor Author

markdoerr commented Feb 11, 2024

Hi, I think, I found a way ... please check the PR socotecio/django-socio-grpc-example#18

@markdoerr
Copy link
Contributor Author

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 :)

@AMontagu
Copy link
Collaborator

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

@markdoerr
Copy link
Contributor Author

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).

@AMontagu AMontagu self-assigned this Feb 13, 2024
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

2 participants