44 lines
911 B
Python
44 lines
911 B
Python
import contextlib
|
|
import logging
|
|
from os import getpid
|
|
|
|
from convopyro import Conversation
|
|
|
|
# This import MUST be done earlier than PyroClient!
|
|
# Even if isort does not like it...
|
|
from modules.cli import *
|
|
|
|
from classes.pyroclient import PyroClient
|
|
from modules.scheduler import scheduler
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
|
|
datefmt="[%X]",
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
with contextlib.suppress(ImportError):
|
|
import uvloop
|
|
|
|
uvloop.install()
|
|
|
|
|
|
def main():
|
|
client = PyroClient(scheduler=scheduler)
|
|
Conversation(client)
|
|
|
|
try:
|
|
client.run()
|
|
except KeyboardInterrupt:
|
|
logger.warning("Forcefully shutting down with PID %s...", getpid())
|
|
finally:
|
|
if client.scheduler is not None:
|
|
client.scheduler.shutdown()
|
|
exit()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|