Forums

Having a problem running telethon using always-on task

When i run my code from directory everything works just fine. But when I try to run the code through always-on task, I get this kind of error:

 Traceback (most recent call last):
  File "/home/Mykola228/try6/main.py", line 10, in <module>
   client.start()
File "/home/Mykola228/.local/lib/python3.9/site-packages/telethon/client/auth.py", line 133, in start
    else self.loop.run_until_complete(coro)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/Mykola228/.local/lib/python3.9/site-packages/telethon/client/auth.py", line 170, in _start
    value = phone()
  File "/home/Mykola228/.local/lib/python3.9/site-packages/telethon/client/auth.py", line 21, in <lambda>
    phone: typing.Callable[[], str] = lambda: input('Please enter your phone (or bot token): '),
EOFError: EOF when reading a line
Please enter your phone (or bot token):

Hope you will help me to solve this problem. Thank you.

You're trying to read information from the terminal (with the input call). There is no terminal in an always on task. You will need to provide that information in a different way. Like including it in the code or reading it from a file.