- Notifications
You must be signed in to change notification settings - Fork5.7k
Description
Steps to Reproduce
- Download any file that is more 1gb from the internet,
- I tried to upload a video, a
.mkv
file, - try to upload to a group with
FilesBot.send_docuemnt
(I have put a link to FilesBot program or class at the end, it is in additional context).
Expected behaviour
Libary should send the file to Local server, then local server should process the file and upload it to group while libaray should return the result
Actual behaviour
No error nor exception, everthing just stop.
Operating System
ubuntu 22LTS on github codespace
Version of Python, python-telegram-bot & dependencies
python-telegram-bot 21.1.1 (0.1.5-18-g067c55a)Bot API 7.2Python 3.10.13 (main, Mar 5 2024, 18:35:01) [GCC 9.4.0]
Relevant log output
LoggeneartedbyFilesBot.send_document2024-07-1009:31:56,459-asyncio-DEBUG-Usingselector:EpollSelector-/usr/local/python/3.10.13/lib/python3.10/asyncio/selector_events.py:54function__init__process:7013module:selector_events2024-07-1009:31:56,461-httpx-DEBUG-load_ssl_contextverify=Truecert=Nonetrust_env=Truehttp2=False-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpx/_config.py:80functionload_ssl_contextprocess:7013module:_config2024-07-1009:31:56,462-httpx-DEBUG-load_verify_locationscafile='/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/certifi/cacert.pem'-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpx/_config.py:146functionload_ssl_context_verifyprocess:7013module:_config2024-07-1009:31:56,483-httpx-DEBUG-load_ssl_contextverify=Truecert=Nonetrust_env=Truehttp2=False-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpx/_config.py:80functionload_ssl_contextprocess:7013module:_config2024-07-1009:31:56,484-httpx-DEBUG-load_verify_locationscafile='/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/certifi/cacert.pem'-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpx/_config.py:146functionload_ssl_context_verifyprocess:7013module:_config2024-07-1009:31:56,489-root-INFO-Gettingbotdelayforgroup-/workspaces/[redacted]/utils/database.py:362functiongetBotDelayprocess:7013module:database2024-07-1009:31:56,507-root-INFO-Makingrequesttohttp://[redacted]/?action=get-bot-delay&query=group&by=%40[redacted]withmethodGET-/workspaces/[redacted]/utils/utils.py:69functionmake_requestprocess:7013module:utils2024-07-1009:31:56,517-urllib3.connectionpool-DEBUG-StartingnewHTTPconnection (1): [redacted]-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/urllib3/connectionpool.py:244function_new_connprocess:7013module:connectionpool2024-07-1009:31:56,605-urllib3.connectionpool-DEBUG-http://[redacted]"GET /?action=get-bot-delay&query=group&by=%40[redacted] HTTP/1.1"20026-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/urllib3/connectionpool.py:549function_make_requestprocess:7013module:connectionpool2024-07-1009:31:56,606-root-INFO-Botdelayforgroupis0.0-/workspaces/[redacted]/utils/database.py:369functiongetBotDelayprocess:7013module:database2024-07-1009:31:56,607-root-INFO-Uploadingfilevideo.mvk[1.6gbfile]togroup-/workspaces/[redacted]/bot/filesbot.py:195functionsend_documentprocess:7013module:filesbot2024-07-1009:32:06,078-telegram.Bot-DEBUG-CallingBotAPIendpoint`sendDocument`withparameters`{'chat_id': '@[redacted]', 'document': <telegram._files.inputfile.InputFile object at 0x7cb7f50d3bc0>, 'disable_content_type_detection': True, 'disable_notification': True, 'caption': 'video at lagos store 1.1.3'}`-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/telegram/_bot.py:643function_do_postprocess:7013module:_bot2024-07-1009:32:06,100-httpcore.connection-DEBUG-connect_tcp.startedhost='[redacted]'port=8080local_address=Nonetimeout=1800socket_options=None-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpcore/_trace.py:85functionatraceprocess:7013module:_trace2024-07-1009:32:06,118-httpcore.connection-DEBUG-connect_tcp.completereturn_value=<httpcore._backends.anyio.AnyIOStreamobjectat0x7cb7f5089210>-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpcore/_trace.py:85functionatraceprocess:7013module:_trace2024-07-1009:32:06,119-httpcore.http11-DEBUG-send_request_headers.startedrequest=<Request [b'POST']>-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpcore/_trace.py:85functionatraceprocess:7013module:_trace2024-07-1009:32:06,120-httpcore.http11-DEBUG-send_request_headers.complete-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpcore/_trace.py:85functionatraceprocess:7013module:_trace2024-07-1009:32:06,120-httpcore.http11-DEBUG-send_request_body.startedrequest=<Request [b'POST']>-/home/codespace/.cache/pypoetry/virtualenvs/[redacted]/lib/python3.10/site-packages/httpcore/_trace.py:85functionatraceprocess:7013module:_trace
Additional Context
the filesbot program isthis.send_document
is the one uploading the video
I was able to upload the file after some time, i also used a third party libarayrequest toolbelt
asyncdefsendDocumentRaw(self,path:str,filename:str,caption="",retries:int=0 )->int:""" Sends a document to a group chat. Args: path (str): The path to the document file `Warning: this will remove the file after sending it.`. filename (str): The name of the document file. caption (str, optional): The caption for the document. Defaults to "". retries (int, optional): The number of retries in case of failure. Defaults to 0. Returns: int: The message ID of the sent document, or 0 if an error occurred. """logger=self.loggerlogger.info(f"Uploading file{filename} to group")returnData:int=0awaitasyncio.sleep(self.database.getBotDelay("group",self._group_name))try:ifos.path.exists(path):url=f"{self._server}{self._token}/sendDocument"encoder=MultipartEncoder(fields={"chat_id":self._group_name,"caption":caption,"disable_notification":"true","document": (filename,open(path,"rb"),"text/plain"), } )response=requests.post(url,data=encoder,headers={"Content-Type":encoder.content_type} )ifresponse.status_code==200:returnData=response.json()["result"]["message_id"]logger.info(f"file{filename} uploaded to group")else:respondJson=response.json()if"description"inrespondJson:if"bad request"inrespondJson["description"].lower():ifretries<self.maxRetries:retries+=1logger.warning(f"A retry after error occurred while trying to upload file , retrying in{self.retryIn} seconds" )awaitasyncio.sleep(self.retryIn)returnData=awaitself.sendDocumentRaw(path,filename,caption,retries )else:logger.error(f"An error occurred while trying to upload file max retries reached, could not get message id respond is :{response.text}" )returnData=0else:logger.error(f"An error occurred while trying to upload file, could not get message id respond is :{response.text}" )returnData=0else:logger.error(f"An error occurred while trying to upload file, could not get message id respond is :{response.text}" )returnData=0else:returnData=0logger.error(f"An error occurred while trying to upload file, file{path} does not exist" )exceptExceptionase:ifretries<self.maxRetries:retries+=1logger.warning(f"A retry after error occurred while trying to upload file , retrying in{self.retryIn} seconds" )awaitasyncio.sleep(self.retryIn)returnData=awaitself.sendDocumentRaw(path,filename,caption,retries )else:logger.exception(f"An error occurred while trying to upload file{e}")returnData=0finally:try:os.remove(path)logger.info(f"file{path} deleted")exceptExceptionase:logger.warning(f"unable to delete file{path}")returnreturnData
Metadata
Metadata
Assignees
Labels
No labels