Changed main structure
This commit is contained in:
parent
21a860f83a
commit
cc24b3c740
17
main.py
17
main.py
@ -1,9 +1,6 @@
|
|||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
from os import getpid
|
from os import getpid
|
||||||
|
|
||||||
from pyrogram.sync import idle
|
|
||||||
|
|
||||||
from modules.app import PyroClient
|
from modules.app import PyroClient
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@ -22,21 +19,17 @@ except ImportError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
def main():
|
||||||
client = PyroClient()
|
client = PyroClient()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await client.start()
|
client.run()
|
||||||
await idle()
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.warning(f"Forcefully shutting down with PID {getpid()}...")
|
logger.warning(f"Forcefully shutting down with PID {getpid()}...")
|
||||||
finally:
|
finally:
|
||||||
await client.stop()
|
client.__exit__()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
event_policy = asyncio.get_event_loop_policy()
|
main()
|
||||||
event_loop = event_policy.new_event_loop()
|
|
||||||
asyncio.set_event_loop(event_loop)
|
|
||||||
event_loop.run_until_complete(main())
|
|
||||||
event_loop.close()
|
|
Reference in New Issue
Block a user