Blame view

src/device_controller/concrete_component/sbig/sbig_simulator.py 1.32 KB
12c6569f   Etienne Pallier   Ajout des nouvell...
1
2
3
4
5
6
7
8
#!/usr/bin/env python3

import sys


#sys.path.append("..")
#sys.path.append("../..")
#sys.path.append("../../..")
4783e5b5   Etienne Pallier   GROS RENOMMAGE de...
9
#from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP
12c6569f   Etienne Pallier   Ajout des nouvell...
10
#from device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP
4783e5b5   Etienne Pallier   GROS RENOMMAGE de...
11
from device_controller.concrete_component.device_simulator_common.server_udp_or_tcp import get_SocketServer_UDP_TCP
12c6569f   Etienne Pallier   Ajout des nouvell...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#from server.server_udp_or_tcp import get_SocketServer_UDP_TCP

HOST = "localhost"


# Voir https://stackoverflow.com/questions/10085996/shutdown-socketserver-serve-forever-in-one-thread-python-application

class DeviceSimulatorSBIG:
    #with socketserver_type((HOST, PORT), MyUDPorTCPHandler_classic) as myserver:

    myserver = None

    @classmethod
    def serve_forever(cls, PORT):
        #with get_SocketServer_UDP_TCP(HOST, PORT, "UDP") as myserver: myserver.serve_forever()
        cls.myserver = get_SocketServer_UDP_TCP(HOST, PORT, "UDP")
d5281371   Etienne Pallier   un début de solut...
28
        print("******** myserver serve: *********", cls.myserver)
12c6569f   Etienne Pallier   Ajout des nouvell...
29
30
31
32
33
34
35
36
37
        try:
            cls.myserver.serve_forever()
        except KeyboardInterrupt:
            pass
        cls.myserver.server_close()
        cls.myserver.shutdown()

    @classmethod
    def stop(cls):
d5281371   Etienne Pallier   un début de solut...
38
        print("******** myserver stop: *********", cls.myserver)
12c6569f   Etienne Pallier   Ajout des nouvell...
39
        cls.myserver.shutdown()