pytg
pytg copied to clipboard
Problem With bad Internet
Hi there My internet speed is awefull , sometimes it stays in script but it does nothing. and sometimes it come out with error below, Is there any way It load itself after a special time. like every one minute
`Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pytg/sender.py", line 504, in _do_send
answer = self.s.recv(1)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tgDelete.py", line 101, in <module>
main()
File "tgDelete.py", line 42, in main
receiver.message(schedulerDeleter(sender))
File "/usr/lib/python3.6/site-packages/pytg/utils.py", line 29, in start
cr = func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pytg/receiver.py", line 212, in message
function.send(message)
File "tgDelete.py", line 52, in schedulerDeleter
sender.status_online()
File "/usr/lib/python3.6/site-packages/pytg/sender.py", line 630, in command_alias
return self.execute_function(command_name, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/pytg/sender.py", line 320, in execute_function
result = self._do_send(request, answer_timeout=self.default_answer_timeout, retry_connect=retry_connect)
File "/usr/lib/python3.6/site-packages/pytg/sender.py", line 527, in _do_send
raise NoResponse(command)
pytg.exceptions.NoResponse: [disable_preview] status_online
`
You can wrap it in a try
try:
# code here
except pytg.exceptions.NoResponse as e:
# handle the error
And write some code which handles the error (e.g. retry, or restart)