pyrogram / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
4.39k stars 1.42k forks source link

Issue with Client() run #449

Closed samthesuperhero closed 4 years ago

samthesuperhero commented 4 years ago

Dear maintainers,

trying to connect the bot with asyncio version,

and the process is just freezes after: Is "..................." correct? (y/N): y

tried at:

do you have any ideas what I should check ?

Thank you!!

Code:

# coding=utf-8
"""
Learning the asyncio ;)
"""
import signal
from pyrogram import Client

if __name__ == "__main__":
    app = Client("samthesuperherobot")
    app.run()

Below debugger output,

C:\Python38\python.exe -X dev F:\PyCharm\plugins\python\helpers\pydev\pydevd.py --multiproc --save-signatures --qt-support=auto --client 127.0.0.1 --port 51837 --file G:/dev/py/aiolearn/aiolearn.py
pydev debugger: process 12520 is connecting
Connected to pydev debugger (build 202.6397.98)
C:\Python38\lib\site-packages\async_lru.py:96: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
  def _wait_closed(wrapped, *, return_exceptions, loop):
C:\Python38\lib\site-packages\async_lru.py:191: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
  def wrapped(*fn_args, **fn_kwargs):
Executing <Task pending name='Task-1' coro=<Client.start() running at C:\Python38\lib\site-packages\pyrogram\client\client.py:833> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000002B10E450750>()] created at C:\Python38\lib\asyncio\base_events.py:422> cb=[_run_until_complete_cb() at C:\Python38\lib\asyncio\base_events.py:184] created at C:\Python38\lib\asyncio\base_events.py:595> took 1.219 seconds
Pyrogram v0.18.0-async, Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Executing <Task pending name='Task-1' coro=<Client.start() running at C:\Python38\lib\site-packages\pyrogram\client\client.py:833> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000002B10E47ED90>()] created at C:\Python38\lib\asyncio\base_events.py:422> cb=[_run_until_complete_cb() at C:\Python38\lib\asyncio\base_events.py:184] created at C:\Python38\lib\asyncio\base_events.py:595> took 0.187 seconds
WARNING:asyncio:Executing <Task pending name='Task-9' coro=<Session.net_worker() running at C:\Python38\lib\site-packages\pyrogram\session\session.py:223> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x000002B10E4CCC10>()] created at C:\Python38\lib\asyncio\base_events.py:422> created at C:\Python38\lib\site-packages\pyrogram\session\session.py:126> took 0.156 seconds
Enter phone number or bot token: >? +++++++ MY BOT TOKEN HERE +++++++
WARNING:asyncio:Executing <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...events.py:461>) created at C:\Python38\lib\asyncio\windows_events.py:87> took 0.453 seconds
WARNING:asyncio:Executing <TimerHandle when=5336.765 _release_waiter(<Future finis...events.py:422>) at C:\Python38\lib\asyncio\tasks.py:429 created at C:\Python38\lib\asyncio\tasks.py:467> took 0.468 seconds
WARNING:asyncio:Executing <TimerHandle when=5336.968 _release_waiter(<Future finis...events.py:422>) at C:\Python38\lib\asyncio\tasks.py:429 created at C:\Python38\lib\asyncio\tasks.py:467> took 0.344 seconds
ERROR:asyncio:Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
handle: <Handle _ProactorBasePipeTransport._call_connection_lost(None) created at C:\Python38\lib\asyncio\proactor_events.py:108>
source_traceback: Object created at (most recent call last):
  File "C:\Python38\lib\asyncio\base_events.py", line 1851, in _run_once
    handle._run()
  File "C:\Python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Python38\lib\site-packages\pyrogram\session\session.py", line 216, in restart
    await self.stop()
  File "C:\Python38\lib\site-packages\pyrogram\session\session.py", line 196, in stop
    self.connection.close()
  File "C:\Python38\lib\site-packages\pyrogram\connection\connection.py", line 73, in close
    self.protocol.close()
  File "C:\Python38\lib\site-packages\pyrogram\connection\transport\tcp\tcp.py", line 86, in close
    self.writer.close()
  File "C:\Python38\lib\asyncio\streams.py", line 353, in close
    return self._transport.close()
  File "C:\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
Traceback (most recent call last):
  File "C:\Python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Python38\lib\asyncio\proactor_events.py", line 162, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
C:\Python38\lib\asyncio\proactor_events.py:115: ResourceWarning: unclosed transport <_ProactorSocketTransport closing fd=792>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
F:\PyCharm\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_comm.py:1786: ResourceWarning: unclosed <socks.socksocket fd=792, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.30.12', 51845), raddr=('149.154.167.51', 443)>
  self.cancel_event = threading.Event()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
samthesuperhero commented 4 years ago

Found answer here - thank you!