I have a Django project for a website. And for the same website, I run another Python bot to scrap some data. I was wondering if I could somehow attach the bot to the Django project so that both can run on the same server without causing harm to each other. The bot and other Django apps should run independently of each other.
Does anyone know how this can be done?
Any help will be appreciated.
with the
multiprocessingmodule I got a solution. In themanage.pyfile of a Django project, there's anifstatement at the end that just calls themainfunction defined in the same file.I created two processes using the
multiprocessing.Processclass. One for themainfunction and one for the bot I wanted to attach to the project. Then I started those processes and the bot was running as well as other apps of the Django project.here's the code:
This is just a way of solving the problem. If you have a better solution please add an answer.