LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.77k stars 1.39k forks source link

RuntimeError: There is no current event loop in thread 'Thread-1'. #912

Closed mdenushev closed 6 years ago

mdenushev commented 6 years ago

Hi, there. I upgraded my telethon version to 1.1.1 (telethon-sync == 1.0.4). It was working tommorow perfectly, but today i have this..

Warning (from warnings module):
  File "C:\Program Files\python3.6.5\lib\multiprocessing\pool.py", line 482
    task = job = obj = None
RuntimeWarning: coroutine 'get_entity' was never awaited
Traceback (most recent call last):
  File "C:\Users\Администратор.WIN-H2O5EF29JET\Desktop\11\main.py", line 261, in <module>
    pool_gcp.map(partial(gcp, lock=lock_gcp), links)
  File "C:\Program Files\python3.6.5\lib\multiprocessing\pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Program Files\python3.6.5\lib\multiprocessing\pool.py", line 644, in get
    raise self._value
  File "C:\Program Files\python3.6.5\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Program Files\python3.6.5\lib\multiprocessing\pool.py", line 44, in mapstar
    return list(map(*args))
  File "C:\Users\Администратор.WIN-H2O5EF29JET\Desktop\11\main.py", line 169, in gcp
    info = client.get_entity(link)
  File "C:\Program Files\python3.6.5\lib\site-packages\telethon\sync.py", line 30, in syncified
    coro if asyncio.get_event_loop().is_running()
  File "C:\Program Files\python3.6.5\lib\asyncio\events.py", line 694, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "C:\Program Files\python3.6.5\lib\asyncio\events.py", line 602, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-1'.

but i import telethon.sync

Lonami commented 6 years ago

You should not mix threads with asyncio (which is what the telethon PyPi package uses). The telethon and telethon-sync package are not compatible, install only one. If you don't know what you're doing uninstall telethon and install telethon-sync.

mdenushev commented 6 years ago

Okay, i'm uninstalled telethon main lib

Traceback (most recent call last):
  File "C:\Users\Администратор.WIN-H2O5EF29JET\Desktop\11\main.py", line 1, in <module>
    from telethon import TelegramClient
ImportError: cannot import name 'TelegramClient'
Lonami commented 6 years ago

What version do you have installed now? What does this show?

import telethon
print(telethon.__version__)
print(dir(telethon))
mdenushev commented 6 years ago
>>> import telethon
>>> print(dir(telethon))
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> print(telethon.__version__)
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    print(telethon.__version__)
AttributeError: module 'telethon' has no attribute '__version__'
>>> 

i reinstalled telethon-sync and it's working now

ftuyama commented 4 years ago

telethon-sync is not supported anymore https://github.com/LonamiWebs/Telethon/issues/1180