0

I have a python script that open and mantein a websocket (socket.io) with a remote server and a django instance. For my purpose I want the script to start and stop with the django server. I would also like to exchange data between the two.

In praticular django needs to be notified whenever the remote server goes offline and keep this information globally.

The tricky points for me are:

  1. Start and stop django and the script at the same time.
  2. Store globally the state of the script in the django application

Is there a good way to implement this?

Mario Rossi
  • 107
  • 1
  • 4
  • 12

1 Answers1

0

For the first question, you can definitely try using system commands to run/stop your project. Take a look at this Stack Overflow answer to help you out with that.

For the second question, I can recommend making a class or function based script which you can call globally throughout your app and set it up to be able to receive and update info (i.e. the state).

vladthelad
  • 165
  • 6