Mark Loki
Mark Loki

Reputation: 37

Django - how to run background script in loop

I have install django 3.0 and I want to add on website bot which will listen for events in background, manage server and users. Bot is dedicated for teamspeak application, using https://github.com/benediktschmitt/py-ts3/tree/v2

simple code:

import time
import ts3

with ts3.query.TS3ServerConnection("telnet://localhost:25639") as ts3conn:
        ts3conn.exec_("auth", apikey="AAAA-....-EEEE")

        # Register for events
        ts3conn.exec_("clientnotifyregister", event="any", schandlerid=0)

        while True:
                event = ts3conn.wait_for_event()
                print(event.parsed)

How can I run this in django background, I have try add code with asyncio to manage.py but teamspeak bot connect to server and website doesn't work Shoud I use Celery, django-background-task or just add it as app, how to manage events received by bot in django?

Upvotes: 0

Views: 529

Answers (0)

Related Questions