Description
Steps to reproduce
-
Set up a bot with a MessageQueue as described in the wiki
-
Override methods send_document, send_photo with @messagequeue.queuedmessage decorator
-
Open file with
context manager
and try to send it
Expected behaviour
Files must be sent to chat as usual, like they do without MessageQueue
Actual behaviour
Files are not sent. As I found, file is closed at the moment it should have sent.
And we have: ValueError: read of closed file
of course.
Why this happens and how to overcome that (steal that topic)
Files are closed before actual send, because send_document returns Promise object instead of message, you know, because it's messagequeue. So that Promise results after context manager close this file.
HotFix: You should wait for promise.result() if you want to close file properly.
Or InputFile should close file after it is done with it, and you don't have to worry about it.
Hope I fill everything right.