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

receiver.py crash on recieved message #112

Open
richardramirez opened this issue Mar 17, 2017 · 2 comments
Open

receiver.py crash on recieved message #112

richardramirez opened this issue Mar 17, 2017 · 2 comments

Comments

@richardramirez
Copy link

richardramirez commented Mar 17, 2017

The problem

receiver.py crash on recieved message

Your environment

Component Version
python 2.7.5
pytg   0.4.10  
OS     Linux centos 3.10.0-229.4.2.el7.x86_64 #1 SMP Wed May 13 10:06:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce

sample from github:

from __future__ import unicode_literals

import logging
logging.basicConfig(level=logging.DEBUG)

from pytg import Telegram
tg = Telegram(
    telegram="/usr/bin/telegram-cli",
    pubkey_file="/etc/tg-server.pub")
receiver = tg.receiver
sender = tg.sender

receiver = tg.receiver

from pytg.utils import coroutine
def main_loop():
    while not QUIT:
        msg = (yield) # it waits until it got a message, stored now in msg.
        print("Message: ", msg.text)
        
    #
#

receiver.start()
receiver.message(main_loop())

Expected behaviour

display received message

Actual behaviour

crash with

INFO:pytg:Starting Telegram Executable: "/usr/bin/telegram-cli -R -W -P 4458 -k /etc/tg-server.pub --json --permanent-peer-ids --permanent-peer-ids"
DEBUG:pytg.sender:Parsing raw: Argument help - <command> (needed)
DEBUG:pytg.sender:Sending command >[disable_preview]  help
<
INFO:pytg:CLI did not responde.
change_user_group: can't find the user telegramd to switch to
DEBUG:pytg.sender:Parsing raw: Argument help - <command> (needed)
DEBUG:pytg.sender:Sending command >[disable_preview]  help
<
DEBUG:pytg.sender:Socket Connected.
DEBUG:pytg.sender:All Sent.
INFO:pytg:CLI available.
DEBUG:pytg.receiver:Socket Connected.
DEBUG:pytg.receiver:CLI session registered.
DEBUG:pytg.receiver:Hit end.
DEBUG:pytg.receiver:Received Message: {"user": {"id": "$xxxxxxxxxxxxxxxxxxxxxxx", "first_name": "xxxxxxxxxxxxxxxxxxxxxxx", "username": "xxxxxxxxxxxxxxxxxxxxxxx", "peer_type": "user", "last_name": "xxxxxxxxxxxxxxxxxxxxxxx", "flags": 589825, "peer_id": xxxxxxxxxxxxxxxxxxxxxxx, "print_name": "xxxxxxxxxxxxxxxxxxxxxxx", "phone": "xxxxxxxxxxxxxxxxxxxxxxx"}, "online": true, "when": "2017-03-17 13:30:34", "state": 1, "event": "online-status"}
DEBUG:pytg.receiver:Received Message: "{"user": {"id": "$xxxxxxxxxxxxxxxxxxxxxxx", "first_name": "xxxxxxxxxxxxxxxxxxxxxxx", "username": "xxxxxxxxxxxxxxxxxxxxxxx", "peer_type": "user", "last_name": "xxxxxxxxxxxxxxxxxxxxxxx", "flags": 589825, "peer_id": xxxxxxxxxxxxxxxxxxxxxxx, "print_name": "xxxxxxxxxxxxxxxxxxxxxxx", "phone": "xxxxxxxxxxxxxxxxxxxxxxx"}, "online": true, "when": "2017-03-17 13:30:34", "state": 1, "event": "online-status"}"
DEBUG:pytg.receiver:Hit end.
DEBUG:pytg.receiver:skipping second linebreak.
DEBUG:pytg.receiver:Messages waiting in queue: 0
**Traceback (most recent call last):
  File "telegram.py", line 30, in <module>
    receiver.message(main_loop())
  File "/opt/pytg/pytg/utils.py", line 29, in start
    cr = func(*args, **kwargs)
  File "/opt/pytg/pytg/receiver.py", line 212, in message
    function.send(message)
TypeError: can't send non-None value to a just-started generator**
INFO:pytg.sender:Quit Sending. Not allowing sending anymore.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
INFO:pytg:Closing Connections.
DEBUG:pytg:Closing sender.
DEBUG:pytg.sender:Already did quit Sending. Not allowing sending.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
DEBUG:pytg:Closing sender.
DEBUG:pytg.receiver:receiver thread existing: True
INFO:pytg:Asking to CLI to stop.
DEBUG:pytg:Sender already stopped. Unable to issue safe_quit or quit to exit via socket.
Exception in thread Receiver (pytg):
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 811, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 764, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/pytg/pytg/receiver.py", line 125, in _receiver
    raise ConnectionError("Remote end closed.")
ConnectionError: Remote end closed.

INFO:pytg:CLI did stop (0).
DEBUG:pytg.sender:Already did quit Sending. Not allowing sending.

if i comment out function.send(message) line from receiver.py it works without problem. I can see incoming messages in debug log.

@luckydonald
Copy link
Owner

The line change_user_group: can't find the user telegramd to switch to is strange. There is no part on pytg side which does that...

@luckydonald
Copy link
Owner

This seems related to #81

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