I've made sending Pong if there's ping in the message body.
message is received in update_handler. Everything is done like in example. Several answers on Ping are send ok, but after that error is raised. What am I doing wrong?
Exception in thread Updates thread:
Traceback (most recent call last):
File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:\Telethon\Telethon\telethon\network\mtproto_sender.py", line 394, in updates_thread_method
reader)
File "D:\Telethon\Telethon\telethon\network\mtproto_sender.py", line 223, in process_msg
return self.handle_container(msg_id, sequence, reader, request)
File "D:\Telethon\Telethon\telethon\network\mtproto_sender.py", line 277, in handle_container
if not self.process_msg(inner_msg_id, sequence, reader, request):
File "D:\Telethon\Telethon\telethon\network\mtproto_sender.py", line 218, in process_msg
return self.handle_rpc_result(msg_id, sequence, reader, request)
File "D:\Telethon\Telethon\telethon\network\mtproto_sender.py", line 339, in handle_rpc_result
'Cannot receive a request from inside an RPC result from the updates thread.')
ValueError: Cannot receive a request from inside an RPC result from the updates thread.
Related to #27, I'm not sure how to fix this…
I've made sending Pong if there's ping in the message body.
What do you mean?
What do you mean?
In my sample script_client class There's init with connect and run method. With registering update_handler and then endless while loop. Update handler is static function, so inside it I can't have access to self of my class, so I can't call send function there.
I made a queue of received messages that is populated inside update_handler.
In run method inside a while loop there's a check for messages in a queue. If it's len(queue) > 0 I get one element and check message text, so that I can make autoanswer. If text = 'ping' I send back 'pong'. That's all.
The update_handler inside the InteractiveTelegramClient is just an example, it doesn't have to be a @staticmethod if you don't want to. You can remove the @staticmethod part and add a first self parameter to suit your needs.
I moved sending "pong" to update_handler, right after receiving "ping". That helped for a while, but after 20 ping requests in a row it still failed with the same error.... But as you already mentioned it seems to be #27 related. :(
After solving #47 perhaps the introduced changes there also fixed this. Could you please try with the upstream version and provide me some feedback about it?
@Lonami is it possible to update in pip so that I can check it easily?
I would rather you tried the upstream version, please. I would like to test it before releasing a new version out there to the wild, you know?
You can replace the telethon folder with the upstream one (remember to generate the TLObjects), probably located at either of these locations:
/usr/local/lib/python3.5/dist-packages/ if used pip3.~/.local/lib/python3.5/site-packages/ if used pip3 with --user/usr/lib/python3.5/ if used aptOk, I'll give it a try.
Yet, all tests passed without errors! One last test left with 40 simultanious message pins in 40 chats. I'll test in about half an hour and let you know. So far results are very optimistic ;)
Aaaaaaand that's it! Everything works great. So you can release it ))) I'll close the issue
I'm really glad it works better now. I would still expect bugs though ;) Hopefully rare enough.