tasks.py
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from __future__ import absolute_import
from celery.task import Task
from django.templatetags.static import static
import socket
import time
IP = '127.0.0.1'
PORT = 31569
class alert_listener(Task):
'''
Launched at server start
Listens to VOEvents, and create appropriate request when an event is received
'''
def run(self):
print("run")
self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.server_socket.setblocking(True)
self.server_socket.bind((IP, PORT))
self.server_socket.listen(12)
while True:
#il faudra que tout ça soit dans un try ...
self.server_socket.accept()
self.alert_received()
def alert_received(self):
# ici, j'ouvre le fichier des séquences de simulation, et j le lis ligne par ligne
with open("alert_manager/simulation_sequences", 'r') as sequences_file:
sequences = sequences_file.readlines()
sequences = [sequence.strip('\n') for sequence in sequences]
for sequence in sequences:
pass
class change_obs_strategy(Task):
def run(self):
time.sleep(5)
print("change_obs_strategy")